Hi,
unfortunately this patch ICEs on the following testcase
/* This used to fail on SPARC with an unaligned memory access.  */

void foo(int n)
{
  struct S {
    int i[n];
    unsigned int b:1;
    int i2;
  } __attribute__ ((packed)) __attribute__ ((aligned (4)));

  struct S s;

  s.i2 = 0;
}

int main(void)
{
  foo(4);
  
  return 0;
}

(in a tetsuite I must have missed during testing) because it check
that field offset is always non-variable.

I merely copied this sanity check from identical one in
lto_fixup_prevailing_decls that however does not fire because it needs
mentions_vars_p_field_decl to record the var first and that never happens.

This patch fixes it by adding an fixup.  Here the variable is local, but
moving n to file scope is allowed.

I have bootstrapped/regtested ppc64-linux, will commit it as obvious.

I apologize for the breakage.  I will prioritize fixing the fallout I caused
this week.

Honza

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 202173)
+++ ChangeLog   (working copy)
@@ -1,5 +1,10 @@
 2013-08-31  Jan Hubicka  <j...@suse.cz>
 
+       * lto.c (mentions_vars_p_field_decl, lto_fixup_prevailing_decls): 
+       DECL_FIELD_OFFSET can contain an reference to variable.
+
+2013-08-31  Jan Hubicka  <j...@suse.cz>
+
        * lto.c (tree_with_vars): Turn into vector.
        (MAYBE_REMEMBER_WITH_VARS): Change to...
        (CHECK_VAR): ... this one.
Index: lto.c
===================================================================
--- lto.c       (revision 202153)
+++ lto.c       (working copy)
@@ -1389,7 +1389,7 @@ mentions_vars_p_field_decl (tree t)
 {
   if (mentions_vars_p_decl_common (t))
     return true;
-  CHECK_NO_VAR (DECL_FIELD_OFFSET (t));
+  CHECK_VAR (DECL_FIELD_OFFSET (t));
   CHECK_NO_VAR (DECL_BIT_FIELD_TYPE (t));
   CHECK_NO_VAR (DECL_QUALIFIER (t));
   CHECK_NO_VAR (DECL_FIELD_BIT_OFFSET (t));
@@ -3207,7 +3207,7 @@ lto_fixup_prevailing_decls (tree t)
        LTO_SET_PREVAIL (DECL_FUNCTION_PERSONALITY (t));
       if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
        {
-         LTO_NO_PREVAIL (DECL_FIELD_OFFSET (t));
+         LTO_SET_PREVAIL (DECL_FIELD_OFFSET (t));
          LTO_NO_PREVAIL (DECL_BIT_FIELD_TYPE (t));
          LTO_NO_PREVAIL (DECL_QUALIFIER (t));
          LTO_NO_PREVAIL (DECL_FIELD_BIT_OFFSET (t));

Reply via email to