llvm / llvm/llvm-project

[arm] __builtin_trap should emit udf not brk

Open
#211,032 7 comments 0 reactions 0 assignees View on GitHub
backend:ARM
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c
void foo () {
__builtin_trap();
}
```
emits with clang:
```asm
_foo:
brk #0x1
```
but with gcc:
```asm
_foo:
udf #255
```
This makes handling traps from ubsan in the linux kernel compiler dependent, which sucks.
https://lore.kernel.org/llvm/CAD++jLk549ZcSjpRN0G27i1C-n-k-dOpmgvfZBgmHQ5s0F6dJg@mail.gmail.com/

Contributor guide

Open the contributing guide

Research direction

Start with the provided C reproducer and compare the ARM assembly emitted by Clang with GCC, focusing on how __builtin_trap is lowered. The change is complete when the ARM output uses udf #255 instead of brk #0x1, with coverage for the behavior in the compiler's relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.