From cd24bb1d3a1957854418f9d14e274304553fa9d1 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 29 Apr 2016 04:56:12 +0000 Subject: [PATCH] [ArgumentPromotion] Propagate operand bundles to promoted call sites We neglected to transfer operand bundles when performing argument promotion. This fixes PR27568. llvm-svn: 267986 --- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 7 +++-- llvm/test/Transforms/ArgumentPromotion/pr27568.ll | 31 +++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Transforms/ArgumentPromotion/pr27568.ll diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index 8823b81..a808df2 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -857,15 +857,18 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F, AttributesVec.push_back(AttributeSet::get(Call->getContext(), CallPAL.getFnAttributes())); + SmallVector OpBundles; + CS.getOperandBundlesAsDefs(OpBundles); + Instruction *New; if (InvokeInst *II = dyn_cast(Call)) { New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(), - Args, "", Call); + Args, OpBundles, "", Call); cast(New)->setCallingConv(CS.getCallingConv()); cast(New)->setAttributes(AttributeSet::get(II->getContext(), AttributesVec)); } else { - New = CallInst::Create(NF, Args, "", Call); + New = CallInst::Create(NF, Args, OpBundles, "", Call); cast(New)->setCallingConv(CS.getCallingConv()); cast(New)->setAttributes(AttributeSet::get(New->getContext(), AttributesVec)); diff --git a/llvm/test/Transforms/ArgumentPromotion/pr27568.ll b/llvm/test/Transforms/ArgumentPromotion/pr27568.ll new file mode 100644 index 0000000..648317a --- /dev/null +++ b/llvm/test/Transforms/ArgumentPromotion/pr27568.ll @@ -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(...) -- 2.7.4