1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[DeadArgumentElimination] Propagate operand bundles to promoted call sites

We neglected to transfer operand bundles when performing argument
promotion.

llvm-svn: 268008
This commit is contained in:
David Majnemer 2016-04-29 07:22:36 +00:00
parent 01846957ca
commit 9514917d37
2 changed files with 39 additions and 4 deletions

View File

@ -255,14 +255,17 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
PAL = AttributeSet::get(Fn.getContext(), AttributesVec);
}
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(PAL);
} else {
New = CallInst::Create(NF, Args, "", Call);
New = CallInst::Create(NF, Args, OpBundles, "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setAttributes(PAL);
if (cast<CallInst>(Call)->isTailCall())
@ -948,14 +951,17 @@ bool DAE::RemoveDeadStuffFromFunction(Function *F) {
// Reconstruct the AttributesList based on the vector we constructed.
AttributeSet NewCallPAL = AttributeSet::get(F->getContext(), AttributesVec);
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->getParent());
Args, OpBundles, "", Call->getParent());
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
cast<InvokeInst>(New)->setAttributes(NewCallPAL);
} else {
New = CallInst::Create(NF, Args, "", Call);
New = CallInst::Create(NF, Args, OpBundles, "", Call);
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
cast<CallInst>(New)->setAttributes(NewCallPAL);
if (cast<CallInst>(Call)->isTailCall())

View File

@ -0,0 +1,29 @@
; RUN: opt -S -deadargelim < %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 %good1 unwind label %bad1
good1: ; preds = %entry-block
ret void
bad1: ; preds = %entry-block
%pad1 = cleanuppad within none []
call void @callee(i8* null) [ "funclet"(token %pad1) ]
cleanupret from %pad1 unwind to caller
}
; CHECK-LABEL: define void @test1(
; CHECK: %[[pad:.*]] = cleanuppad within none []
; CHECK-NEXT: call void @callee() [ "funclet"(token %[[pad]]) ]
declare void @thunk()
declare i32 @__CxxFrameHandler3(...)