llvm.org GIT mirror llvm / bfc5ae6
When DAE drops the varargs part of a function, ensure any attributes on the vararg call arguments are also dropped. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45892 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan Sands 11 years ago
2 changed file(s) with 19 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
174174 // Pass all the same arguments.
175175 Args.assign(CS.arg_begin(), CS.arg_begin()+NumArgs);
176176
177 // Drop any attributes that were on the vararg arguments.
178 const ParamAttrsList *PAL = CS.getParamAttrs();
179 if (PAL && PAL->getParamIndex(PAL->size() - 1) > NumArgs) {
180 ParamAttrsVector ParamAttrsVec;
181 for (unsigned i = 0; PAL->getParamIndex(i) <= NumArgs; ++i) {
182 ParamAttrsWithIndex PAWI;
183 PAWI = ParamAttrsWithIndex::get(PAL->getParamIndex(i),
184 PAL->getParamAttrsAtIndex(i));
185 ParamAttrsVec.push_back(PAWI);
186 }
187 PAL = ParamAttrsList::get(ParamAttrsVec);
188 }
189
177190 Instruction *New;
178191 if (InvokeInst *II = dyn_cast(Call)) {
179192 New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(),
180193 Args.begin(), Args.end(), "", Call);
181194 cast(New)->setCallingConv(CS.getCallingConv());
182 cast(New)->setParamAttrs(CS.getParamAttrs());
195 cast(New)->setParamAttrs(PAL);
183196 } else {
184197 New = new CallInst(NF, Args.begin(), Args.end(), "", Call);
185198 cast(New)->setCallingConv(CS.getCallingConv());
186 cast(New)->setParamAttrs(CS.getParamAttrs());
199 cast(New)->setParamAttrs(PAL);
187200 if (cast(Call)->isTailCall())
188201 cast(New)->setTailCall();
189202 }
11 ; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | grep signext | count 2
22 ; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep inreg
33 ; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep zeroext
4 ; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep byval
5
6 %struct = type { }
47
58 @g = global i8 0
69
1013 }
1114
1215 define i32 @bar() {
13 %A = call i8(i8*, i8, ...)* @foo(i8* inreg null, i8 signext 1, i8 2) zeroext nounwind
16 %A = call i8(i8*, i8, ...)* @foo(i8* inreg null, i8 signext 1, %struct* byval null ) zeroext nounwind
1417 ret i32 0
1518 }