[llvm] r261942 - [WinEH] Don't remove unannotated inline-asm calls

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 25 16:04:25 PST 2016


Author: majnemer
Date: Thu Feb 25 18:04:25 2016
New Revision: 261942

URL: http://llvm.org/viewvc/llvm-project?rev=261942&view=rev
Log:
[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.

Added:
    llvm/trunk/test/CodeGen/WinEH/wineh-asm.ll
Modified:
    llvm/trunk/lib/CodeGen/WinEHPrepare.cpp

Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=261942&r1=261941&r2=261942&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Thu Feb 25 18:04:25 2016
@@ -948,10 +948,11 @@ void WinEHPrepare::removeImplausibleInst
         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.

Added: llvm/trunk/test/CodeGen/WinEH/wineh-asm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WinEH/wineh-asm.ll?rev=261942&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/WinEH/wineh-asm.ll (added)
+++ llvm/trunk/test/CodeGen/WinEH/wineh-asm.ll Thu Feb 25 18:04:25 2016
@@ -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(...)




More information about the llvm-commits mailing list