public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113795] New: armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error
@ 2024-02-07  6:09 keithp at keithp dot com
  2024-02-07  6:11 ` [Bug c/113795] " keithp at keithp dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: keithp at keithp dot com @ 2024-02-07  6:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113795

            Bug ID: 113795
           Summary: armv8.1m-m.main+pacbti -mbranch-protection=standard
                    -O2 compile error
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: keithp at keithp dot com
  Target Milestone: ---

Created attachment 57348
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57348&action=edit
Reasonably short test case.

A tail-call indirect branch is miscompiled in the attached example.

Without -mbranch-protection=standard:
```
.L2:
        ldr     r4, .L25+4
        movs    r0, #0
        ldr     r4, [r4, #24]
        mov     ip, r4
        str     r4, [sp, #4]
        add     sp, sp, #28
        @ sp needed
        pop     {r4, r5, r6, r7, r8, r9, r10, fp, lr}
        bx      ip
```
With -mbranch-protection=standard:
```
.L2:
        movs    r0, #0
        ldr     r4, .L25+4
        ldr     r4, [r4, #24]
        str     r4, [sp, #4]
        add     sp, sp, #24
        @ sp needed
        pop     {r4, r5, r6, r7, r8, r9, r10, fp, ip, lr}
        aut     ip, lr, sp
        bx      ip
```
Note that in the latter example, the `ip` register doesn't get copied from
`r4`, presumably because `ip` gets clobbered by the PAC operation. That leaves
the indirect branch at the end jumping to a random address.

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

* [Bug c/113795] armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error
  2024-02-07  6:09 [Bug c/113795] New: armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error keithp at keithp dot com
@ 2024-02-07  6:11 ` keithp at keithp dot com
  2024-02-07  6:20 ` keithp at keithp dot com
  2024-02-08 11:17 ` [Bug target/113795] " rearnsha at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: keithp at keithp dot com @ 2024-02-07  6:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113795

--- Comment #1 from keithp at keithp dot com <keithp at keithp dot com> ---
compiler command:

arm-none-eabi-gcc \
    -std=c18 \
    -O2 \
    -mthumb \
    -march=armv8.1-m.main+pacbti+fp \
    -mbranch-protection=standard \
    -o \
    bar.s \
    -S \
    bar.c

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

* [Bug c/113795] armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error
  2024-02-07  6:09 [Bug c/113795] New: armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error keithp at keithp dot com
  2024-02-07  6:11 ` [Bug c/113795] " keithp at keithp dot com
@ 2024-02-07  6:20 ` keithp at keithp dot com
  2024-02-08 11:17 ` [Bug target/113795] " rearnsha at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: keithp at keithp dot com @ 2024-02-07  6:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113795

keithp at keithp dot com <keithp at keithp dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|13.2.1                      |14.0

--- Comment #2 from keithp at keithp dot com <keithp at keithp dot com> ---
Just reproduced this with version 14.0.1 (debian unstable
arm-linux-gnueabi-gcc-14 package)

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

* [Bug target/113795] armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error
  2024-02-07  6:09 [Bug c/113795] New: armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error keithp at keithp dot com
  2024-02-07  6:11 ` [Bug c/113795] " keithp at keithp dot com
  2024-02-07  6:20 ` keithp at keithp dot com
@ 2024-02-08 11:17 ` rearnsha at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rearnsha at gcc dot gnu.org @ 2024-02-08 11:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113795

Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #3 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Same as 113780

*** This bug has been marked as a duplicate of bug 113780 ***

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

end of thread, other threads:[~2024-02-08 11:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07  6:09 [Bug c/113795] New: armv8.1m-m.main+pacbti -mbranch-protection=standard -O2 compile error keithp at keithp dot com
2024-02-07  6:11 ` [Bug c/113795] " keithp at keithp dot com
2024-02-07  6:20 ` keithp at keithp dot com
2024-02-08 11:17 ` [Bug target/113795] " 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).