public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "me at williamgrant dot id.au" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/57837] New: ARM function pointer tailcall miscompilation regression Date: Sat, 06 Jul 2013 16:16:00 -0000 [thread overview] Message-ID: <bug-57837-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57837 Bug ID: 57837 Summary: ARM function pointer tailcall miscompilation regression Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: me at williamgrant dot id.au Created attachment 30469 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30469&action=edit arm.md fix The fix for PR target/19599 in svn trunk r198928 causes predicated function pointer tailcalls for some ARM targets to lose their predicate and execute unconditionally, resulting in a crash or other misbehaviour. I was able to reproduce the miscompilation, manifesting as a segfault, using -march=armv4t -marm -O3, as below: gcc -march=armv4t -marm -O3 -o bx-test bx-test.c ---- void baz() {}; void (*bar)() = baz; void foo(int c) { if (c == 1) { foo(0); } bar(); } int main(int argc, char **argv) { foo(1); } ---- Today's trunk gives the following asm: ---- foo: cmp r0, #1 stmfd sp!, {r4, lr} ldr r4, .L8 ldrne r3, [r4] ldmnefd sp!, {r4, lr} bx r3 @ indirect register sibling call ---- Note the bx to an r3 that is uninitialised when r0 == 1; it should actually be a bxne. The bug in arm.md is fairly clear: the %? is missing from two bx instructions, so the predicate is omitted. After identifying the bad code I discovered that the issue was raised in review, but deemed irrelevant (http://gcc.gnu.org/ml/gcc-patches/2013-05/msg01022.html). The attached patch fixes the bug for me.
next reply other threads:[~2013-07-06 16:16 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-06 16:16 me at williamgrant dot id.au [this message] 2013-07-10 22:34 ` [Bug target/57837] " ramana at gcc dot gnu.org 2013-07-26 7:02 ` bernd.edlinger at hotmail dot de 2013-07-26 8:16 ` ramana 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-57837-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).