Skip to content

Commit 08dd52d

Browse files
committed
[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. llvm-svn: 261942
1 parent ad59b65 commit 08dd52d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

llvm/lib/CodeGen/WinEHPrepare.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,10 +948,11 @@ void WinEHPrepare::removeImplausibleInstructions(Function &F) {
948948
if (FuncletBundleOperand == FuncletPad)
949949
continue;
950950

951-
// Skip call sites which are nounwind intrinsics.
951+
// Skip call sites which are nounwind intrinsics or inline asm.
952952
auto *CalledFn =
953953
dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts());
954-
if (CalledFn && CalledFn->isIntrinsic() && CS.doesNotThrow())
954+
if (CalledFn && ((CalledFn->isIntrinsic() && CS.doesNotThrow()) ||
955+
CS.isInlineAsm()))
955956
continue;
956957

957958
// This call site was not part of this funclet, remove it.

llvm/test/CodeGen/WinEH/wineh-asm.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; RUN: opt -winehprepare < %s
2+
3+
target triple = "x86_64-pc-windows-msvc"
4+
5+
define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
6+
entry:
7+
invoke void @f(i32 1)
8+
to label %exit unwind label %cleanup
9+
10+
cleanup:
11+
%cp = cleanuppad within none []
12+
call void asm sideeffect "", ""()
13+
cleanupret from %cp unwind to caller
14+
15+
exit:
16+
ret void
17+
}
18+
19+
; CHECK-LABEL: define void @test1(
20+
; CHECK: %[[cp:.*]] = cleanuppad within none []
21+
; CHECK-NEXT: call void asm sideeffect "", ""()
22+
; CHECK-NEXT: cleanupret from %[[cp]] unwind to caller
23+
24+
declare void @f(i32)
25+
26+
declare i32 @__CxxFrameHandler3(...)

0 commit comments

Comments
 (0)