This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFH] [tree-ssa] disabling lowering for &a->b causes ICE


On Sun, 2004-02-15 at 03:03, Andrew Pinski wrote:
> When I disable the lowering of &a->b in the C or C++ front-ends, I get 
> an
> ICE because for some reason a SSA_NAME made it through to expand.  This
> patch should be used to solve PR 14029 when this is ICE is fixed.
> 
> The test-case I get the ICE with:
> struct a
> {
> int i;
> };
> int *h(struct a *b)
> {
>    return &b->i;
> }
> 
> This works at -O0 because there is no rewrite into SSA.
> I need help figuring out why the variable is not rewrote out of SSA.
>
We were considering b addressable, which is not quite right.  This patch
fixes this problem, but there is something else going on as we try to
get the size of 'unsigned char []' in expand_expr_real_1 while compiling
unwind-dw2.c.

I would add a check for non-null TYPE_SIZE, but I don't know that code,
and doing so causes warnings in tree-dfa.c (the compiler thinks that
we're returning the address of a local in 'return &(TREE_CHAIN (d))'. 
So, there's something else going on.

HTH.  Diego.


$ cvs diff -dup tree-ssa-operands.c
Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-operands.c,v
retrieving revision 1.1.2.9
diff -d -u -p -r1.1.2.9 tree-ssa-operands.c
--- tree-ssa-operands.c 10 Feb 2004 18:24:17 -0000      1.1.2.9
+++ tree-ssa-operands.c 15 Feb 2004 21:46:17 -0000
@@ -1264,12 +1264,22 @@ add_stmt_operand (tree *var_p, tree stmt
 static void
 note_addressable (tree var, stmt_ann_t s_ann)
 {
-  var = get_base_decl (var);
-  if (var && SSA_VAR_P (var))
+  tree sym = get_base_decl (var);
+
+  /* If VAR is a COMPONENT_REF and SYM is a pointer, then VAR is an
+     expression of the form SYM->FIELD.  This means that our caller is
+     processing the expressiong &SYM->FIELD which is equivalent to
+     SYM + offsetof(FIELD).  So, if this is the case, it means that we
+     are not taking the address of SYM and should just return.  */
+  if (TREE_CODE (var) == COMPONENT_REF
+      && POINTER_TYPE_P (TREE_TYPE (sym)))
+    return;
+
+  if (sym && SSA_VAR_P (sym))
     {
       if (s_ann->addresses_taken == NULL)
        s_ann->addresses_taken = BITMAP_GGC_ALLOC ();
-      bitmap_set_bit (s_ann->addresses_taken, var_ann (var)->uid);
+      bitmap_set_bit (s_ann->addresses_taken, var_ann (sym)->uid);
     }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]