mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Enable TrapUnreachable in LLVM.
Enable LLVM's TrapUnreachable flag, which tells it to translate `unreachable` instructions into hardware trap instructions, rather than allowing control flow to "fall through" into whatever code happens to follow it in memory.
This commit is contained in:
parent
75d25acd97
commit
d9f0e88f19
@ -398,6 +398,12 @@ extern "C" LLVMTargetMachineRef LLVMRustCreateTargetMachine(
|
||||
Options.DataSections = DataSections;
|
||||
Options.FunctionSections = FunctionSections;
|
||||
|
||||
// Tell LLVM to translate `unreachable` into an explicit trap instruction.
|
||||
// This limits the extent of possible undefined behavior in some cases, as it
|
||||
// prevents control flow from "falling through" into whatever code happens to
|
||||
// be layed out next in memory.
|
||||
Options.TrapUnreachable = true;
|
||||
|
||||
TargetMachine *TM = TheTarget->createTargetMachine(
|
||||
Trip.getTriple(), RealCPU, Feature, Options, RM, CM, OptLevel);
|
||||
return wrap(TM);
|
||||
|
Loading…
Reference in New Issue
Block a user