Skip to content

Commit 6fa99de

Browse files
committed
Use the LLVM option NoTrapAfterNoreturn
Use this LLVM option: https://llvm.org/doxygen/classllvm_1_1TargetOptions.html#acd83fce25de1ac9f6c975135a8235c22 when TrapUnreachable is enabled. This prevents codegenning unnecessary double-traps in some situations.
1 parent 5fe3528 commit 6fa99de

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
419419
// it prevents control flow from "falling through" into whatever code
420420
// happens to be laid out next in memory.
421421
Options.TrapUnreachable = true;
422+
// But don't emit traps after other traps or no-returns unnecessarily.
423+
Options.NoTrapAfterNoreturn = true;
422424
}
423425

424426
if (Singlethread) {

0 commit comments

Comments
 (0)