This is the mail archive of the 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]

[PATCH]: Make valgrind happy with tree-ssa-structalias.c

In get_constraint_for_component_ref, it is apparently possible for
bitsize to not be set by get_inner_reference, even though that would
have to be a bug, since it would imply either that DECL_SIZE of a
FIELD_DECL is NULL, or the first operand of a BIT_FIELD_REF was NULL.

In fact, adding the following assert to get_inner_reference before the
check for size_tree != 0, finds the real bug here:

gcc_assert (size_tree != 0 || (TREE_CODE (exp) != COMPONENT_REF  &&

we get a component_ref with:

 arg 1 <field_decl 0x403462e0 augmentation type <array_type 0x40346284>
        BLK file ../../gcc/unwind-dw2-fde.h line 145
        align 8 offset_align 128
        offset <integer_cst 0x401691b0 constant invariant 0>
        bit offset <integer_cst 0x403450f0 constant invariant 72>
context <record_type 0x403460b8 dwarf_cie>>>

DECL_SIZE on this field_decl is NULL.  I was always under the impression
that DECL_SIZE should always be set, even if it was to a non-constant

I've filed a bug about this, and in the meantime, i'm just going to use
the following workaround for 4.1, which is to set bitsize to -1.
(I also renamed needs_anyoffset so it is consistent with the other

Bootstrapped and regtested on i686-pc-linux-gnu

Index: tree-ssa-structalias.c
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-structalias.c,v
retrieving revision 2.28
diff -u -p -r2.28 tree-ssa-structalias.c
--- tree-ssa-structalias.c	21 Sep 2005 01:42:53 -0000	2.28
+++ tree-ssa-structalias.c	21 Sep 2005 14:07:03 -0000
@@ -2008,12 +2008,12 @@ offset_overlaps_with_access (const unsig
 /* Given a COMPONENT_REF T, return the constraint_expr for it.  */
 static struct constraint_expr
-get_constraint_for_component_ref (tree t, bool *needs_anyoffset)
+get_constraint_for_component_ref (tree t, bool *need_anyoffset)
   struct constraint_expr result;
-  HOST_WIDE_INT bitsize;
+  HOST_WIDE_INT bitsize = -1;
   HOST_WIDE_INT bitpos;
-  tree offset;
+  tree offset = NULL_TREE;
   enum machine_mode mode;
   int unsignedp;
   int volatilep;
@@ -2039,7 +2039,7 @@ get_constraint_for_component_ref (tree t
   t = get_inner_reference (t, &bitsize, &bitpos, &offset, &mode,
 			   &unsignedp, &volatilep, false);
-  result = get_constraint_for (t, needs_anyoffset);
+  result = get_constraint_for (t, need_anyoffset);
   /* This can also happen due to weird offsetof type macros.  */
   if (TREE_CODE (t) != ADDR_EXPR && result.type == ADDRESSOF)
@@ -2051,10 +2051,10 @@ get_constraint_for_component_ref (tree t
       result.offset = bitpos;
-  else if (needs_anyoffset)
+  else if (need_anyoffset)
       result.offset = 0;
-      *needs_anyoffset = true; 
+      *need_anyoffset = true; 

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