diff options
author | David Green <david.green@arm.com> | 2018-02-12 11:06:27 +0000 |
---|---|---|
committer | David Green <david.green@arm.com> | 2018-02-12 11:06:27 +0000 |
commit | 6d9f8c98172cd4d648e33b21679325227c5cec83 (patch) | |
tree | d215f2aebd4885fdc5f3cb49706065b39a2edd69 | |
parent | 3cfaf3dd0def9f87ebfcc530bfe0c26a444a27ac (diff) | |
download | bcm5719-llvm-6d9f8c98172cd4d648e33b21679325227c5cec83.tar.gz bcm5719-llvm-6d9f8c98172cd4d648e33b21679325227c5cec83.zip |
[CodeGen] Add a -trap-unreachable option for debugging
Add a common -trap-unreachable option, similar to the target
specific hexagon equivalent, which has been replaced. This
turns unreachable instructions into traps, which is useful for
debugging.
Differential Revision: https://reviews.llvm.org/D42965
llvm-svn: 324880
-rw-r--r-- | llvm/lib/CodeGen/LLVMTargetMachine.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp | 6 | ||||
-rw-r--r-- | llvm/test/CodeGen/ARM/trap-unreachable.ll | 8 | ||||
-rw-r--r-- | llvm/test/CodeGen/Hexagon/trap-unreachable.ll | 2 |
4 files changed, 16 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index 4c6e21ab315..b4039c0a332 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -34,6 +34,10 @@ #include "llvm/Target/TargetOptions.h" using namespace llvm; +static cl::opt<bool> EnableTrapUnreachable("trap-unreachable", + cl::Hidden, cl::ZeroOrMore, cl::init(false), + cl::desc("Enable generating trap for unreachable")); + void LLVMTargetMachine::initAsmInfo() { MRI = TheTarget.createMCRegInfo(getTargetTriple().str()); MII = TheTarget.createMCInstrInfo(); @@ -79,6 +83,9 @@ LLVMTargetMachine::LLVMTargetMachine(const Target &T, this->RM = RM; this->CMModel = CM; this->OptLevel = OL; + + if (EnableTrapUnreachable) + this->Options.TrapUnreachable = true; } TargetTransformInfo diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp index 4ecfc0753b9..80ae474822c 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -97,10 +97,6 @@ static cl::opt<bool> EnableVectorPrint("enable-hexagon-vector-print", static cl::opt<bool> EnableVExtractOpt("hexagon-opt-vextract", cl::Hidden, cl::ZeroOrMore, cl::init(true), cl::desc("Enable vextract optimization")); -static cl::opt<bool> EnableTrapUnreachable("hexagon-trap-unreachable", - cl::Hidden, cl::ZeroOrMore, cl::init(false), - cl::desc("Enable generating trap for unreachable")); - /// HexagonTargetMachineModule - Note that this is used on hosts that /// cannot link in a library unless there are references into the /// library. In particular, it seems that it is not possible to get @@ -219,8 +215,6 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT, TT, CPU, FS, Options, getEffectiveRelocModel(RM), getEffectiveCodeModel(CM), (HexagonNoOpt ? CodeGenOpt::None : OL)), TLOF(make_unique<HexagonTargetObjectFile>()) { - if (EnableTrapUnreachable) - this->Options.TrapUnreachable = true; initializeHexagonExpandCondsetsPass(*PassRegistry::getPassRegistry()); initAsmInfo(); } diff --git a/llvm/test/CodeGen/ARM/trap-unreachable.ll b/llvm/test/CodeGen/ARM/trap-unreachable.ll new file mode 100644 index 00000000000..605d5a23429 --- /dev/null +++ b/llvm/test/CodeGen/ARM/trap-unreachable.ll @@ -0,0 +1,8 @@ +; RUN: llc -mtriple=thumbv7 -trap-unreachable < %s | FileCheck %s +; CHECK: .inst.n 0xdefe + +define void @test() #0 { + unreachable +} + +attributes #0 = { nounwind } diff --git a/llvm/test/CodeGen/Hexagon/trap-unreachable.ll b/llvm/test/CodeGen/Hexagon/trap-unreachable.ll index 74bc104afaf..9c47fb372c0 100644 --- a/llvm/test/CodeGen/Hexagon/trap-unreachable.ll +++ b/llvm/test/CodeGen/Hexagon/trap-unreachable.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=hexagon -hexagon-trap-unreachable < %s | FileCheck %s +; RUN: llc -march=hexagon -trap-unreachable < %s | FileCheck %s ; CHECK: call abort define void @fred() #0 { |