[llvm] r267986 - [ArgumentPromotion] Propagate operand bundles to promoted call sites

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 28 21:56:12 PDT 2016


Author: majnemer
Date: Thu Apr 28 23:56:12 2016
New Revision: 267986

URL: http://llvm.org/viewvc/llvm-project?rev=267986&view=rev
Log:
[ArgumentPromotion] Propagate operand bundles to promoted call sites

We neglected to transfer operand bundles when performing argument
promotion.

This fixes PR27568.

Added:
    llvm/trunk/test/Transforms/ArgumentPromotion/pr27568.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp

Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=267986&r1=267985&r2=267986&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Thu Apr 28 23:56:12 2016
@@ -857,15 +857,18 @@ CallGraphNode *ArgPromotion::DoPromotion
       AttributesVec.push_back(AttributeSet::get(Call->getContext(),
                                                 CallPAL.getFnAttributes()));
 
+    SmallVector<OperandBundleDef, 1> OpBundles;
+    CS.getOperandBundlesAsDefs(OpBundles);
+
     Instruction *New;
     if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
       New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
-                               Args, "", Call);
+                               Args, OpBundles, "", Call);
       cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
       cast<InvokeInst>(New)->setAttributes(AttributeSet::get(II->getContext(),
                                                             AttributesVec));
     } else {
-      New = CallInst::Create(NF, Args, "", Call);
+      New = CallInst::Create(NF, Args, OpBundles, "", Call);
       cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
       cast<CallInst>(New)->setAttributes(AttributeSet::get(New->getContext(),
                                                           AttributesVec));

Added: llvm/trunk/test/Transforms/ArgumentPromotion/pr27568.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/pr27568.ll?rev=267986&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/ArgumentPromotion/pr27568.ll (added)
+++ llvm/trunk/test/Transforms/ArgumentPromotion/pr27568.ll Thu Apr 28 23:56:12 2016
@@ -0,0 +1,31 @@
+; RUN: opt -S -argpromotion < %s | FileCheck %s
+target triple = "x86_64-pc-windows-msvc"
+
+define internal void @callee(i8*) {
+entry:
+  call void @thunk()
+  ret void
+}
+
+define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
+entry:
+  invoke void @thunk()
+          to label %out unwind label %cpad
+
+out:
+  ret void
+
+cpad:
+  %pad = cleanuppad within none []
+  call void @callee(i8* null) [ "funclet"(token %pad) ]
+  cleanupret from %pad unwind to caller
+}
+
+; CHECK-LABEL: define void @test1(
+; CHECK:      %[[pad:.*]] = cleanuppad within none []
+; CHECK-NEXT: call void @callee() [ "funclet"(token %[[pad]]) ]
+; CHECK-NEXT: cleanupret from %[[pad]] unwind to caller
+
+declare void @thunk()
+
+declare i32 @__CxxFrameHandler3(...)




More information about the llvm-commits mailing list