public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10294] Fix looping flag discovery in ipa-pure-const Date: Thu, 25 Nov 2021 11:25:50 +0000 (GMT) [thread overview] Message-ID: <20211125112550.C342A3858435@sourceware.org> (raw) https://gcc.gnu.org/g:298a4694f89ecb512be8ecba0512558996961fae commit r10-10294-g298a4694f89ecb512be8ecba0512558996961fae Author: Jan Hubicka <jh@suse.cz> Date: Sun Nov 21 00:35:22 2021 +0100 Fix looping flag discovery in ipa-pure-const The testcase shows situation where there is non-trivial cycle in the callgraph involving a noreturn call. This cycle is important for const function discovery but not important for pure. IPA pure const uses same strongly connected components for both propagations which makes it to get suboptimal result (does not detect the pure flag). However local pure const gets the situation right becaue it processes functions in right order. This hits rarely executed code in propagate_pure_const that merge results with previously known state that has long standing bug in it that makes it to throw away the looping flag. Bootstrapped/regtested x86_64-linux. gcc/ChangeLog: 2021-11-21 Jan Hubicka <hubicka@ucw.cz> PR ipa/103052 * ipa-pure-const.c (propagate_pure_const): Fix merging of loping flag. gcc/testsuite/ChangeLog: 2021-11-21 Jan Hubicka <hubicka@ucw.cz> PR ipa/103052 * gcc.c-torture/execute/pr103052.c: New test. (cherry picked from commit a0e99d5bb741d3db74a67d492f47b28217fbf88a) Diff: --- gcc/ipa-pure-const.c | 4 +-- gcc/testsuite/gcc.c-torture/execute/pr103052.c | 35 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 564c6629c92..890826aea4c 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -1665,9 +1665,9 @@ propagate_pure_const (void) if (w_l->state_previously_known != IPA_NEITHER && this_state > w_l->state_previously_known) { - this_state = w_l->state_previously_known; if (this_state == IPA_NEITHER) - this_looping = w_l->looping_previously_known; + this_looping = w_l->looping_previously_known; + this_state = w_l->state_previously_known; } if (!this_looping && self_recursive_p (w)) this_looping = true; diff --git a/gcc/testsuite/gcc.c-torture/execute/pr103052.c b/gcc/testsuite/gcc.c-torture/execute/pr103052.c new file mode 100644 index 00000000000..bef8674a43c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr103052.c @@ -0,0 +1,35 @@ +static void js_error(void); +static int top; +static void js_throw(void) +{ + __builtin_exit(0); +} + +// LOCATION A -- if js_pop is here, the bug is present +static void js_pop(void) +{ + if (++top > 100) + js_error(); +} + +static void jsC_error(const char *v) +{ + if (v[0] == 0) + js_error(); + js_throw(); +} +static void checkfutureword(const char *exp) +{ + if (!__builtin_strcmp(exp, "const")) + jsC_error("boom"); +} +static void js_error(void) { + checkfutureword("foo"); + checkfutureword("bar"); + js_pop(); +} +int main(void) +{ + checkfutureword("const"); + __builtin_abort (); +}
reply other threads:[~2021-11-25 11:25 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211125112550.C342A3858435@sourceware.org \ --to=hubicka@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).