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

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

Issue 14262011: PNaCl: Add ReplacePtrsWithInts pass for stripping out pointer types (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Fix alloca alignment 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 virtual bool runOnModule(Module &M); 59 virtual bool runOnModule(Module &M);
60 }; 60 };
61 } 61 }
62 62
63 char ExpandVarArgs::ID = 0; 63 char ExpandVarArgs::ID = 0;
64 INITIALIZE_PASS(ExpandVarArgs, "expand-varargs", 64 INITIALIZE_PASS(ExpandVarArgs, "expand-varargs",
65 "Expand out variable argument function definitions and calls", 65 "Expand out variable argument function definitions and calls",
66 false, false) 66 false, false)
67 67
68 static Instruction *CopyDebug(Instruction *NewInst, Instruction *Original) {
69 NewInst->setDebugLoc(Original->getDebugLoc());
70 return NewInst;
71 }
72
73 static void ExpandVarArgFunc(Function *Func) { 68 static void ExpandVarArgFunc(Function *Func) {
74 Type *PtrType = Type::getInt8PtrTy(Func->getContext()); 69 Type *PtrType = Type::getInt8PtrTy(Func->getContext());
75 70
76 FunctionType *FTy = Func->getFunctionType(); 71 FunctionType *FTy = Func->getFunctionType();
77 SmallVector<Type *, 8> Params(FTy->param_begin(), FTy->param_end()); 72 SmallVector<Type *, 8> Params(FTy->param_begin(), FTy->param_end());
78 Params.push_back(PtrType); 73 Params.push_back(PtrType);
79 FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false); 74 FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false);
80 75
81 // In order to change the function's arguments, we have to recreate 76 // In order to change the function's arguments, we have to recreate
82 // the function. 77 // the function.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 ExpandVarArgFunc(Func); 330 ExpandVarArgFunc(Func);
336 } 331 }
337 } 332 }
338 333
339 return Changed; 334 return Changed;
340 } 335 }
341 336
342 ModulePass *llvm::createExpandVarArgsPass() { 337 ModulePass *llvm::createExpandVarArgsPass() {
343 return new ExpandVarArgs(); 338 return new ExpandVarArgs();
344 } 339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698