[all-commits] [llvm/llvm-project] 23db37: [CodeGen] Do not emit TRAP for `unreachable` after...
Igor Kudrin via All-commits
all-commits at lists.llvm.org
Tue Jul 2 15:36:24 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 23db37c51cd3dcdcf069345aa7fab7d84b6f6f6e
https://github.com/llvm/llvm-project/commit/23db37c51cd3dcdcf069345aa7fab7d84b6f6f6e
Author: Igor Kudrin <ikudrin at accesssoftek.com>
Date: 2024-07-02 (Tue, 02 Jul 2024)
Changed paths:
M llvm/include/llvm/IR/Instructions.h
M llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/test/CodeGen/X86/trap.ll
M llvm/test/CodeGen/X86/unreachable-trap.ll
A llvm/test/CodeGen/X86/unreachable-ubsantrap.ll
M llvm/test/LTO/X86/unified-cfi.ll
Log Message:
-----------
[CodeGen] Do not emit TRAP for `unreachable` after `@llvm.trap` (#94570)
With `--trap-unreachable`, `clang` can emit double `TRAP` instructions
for code that contains a call to `__builtin_trap()`:
```
> cat test.c
void test() { __builtin_trap(); }
> clang test.c --target=x86_64 -mllvm --trap-unreachable -O1 -S -o -
...
test:
...
ud2
ud2
...
```
`SimplifyCFGPass` inserts `unreachable` after a call to a `noreturn`
function, and later this instruction causes `TRAP/G_TRAP` to be emitted
in `SelectionDAGBuilder::visitUnreachable()` or
`IRTranslator::translateUnreachable()` if
`TargetOptions.TrapUnreachable` is set.
The patch checks the instruction before `unreachable` and avoids
inserting an additional trap.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list