Skip to content

Commit 04af661

Browse files
author
Evan Cheng
committed
DAE bug fix. Don't lose parameter attributes on vararg arguments.
llvm-svn: 46113
1 parent 16808a3 commit 04af661

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,19 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) {
590590
ParamAttrsVec.push_back(ParamAttrsWithIndex::get(Args.size(), Attrs));
591591
}
592592

593-
// Reconstruct the ParamAttrsList based on the vector we constructed.
594-
PAL = ParamAttrsList::get(ParamAttrsVec);
595-
596593
if (ExtraArgHack)
597594
Args.push_back(UndefValue::get(Type::Int32Ty));
598595

599-
// Push any varargs arguments on the list
600-
for (; AI != CS.arg_end(); ++AI)
596+
// Push any varargs arguments on the list. Don't forget their attributes.
597+
for (; AI != CS.arg_end(); ++AI) {
601598
Args.push_back(*AI);
599+
uint16_t Attrs = PAL ? PAL->getParamAttrs(index++) : 0;
600+
if (Attrs)
601+
ParamAttrsVec.push_back(ParamAttrsWithIndex::get(Args.size(), Attrs));
602+
}
603+
604+
// Reconstruct the ParamAttrsList based on the vector we constructed.
605+
PAL = ParamAttrsList::get(ParamAttrsVec);
602606

603607
Instruction *New;
604608
if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) {

0 commit comments

Comments
 (0)