llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.36k stars 12.14k forks source link

[llvm][ARM] Unable to use `.cantunwind` (and similar directives) in inline assembly #115891

Open alexrp opened 2 weeks ago

alexrp commented 2 weeks ago
void _start(void)
{
    asm volatile (".cantunwind");
}
❯ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0
❯ arm-linux-gnueabihf-gcc test.c -nostdlib -fasynchronous-unwind-tables
❯ clang --version
clang version 19.1.2 (git@github.com:llvm/llvm-project.git d5498c39fe6a17e271ad5a02917103445eb89373)
❯ clang --target=arm-linux-gnueabihf test.c -nostdlib -fasynchronous-unwind-tables
test.c:3:19: error: .fnstart must precede .cantunwind directive
    3 |     asm volatile (".cantunwind");
      |                   ^
<inline asm>:1:2: note: instantiated into assembly here
    1 |         .cantunwind
      |         ^
1 error generated.

I would guess that .fnstart/.fnend is lacking similar handling to .cfi_startproc/.cfi_endproc in the integrated assembler?

llvmbot commented 2 weeks ago

@llvm/issue-subscribers-backend-arm

Author: Alex Rønne Petersen (alexrp)

```c void _start(void) { asm volatile (".cantunwind"); } ``` ```console ❯ arm-linux-gnueabihf-gcc --version arm-linux-gnueabihf-gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0 ❯ arm-linux-gnueabihf-gcc test.c -nostdlib -fasynchronous-unwind-tables ❯ clang --version clang version 19.1.2 (git@github.com:llvm/llvm-project.git d5498c39fe6a17e271ad5a02917103445eb89373) ❯ clang --target=arm-linux-gnueabihf test.c -nostdlib -fasynchronous-unwind-tables test.c:3:19: error: .fnstart must precede .cantunwind directive 3 | asm volatile (".cantunwind"); | ^ <inline asm>:1:2: note: instantiated into assembly here 1 | .cantunwind | ^ 1 error generated. ``` I would guess that `.fnstart`/`.fnend` is lacking similar handling to `.cfi_startproc`/`.cfi_endproc` in the integrated assembler?