Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit a73c41e

Browse files
majnemeralexcrichton
authored andcommitted
[ArgumentPromotion] Propagate operand bundles to promoted call sites
We neglected to transfer operand bundles when performing argument promotion. This fixes PR27568. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267986 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 7513452 commit a73c41e

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

lib/Transforms/IPO/ArgumentPromotion.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,15 +853,18 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F,
853853
AttributesVec.push_back(AttributeSet::get(Call->getContext(),
854854
CallPAL.getFnAttributes()));
855855

856+
SmallVector<OperandBundleDef, 1> OpBundles;
857+
CS.getOperandBundlesAsDefs(OpBundles);
858+
856859
Instruction *New;
857860
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
858861
New = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
859-
Args, "", Call);
862+
Args, OpBundles, "", Call);
860863
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
861864
cast<InvokeInst>(New)->setAttributes(AttributeSet::get(II->getContext(),
862865
AttributesVec));
863866
} else {
864-
New = CallInst::Create(NF, Args, "", Call);
867+
New = CallInst::Create(NF, Args, OpBundles, "", Call);
865868
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
866869
cast<CallInst>(New)->setAttributes(AttributeSet::get(New->getContext(),
867870
AttributesVec));
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; RUN: opt -S -argpromotion < %s | FileCheck %s
2+
target triple = "x86_64-pc-windows-msvc"
3+
4+
define internal void @callee(i8*) {
5+
entry:
6+
call void @thunk()
7+
ret void
8+
}
9+
10+
define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
11+
entry:
12+
invoke void @thunk()
13+
to label %out unwind label %cpad
14+
15+
out:
16+
ret void
17+
18+
cpad:
19+
%pad = cleanuppad within none []
20+
call void @callee(i8* null) [ "funclet"(token %pad) ]
21+
cleanupret from %pad unwind to caller
22+
}
23+
24+
; CHECK-LABEL: define void @test1(
25+
; CHECK: %[[pad:.*]] = cleanuppad within none []
26+
; CHECK-NEXT: call void @callee() [ "funclet"(token %[[pad]]) ]
27+
; CHECK-NEXT: cleanupret from %[[pad]] unwind to caller
28+
29+
declare void @thunk()
30+
31+
declare i32 @__CxxFrameHandler3(...)

0 commit comments

Comments
 (0)