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

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: Put noalias on the varargs function, not call 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 // In order to change the function's arguments, we have to recreate 81 // In order to change the function's arguments, we have to recreate
82 // the function. 82 // the function.
83 Function *NewFunc = Function::Create(NFTy, Func->getLinkage()); 83 Function *NewFunc = Function::Create(NFTy, Func->getLinkage());
84 NewFunc->copyAttributesFrom(Func); 84 NewFunc->copyAttributesFrom(Func);
85 Func->getParent()->getFunctionList().insert(Func, NewFunc); 85 Func->getParent()->getFunctionList().insert(Func, NewFunc);
86 NewFunc->takeName(Func); 86 NewFunc->takeName(Func);
87 NewFunc->getBasicBlockList().splice(NewFunc->begin(), 87 NewFunc->getBasicBlockList().splice(NewFunc->begin(),
88 Func->getBasicBlockList()); 88 Func->getBasicBlockList());
89 89
90 // Declare the new argument as "noalias".
91 NewFunc->setAttributes(
92 Func->getAttributes().addAttribute(
93 Func->getContext(), FTy->getNumParams() + 1, Attribute::NoAlias));
94
90 // Move the arguments across to the new function. 95 // Move the arguments across to the new function.
91 for (Function::arg_iterator Arg = Func->arg_begin(), E = Func->arg_end(), 96 for (Function::arg_iterator Arg = Func->arg_begin(), E = Func->arg_end(),
92 NewArg = NewFunc->arg_begin(); 97 NewArg = NewFunc->arg_begin();
93 Arg != E; ++Arg, ++NewArg) { 98 Arg != E; ++Arg, ++NewArg) {
94 Arg->replaceAllUsesWith(NewArg); 99 Arg->replaceAllUsesWith(NewArg);
95 NewArg->takeName(Arg); 100 NewArg->takeName(Arg);
96 } 101 }
97 102
98 Func->replaceAllUsesWith( 103 Func->replaceAllUsesWith(
99 ConstantExpr::getBitCast(NewFunc, FTy->getPointerTo())); 104 ConstantExpr::getBitCast(NewFunc, FTy->getPointerTo()));
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 ExpandVarArgFunc(Func); 335 ExpandVarArgFunc(Func);
331 } 336 }
332 } 337 }
333 338
334 return Changed; 339 return Changed;
335 } 340 }
336 341
337 ModulePass *llvm::createExpandVarArgsPass() { 342 ModulePass *llvm::createExpandVarArgsPass() {
338 return new ExpandVarArgs(); 343 return new ExpandVarArgs();
339 } 344 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698