From: Jakub Jelinek Date: Wed, 12 Nov 2014 23:25:47 +0000 (+0100) Subject: re PR ipa/63838 (ipa-pure-const miscomputes can_throw) X-Git-Tag: releases/gcc-4.8.4~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a0dafa12ecda9767fd2f17181b17749bbcbf3ed;p=thirdparty%2Fgcc.git re PR ipa/63838 (ipa-pure-const miscomputes can_throw) PR ipa/63838 * ipa-pure-const.c (propagate_nothrow): Walk w->indirect_calls chain instead of node->indirect_calls. * g++.dg/ipa/pr63838.C: New test. From-SVN: r217451 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 99bba83ecde7..37584bf14762 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-11-12 Jakub Jelinek + + PR ipa/63838 + * ipa-pure-const.c (propagate_nothrow): Walk w->indirect_calls + chain instead of node->indirect_calls. + 2014-11-10 Daniel Hellstrom Backport from mainline diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index bedc28a8c39c..e3c4b6aee32f 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1429,7 +1429,7 @@ propagate_nothrow (void) else if (e->can_throw_external && !TREE_NOTHROW (y->symbol.decl)) can_throw = true; } - for (ie = node->indirect_calls; ie; ie = ie->next_callee) + for (ie = w->indirect_calls; ie; ie = ie->next_callee) if (ie->can_throw_external) can_throw = true; w_info = (struct ipa_dfs_info *) w->symbol.aux; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3b05295c12bd..a4c8f412d847 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-11-12 Jakub Jelinek + + PR ipa/63838 + * g++.dg/ipa/pr63838.C: New test. + 2014-11-03 Marek Polacek PR c/52769 diff --git a/gcc/testsuite/g++.dg/ipa/pr63838.C b/gcc/testsuite/g++.dg/ipa/pr63838.C new file mode 100644 index 000000000000..d67364900809 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr63838.C @@ -0,0 +1,56 @@ +// PR ipa/63838 +// { dg-do run } +// { dg-options "-O2 -fdump-ipa-pure-const" } +// { dg-final { scan-ipa-dump-not "Function found to be nothrow: void foo" "pure-const" } } +// { dg-final { scan-ipa-dump-not "Function found to be nothrow: void bar" "pure-const" } } +// { dg-final { cleanup-ipa-dump "pure-const" } } + +__attribute__((noinline, noclone)) static void bar (int); +volatile int v; +void (*fn) (); +struct S { S () { v++; } ~S () { v++; } }; + +__attribute__((noinline, noclone)) static void +foo (int x) +{ + v++; + if (x == 5) + bar (x); +} + +__attribute__((noinline, noclone)) static void +bar (int x) +{ + v++; + if (x == 6) + foo (x); + else if (x == 5) + fn (); +} + +__attribute__((noinline, noclone)) int +baz (int x) +{ + S s; + foo (x); +} + +void +throw0 () +{ + throw 0; +} + +int +main () +{ + fn = throw0; + asm volatile ("" : : : "memory"); + try + { + baz (5); + } + catch (int) + { + } +}