| OLD | NEW |
| 1 //===- ExpandVarArgs.cpp - Expand out variable argument function calls-----===// | 1 //===- ExpandVarArgs.cpp - Expand out variable argument function calls-----===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This pass expands out all use of variable argument functions. | 10 // This pass expands out all use of variable argument functions. |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 | 196 |
| 197 // Split argument list into fixed and variable arguments. | 197 // Split argument list into fixed and variable arguments. |
| 198 SmallVector<Value *, 8> FixedArgs; | 198 SmallVector<Value *, 8> FixedArgs; |
| 199 SmallVector<Value *, 8> VarArgs; | 199 SmallVector<Value *, 8> VarArgs; |
| 200 SmallVector<Type *, 8> VarArgsTypes; | 200 SmallVector<Type *, 8> VarArgsTypes; |
| 201 for (unsigned I = 0; I < FuncType->getNumParams(); ++I) { | 201 for (unsigned I = 0; I < FuncType->getNumParams(); ++I) { |
| 202 FixedArgs.push_back(Call->getArgOperand(I)); | 202 FixedArgs.push_back(Call->getArgOperand(I)); |
| 203 // AttributeSets use 1-based indexing. | 203 // AttributeSets use 1-based indexing. |
| 204 Attrs.push_back(Call->getAttributes().getParamAttributes(I + 1)); | 204 Attrs.push_back(Call->getAttributes().getParamAttributes(I + 1)); |
| 205 } | 205 } |
| 206 Attrs.push_back(AttributeSet::get(*Context, FuncType->getNumParams() + 1, |
| 207 Attribute::NoAlias)); |
| 206 for (unsigned I = FuncType->getNumParams(); | 208 for (unsigned I = FuncType->getNumParams(); |
| 207 I < Call->getNumArgOperands(); ++I) { | 209 I < Call->getNumArgOperands(); ++I) { |
| 208 Value *ArgVal = Call->getArgOperand(I); | 210 Value *ArgVal = Call->getArgOperand(I); |
| 209 if (Call->getAttributes().hasAttribute(I + 1, Attribute::ByVal)) { | 211 if (Call->getAttributes().hasAttribute(I + 1, Attribute::ByVal)) { |
| 210 // For "byval" arguments we must dereference the pointer and | 212 // For "byval" arguments we must dereference the pointer and |
| 211 // make a copy of the struct being passed by value. | 213 // make a copy of the struct being passed by value. |
| 212 ArgVal = CopyDebug(new LoadInst(ArgVal, "vararg_struct_copy", Call), | 214 ArgVal = CopyDebug(new LoadInst(ArgVal, "vararg_struct_copy", Call), |
| 213 Call); | 215 Call); |
| 214 } | 216 } |
| 215 VarArgs.push_back(ArgVal); | 217 VarArgs.push_back(ArgVal); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 ExpandVarArgFunc(Func); | 332 ExpandVarArgFunc(Func); |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 | 335 |
| 334 return Changed; | 336 return Changed; |
| 335 } | 337 } |
| 336 | 338 |
| 337 ModulePass *llvm::createExpandVarArgsPass() { | 339 ModulePass *llvm::createExpandVarArgsPass() { |
| 338 return new ExpandVarArgs(); | 340 return new ExpandVarArgs(); |
| 339 } | 341 } |
| OLD | NEW |