mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-23 12:08:25 +00:00
When DAE drops the varargs part of a function, ensure any
attributes on the vararg call arguments are also dropped. llvm-svn: 45892
This commit is contained in:
parent
438d36bf7d
commit
6f49217a5e
@ -175,16 +175,29 @@ bool DAE::DeleteDeadVarargs(Function &Fn) {
|
||||
// Pass all the same arguments.
|
||||
Args.assign(CS.arg_begin(), CS.arg_begin()+NumArgs);
|
||||
|
||||
// Drop any attributes that were on the vararg arguments.
|
||||
const ParamAttrsList *PAL = CS.getParamAttrs();
|
||||
if (PAL && PAL->getParamIndex(PAL->size() - 1) > NumArgs) {
|
||||
ParamAttrsVector ParamAttrsVec;
|
||||
for (unsigned i = 0; PAL->getParamIndex(i) <= NumArgs; ++i) {
|
||||
ParamAttrsWithIndex PAWI;
|
||||
PAWI = ParamAttrsWithIndex::get(PAL->getParamIndex(i),
|
||||
PAL->getParamAttrsAtIndex(i));
|
||||
ParamAttrsVec.push_back(PAWI);
|
||||
}
|
||||
PAL = ParamAttrsList::get(ParamAttrsVec);
|
||||
}
|
||||
|
||||
Instruction *New;
|
||||
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {
|
||||
New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
|
||||
Args.begin(), Args.end(), "", Call);
|
||||
cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv());
|
||||
cast<InvokeInst>(New)->setParamAttrs(CS.getParamAttrs());
|
||||
cast<InvokeInst>(New)->setParamAttrs(PAL);
|
||||
} else {
|
||||
New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
|
||||
cast<CallInst>(New)->setCallingConv(CS.getCallingConv());
|
||||
cast<CallInst>(New)->setParamAttrs(CS.getParamAttrs());
|
||||
cast<CallInst>(New)->setParamAttrs(PAL);
|
||||
if (cast<CallInst>(Call)->isTailCall())
|
||||
cast<CallInst>(New)->setTailCall();
|
||||
}
|
||||
|
@ -2,6 +2,9 @@
|
||||
; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | grep signext | count 2
|
||||
; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep inreg
|
||||
; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep zeroext
|
||||
; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep byval
|
||||
|
||||
%struct = type { }
|
||||
|
||||
@g = global i8 0
|
||||
|
||||
@ -11,6 +14,6 @@ define internal i8 @foo(i8* inreg %p, i8 signext %y, ... ) zeroext nounwind {
|
||||
}
|
||||
|
||||
define i32 @bar() {
|
||||
%A = call i8(i8*, i8, ...)* @foo(i8* inreg null, i8 signext 1, i8 2) zeroext nounwind
|
||||
%A = call i8(i8*, i8, ...)* @foo(i8* inreg null, i8 signext 1, %struct* byval null ) zeroext nounwind
|
||||
ret i32 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user