[PATCH] D42965: [CodeGen] Add a -trap-unreachable option for debugging
Dave Green via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 6 07:50:20 PST 2018
dmgreen updated this revision to Diff 133002.
dmgreen retitled this revision from "[ARM] Add an -arm-trap-unreachable for debugging" to "[CodeGen] Add a -trap-unreachable option for debugging".
dmgreen edited the summary of this revision.
dmgreen added a comment.
Sounds like a good idea. Now for all targets. I have not removed the hexagon option, in case it was being used by them.
https://reviews.llvm.org/D42965
Files:
lib/CodeGen/LLVMTargetMachine.cpp
test/CodeGen/ARM/trap-unreachable.ll
Index: test/CodeGen/ARM/trap-unreachable.ll
===================================================================
--- /dev/null
+++ 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 }
Index: lib/CodeGen/LLVMTargetMachine.cpp
===================================================================
--- lib/CodeGen/LLVMTargetMachine.cpp
+++ 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 @@
this->RM = RM;
this->CMModel = CM;
this->OptLevel = OL;
+
+ if (EnableTrapUnreachable)
+ this->Options.TrapUnreachable = true;
}
TargetTransformInfo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42965.133002.patch
Type: text/x-patch
Size: 1118 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180206/e3f35931/attachment.bin>
More information about the llvm-commits
mailing list