public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/99271] New: [10/11 regression] Wrong code for Arm-v8-m.main CMSE calling __gnu_cmse_nonsecure_call
@ 2021-02-25 14:58 rearnsha at gcc dot gnu.org
  2021-02-25 14:58 ` [Bug target/99271] " rearnsha at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2021-02-25 14:58 UTC (permalink / raw)
  To: gcc-bugs

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}

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-03-01 17:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 14:58 [Bug target/99271] New: [10/11 regression] Wrong code for Arm-v8-m.main CMSE calling __gnu_cmse_nonsecure_call rearnsha at gcc dot gnu.org
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

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).