public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "fxue at os dot amperecomputing.com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/108117] New: Wrong instruction scheduling on value coming from abnormal SSA Date: Thu, 15 Dec 2022 05:36:05 +0000 [thread overview] Message-ID: <bug-108117-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108117 Bug ID: 108117 Summary: Wrong instruction scheduling on value coming from abnormal SSA Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: fxue at os dot amperecomputing.com Target Milestone: --- Compile the following code with "-O2" on AArch64. #include <stdio.h> #include <setjmp.h> jmp_buf ex_buf; __attribute__((noinline)) int fn_throw(int x) { if (x == 1) longjmp(ex_buf, 1); return 1; } int main(int argc, char** argv) { int va = 0; int vb = 0; if (!setjmp(ex_buf)) { va = fn_throw(1); /* throw via longjmp */ vb = 1; } else printf("Got exception, va = %d\n", va); if (vb) printf("Failed, vb should not = %d!\n", vb); return 0; } Since "fn_throw" involves abnormal control flow transferring, any statement after "va = fn_throw(1)" should not be hoisted prior to the call. In this case, "vb = 1" is moved before it by RTL inst sched, and leads to incorrect result. Similar to C++ exception handling, setjmp/longjmp would generate SSA names occurring in abnormal phi, these should be specially treated. Though, it looks like that RTL passes do not respect this characteristics in any kind of code motions. Now the issue is only exposed on AArch64, for while inst sched1 pass is enabled, but it is also a potential one on other backends.
next reply other threads:[~2022-12-15 5:36 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-12-15 5:36 fxue at os dot amperecomputing.com [this message] 2022-12-15 5:42 ` [Bug rtl-optimization/108117] " pinskia at gcc dot gnu.org 2022-12-15 5:44 ` pinskia at gcc dot gnu.org 2022-12-15 5:46 ` pinskia at gcc dot gnu.org 2022-12-15 7:15 ` amonakov at gcc dot gnu.org 2022-12-15 8:30 ` amonakov at gcc dot gnu.org 2022-12-15 8:54 ` fxue at os dot amperecomputing.com 2022-12-15 9:01 ` pinskia at gcc dot gnu.org 2022-12-15 11:38 ` fxue at os dot amperecomputing.com 2022-12-15 12:44 ` amonakov at gcc dot gnu.org 2022-12-15 18:04 ` pinskia at gcc dot gnu.org 2022-12-15 18:06 ` pinskia at gcc dot gnu.org 2022-12-15 18:17 ` amonakov at gcc dot gnu.org 2022-12-15 18:19 ` pinskia at gcc dot gnu.org 2022-12-15 18:26 ` amonakov at gcc dot gnu.org 2022-12-15 18:33 ` amonakov at gcc dot gnu.org 2022-12-23 7:37 ` amonakov at gcc dot gnu.org 2023-01-13 18:33 ` cvs-commit at gcc dot gnu.org
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=bug-108117-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).