Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: lib/Transforms/NaCl/ExpandVarArgs.cpp

Issue 14060026: PNaCl: Add NoAlias attributes in ExpandByVal and ExpandVarArgs passes (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698