[PATCH] When stripping debug info, also rewrite @llvm.debugtrap to @llvm.trap.
Richard Diamond
wichard at vitalitystudios.com
Tue Jun 9 16:01:02 PDT 2015
Hi jfb,
REPOSITORY
rL LLVM
http://reviews.llvm.org/D10349
Files:
lib/IR/DebugInfo.cpp
test/CodeGen/X86/trap.ll
test/DebugInfo/rewrite-debug-trap.ll
Index: lib/IR/DebugInfo.cpp
===================================================================
--- lib/IR/DebugInfo.cpp
+++ lib/IR/DebugInfo.cpp
@@ -343,6 +343,18 @@
Changed = true;
}
+ // Rewrite `@llvm.debugtrap` to `@llvm.trap`.
+ if (Function *DbgTrap = M.getFunction("llvm.debugtrap")) {
+ Function* Trap = Intrinsic::getDeclaration(&M, Intrinsic::trap);
+ while (!DbgTrap->use_empty()) {
+ CallInst *CI = cast<CallInst>(DbgTrap->user_back());
+ CallInst::Create(Trap, None, "", CI);
+ CI->eraseFromParent();
+ }
+ DbgTrap->eraseFromParent();
+ Changed = true;
+ }
+
for (Module::named_metadata_iterator NMI = M.named_metadata_begin(),
NME = M.named_metadata_end(); NMI != NME;) {
NamedMDNode *NMD = NMI;
Index: test/CodeGen/X86/trap.ll
===================================================================
--- test/CodeGen/X86/trap.ll
+++ test/CodeGen/X86/trap.ll
@@ -26,6 +26,9 @@
unreachable
}
-declare void @llvm.trap() nounwind
-declare void @llvm.debugtrap() nounwind
+declare void @llvm.trap() nounwind
+declare void @llvm.debugtrap() nounwind
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
Index: test/DebugInfo/rewrite-debug-trap.ll
===================================================================
--- /dev/null
+++ test/DebugInfo/rewrite-debug-trap.ll
@@ -0,0 +1,13 @@
+; RUN: opt -strip-debug < %s -S | FileCheck %s
+
+; CHECK-NOT: llvm.debugtrap
+
+declare void @llvm.debugtrap()
+
+; CHECK-LABEL: @call_debugtrap
+define void @call_debugtrap() {
+entry:
+; CHECK: call void @llvm.trap()
+ call void @llvm.debugtrap()
+ ret void
+}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10349.27411.patch
Type: text/x-patch
Size: 1651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150609/23a3dead/attachment.bin>
More information about the llvm-commits
mailing list