This fixes PR49217, we should use w, not node when visiting indirect calls and refs.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk and branch. Richard. 2011-05-29 Richard Guenther <rguent...@suse.de> PR tree-optimization/49217 * ipa-pure-const.c (propagate_pure_const): Fix typos. * gcc.dg/torture/pr49217.c: New testcase. Index: gcc/ipa-pure-const.c =================================================================== *** gcc/ipa-pure-const.c (revision 174393) --- gcc/ipa-pure-const.c (working copy) *************** propagate_pure_const (void) *** 1223,1229 **** break; /* Now process the indirect call. */ ! for (ie = node->indirect_calls; ie; ie = ie->next_callee) { enum pure_const_state_e edge_state = IPA_CONST; bool edge_looping = false; --- 1223,1229 ---- break; /* Now process the indirect call. */ ! for (ie = w->indirect_calls; ie; ie = ie->next_callee) { enum pure_const_state_e edge_state = IPA_CONST; bool edge_looping = false; *************** propagate_pure_const (void) *** 1246,1252 **** break; /* And finally all loads and stores. */ ! for (i = 0; ipa_ref_list_reference_iterate (&node->ref_list, i, ref); i++) { enum pure_const_state_e ref_state = IPA_CONST; bool ref_looping = false; --- 1246,1252 ---- break; /* And finally all loads and stores. */ ! for (i = 0; ipa_ref_list_reference_iterate (&w->ref_list, i, ref); i++) { enum pure_const_state_e ref_state = IPA_CONST; bool ref_looping = false; Index: gcc/testsuite/gcc.dg/torture/pr49217.c =================================================================== *** gcc/testsuite/gcc.dg/torture/pr49217.c (revision 0) --- gcc/testsuite/gcc.dg/torture/pr49217.c (revision 0) *************** *** 0 **** --- 1,26 ---- + /* { dg-do run } */ + /* { dg-options "-fno-early-inlining" } */ + + extern void abort (void); + int i; + static void foo(void); + void __attribute__((noinline)) + bar (void) + { + if (!i) + foo (); + } + static void + foo(void) + { + i = 1; + bar (); + } + int main() + { + i = 0; + bar(); + if (i != 1) + abort (); + return 0; + }