OSDN Git Service

[Hexagon] Add option to generate calls to "abort" for "unreachable"
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>
Wed, 6 Sep 2017 16:22:55 +0000 (16:22 +0000)
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>
Wed, 6 Sep 2017 16:22:55 +0000 (16:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312644 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Hexagon/HexagonTargetMachine.cpp
test/CodeGen/Hexagon/trap-unreachable.ll [new file with mode: 0644]

index 85a69c9..819c984 100644 (file)
@@ -91,6 +91,10 @@ static cl::opt<bool> EnableVectorPrint("enable-hexagon-vector-print",
   cl::Hidden, cl::ZeroOrMore, cl::init(false),
   cl::desc("Enable Hexagon Vector print instr pass"));
 
+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
@@ -195,6 +199,8 @@ 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/test/CodeGen/Hexagon/trap-unreachable.ll b/test/CodeGen/Hexagon/trap-unreachable.ll
new file mode 100644 (file)
index 0000000..74bc104
--- /dev/null
@@ -0,0 +1,8 @@
+; RUN: llc -march=hexagon -hexagon-trap-unreachable < %s | FileCheck %s
+; CHECK: call abort
+
+define void @fred() #0 {
+  unreachable
+}
+
+attributes #0 = { nounwind }