summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-02-26 00:04:25 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-02-26 00:04:25 +0000
commit20cfdfefcf4a45260d19e324a34eb1751d80d5d2 (patch)
treee4df327e0478c84c04509b86918f379ab6b405eb
parent5786b73593d5af728b8b4fa9dc15002e39918083 (diff)
[WinEH] Don't remove unannotated inline-asm calls
Inline-asm calls aren't annotated with funclet bundle operands because they don't throw and cannot be inlined through. We shouldn't require them to bear an funclet bundle operand. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@261942 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/WinEHPrepare.cpp5
-rw-r--r--test/CodeGen/WinEH/wineh-asm.ll26
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/CodeGen/WinEHPrepare.cpp b/lib/CodeGen/WinEHPrepare.cpp
index 8157857bc25..b2b3130e9f1 100644
--- a/lib/CodeGen/WinEHPrepare.cpp
+++ b/lib/CodeGen/WinEHPrepare.cpp
@@ -948,10 +948,11 @@ void WinEHPrepare::removeImplausibleInstructions(Function &F) {
if (FuncletBundleOperand == FuncletPad)
continue;
- // Skip call sites which are nounwind intrinsics.
+ // Skip call sites which are nounwind intrinsics or inline asm.
auto *CalledFn =
dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts());
- if (CalledFn && CalledFn->isIntrinsic() && CS.doesNotThrow())
+ if (CalledFn && ((CalledFn->isIntrinsic() && CS.doesNotThrow()) ||
+ CS.isInlineAsm()))
continue;
// This call site was not part of this funclet, remove it.
diff --git a/test/CodeGen/WinEH/wineh-asm.ll b/test/CodeGen/WinEH/wineh-asm.ll
new file mode 100644
index 00000000000..ed99411810e
--- /dev/null
+++ b/test/CodeGen/WinEH/wineh-asm.ll
@@ -0,0 +1,26 @@
+; RUN: opt -winehprepare < %s
+
+target triple = "x86_64-pc-windows-msvc"
+
+define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
+entry:
+ invoke void @f(i32 1)
+ to label %exit unwind label %cleanup
+
+cleanup:
+ %cp = cleanuppad within none []
+ call void asm sideeffect "", ""()
+ cleanupret from %cp unwind to caller
+
+exit:
+ ret void
+}
+
+; CHECK-LABEL: define void @test1(
+; CHECK: %[[cp:.*]] = cleanuppad within none []
+; CHECK-NEXT: call void asm sideeffect "", ""()
+; CHECK-NEXT: cleanupret from %[[cp]] unwind to caller
+
+declare void @f(i32)
+
+declare i32 @__CxxFrameHandler3(...)