Skip to content

Commit 7a9bfd4

Browse files
authored
Rollup merge of rust-lang#110494 - majaha:noTrapAfterNoreturn, r=nikic
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. See further discussion here: rust-lang/compiler-team#618
2 parents 047dd55 + 6fa99de commit 7a9bfd4

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
437437
// it prevents control flow from "falling through" into whatever code
438438
// happens to be laid out next in memory.
439439
Options.TrapUnreachable = true;
440+
// But don't emit traps after other traps or no-returns unnecessarily.
441+
Options.NoTrapAfterNoreturn = true;
440442
}
441443

442444
if (Singlethread) {

0 commit comments

Comments
 (0)