public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug target/99271] New: [10/11 regression] Wrong code for Arm-v8-m.main CMSE calling __gnu_cmse_nonsecure_call Date: Thu, 25 Feb 2021 14:58:31 +0000 [thread overview] Message-ID: <bug-99271-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99271 Bug ID: 99271 Summary: [10/11 regression] Wrong code for Arm-v8-m.main CMSE calling __gnu_cmse_nonsecure_call Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: rearnsha at gcc dot gnu.org Target Milestone: --- Target: arm The code fragment: typedef void (*f)(int) __attribute__((cmse_nonsecure_call)); void bar(f func, int a) { func(a); } When compiled with -O2 -mcmse -march=armv8-m.main -mthumb Incorrectly optimizes the code sequence so that the register used for the function pointer is not correctly initialized. The problem was introduced in r10-6017, so affects gcc-10 and gcc-11. Current code: mov r3, r0 mov r0, r1 push {r4, lr} lsrs r3, r3, #1 lsls r3, r3, #1 mov r1, r3 mov r2, r3 bl __gnu_cmse_nonsecure_call // r4 not initialized above. pop {r4, pc} Correct code push {r4, lr} mov r4, r0 mov r0, r1 lsrs r4, r4, #1 lsls r4, r4, #1 mov r1, r4 mov r2, r4 mov r3, r4 bl __gnu_cmse_nonsecure_call // r4 = function with LSB cleared. pop {r4, pc}
next reply other threads:[~2021-02-25 14:58 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-25 14:58 rearnsha at gcc dot gnu.org [this message] 2021-02-25 14:58 ` [Bug target/99271] " rearnsha at gcc dot gnu.org 2021-02-25 17:17 ` cvs-commit at gcc dot gnu.org 2021-02-25 17:31 ` [Bug target/99271] [10 " rearnsha at gcc dot gnu.org 2021-02-26 7:12 ` rguenth at gcc dot gnu.org 2021-03-01 17:45 ` cvs-commit at gcc dot gnu.org 2021-03-01 17:46 ` rearnsha 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-99271-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).