diff mbox

[12/18] make CASE_LABEL_EXPR not abuse TREE_CHAIN

Message ID 1299817406-16745-13-git-send-email-froydnj@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd March 11, 2011, 4:23 a.m. UTC
Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
see here.

-Nathan

gcc/
	* tree.def (CASE_LABEL_EXPR): Add an operand.
	* tree.h (CASE_CHAIN): Use TREE_OPERAND instead of TREE_CHAIN.

Comments

Richard Biener March 11, 2011, 1:19 p.m. UTC | #1
On Fri, Mar 11, 2011 at 5:23 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
> see here.

I wonder if there isn't a better way to do this ... like always requiring
operand 2 of SWITCH_EXPRs.

Richard.

> -Nathan
>
> gcc/
>        * tree.def (CASE_LABEL_EXPR): Add an operand.
>        * tree.h (CASE_CHAIN): Use TREE_OPERAND instead of TREE_CHAIN.
>
> diff --git a/gcc/tree.def b/gcc/tree.def
> index eb94ad2..9c6606d 100644
> --- a/gcc/tree.def
> +++ b/gcc/tree.def
> @@ -863,7 +863,7 @@ DEFTREECODE (SWITCH_EXPR, "switch_expr", tcc_statement, 3)
>    CASE_HIGH, respectively. If CASE_LOW is NULL_TREE, the label is a
>    'default' label. If CASE_HIGH is NULL_TREE, the label is a normal case
>    label.  CASE_LABEL is the corresponding LABEL_DECL.  */
> -DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 3)
> +DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 4)
>
>  /* Used to represent an inline assembly statement.  ASM_STRING returns a
>    STRING_CST for the instruction (e.g., "mov x, y"). ASM_OUTPUTS,
> diff --git a/gcc/tree.h b/gcc/tree.h
> index 3e1ff2c..c81186a 100644
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -1689,7 +1689,7 @@ extern void protected_set_expr_location (tree, location_t);
>  #define CASE_LOW(NODE)                 TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 0)
>  #define CASE_HIGH(NODE)                TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 1)
>  #define CASE_LABEL(NODE)               TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 2)
> -#define CASE_CHAIN(NODE)               TREE_CHAIN (CASE_LABEL_EXPR_CHECK (NODE))
> +#define CASE_CHAIN(NODE)               TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 3)
>
>  /* The operands of a TARGET_MEM_REF.  Operands 0 and 1 have to match
>    corresponding MEM_REF operands.  */
> --
> 1.7.0.4
>
>
Nathan Froyd May 10, 2011, 6:55 p.m. UTC | #2
On Fri, Mar 11, 2011 at 02:19:14PM +0100, Richard Guenther wrote:
> On Fri, Mar 11, 2011 at 5:23 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> > Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
> > see here.
> 
> I wonder if there isn't a better way to do this ... like always requiring
> operand 2 of SWITCH_EXPRs.

I'm honestly not sure.  Would it be OK to commit the patch and discuss
other options later?  CASE_LABEL is the last expression-esque node using
TREE_CHAIN.

-Nathan
Diego Novillo May 10, 2011, 7:01 p.m. UTC | #3
On Fri, Mar 11, 2011 at 10:19, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Mar 11, 2011 at 5:23 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
>> Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
>> see here.
>
> I wonder if there isn't a better way to do this ... like always requiring
> operand 2 of SWITCH_EXPRs.

Could be, but I think it makes sense to do it in incremental steps.
This change seems like a step forward in its own sense.  I'm fine with
it.


Diego.
Richard Biener May 11, 2011, 8:35 a.m. UTC | #4
On Tue, May 10, 2011 at 9:01 PM, Diego Novillo <dnovillo@google.com> wrote:
> On Fri, Mar 11, 2011 at 10:19, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Fri, Mar 11, 2011 at 5:23 AM, Nathan Froyd <froydnj@codesourcery.com> wrote:
>>> Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
>>> see here.
>>
>> I wonder if there isn't a better way to do this ... like always requiring
>> operand 2 of SWITCH_EXPRs.
>
> Could be, but I think it makes sense to do it in incremental steps.
> This change seems like a step forward in its own sense.  I'm fine with
> it.

Yeah, ok.

Richard.

>
> Diego.
>
H.J. Lu May 11, 2011, 3:40 p.m. UTC | #5
On Thu, Mar 10, 2011 at 8:23 PM, Nathan Froyd <froydnj@codesourcery.com> wrote:
> Move CASE_CHAIN into a local operand for CASE_LABEL_EXPR.  Nothing to
> see here.
>
> -Nathan
>
> gcc/
>        * tree.def (CASE_LABEL_EXPR): Add an operand.
>        * tree.h (CASE_CHAIN): Use TREE_OPERAND instead of TREE_CHAIN.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48965

This failure is kind of random.  We may have some invalid memory access.
diff mbox

Patch

diff --git a/gcc/tree.def b/gcc/tree.def
index eb94ad2..9c6606d 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -863,7 +863,7 @@  DEFTREECODE (SWITCH_EXPR, "switch_expr", tcc_statement, 3)
    CASE_HIGH, respectively. If CASE_LOW is NULL_TREE, the label is a
    'default' label. If CASE_HIGH is NULL_TREE, the label is a normal case
    label.  CASE_LABEL is the corresponding LABEL_DECL.  */
-DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 3)
+DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 4)
 
 /* Used to represent an inline assembly statement.  ASM_STRING returns a
    STRING_CST for the instruction (e.g., "mov x, y"). ASM_OUTPUTS,
diff --git a/gcc/tree.h b/gcc/tree.h
index 3e1ff2c..c81186a 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1689,7 +1689,7 @@  extern void protected_set_expr_location (tree, location_t);
 #define CASE_LOW(NODE)          	TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 0)
 #define CASE_HIGH(NODE)         	TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 1)
 #define CASE_LABEL(NODE)		TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 2)
-#define CASE_CHAIN(NODE)		TREE_CHAIN (CASE_LABEL_EXPR_CHECK (NODE))
+#define CASE_CHAIN(NODE)		TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 3)
 
 /* The operands of a TARGET_MEM_REF.  Operands 0 and 1 have to match
    corresponding MEM_REF operands.  */