aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/NaCl/ExpandVarArgs.cpp
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-05-29 22:47:23 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-05-29 22:47:23 -0700
commit614c108c60ef2ea51d0e5d4db871a5d954f4ecda (patch)
treed8d65d244ab1c7481ae61f8be5a3e9199f4bf32a /lib/Transforms/NaCl/ExpandVarArgs.cpp
parentcfcccc95343088d7d73e0d7be1da5d4c5de57e49 (diff)
PNaCl: Add ExpandSmallArguments pass to widen parameters to 32 bits
This widens i1, i8 and i16 function arguments and return types. Factor out RecreateFunction() helper function from existing PNaCl passes since this is a reoccurring code fragment. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3342 TEST=*.ll tests + PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/15971007
Diffstat (limited to 'lib/Transforms/NaCl/ExpandVarArgs.cpp')
-rw-r--r--lib/Transforms/NaCl/ExpandVarArgs.cpp12
1 files changed, 1 insertions, 11 deletions
diff --git a/lib/Transforms/NaCl/ExpandVarArgs.cpp b/lib/Transforms/NaCl/ExpandVarArgs.cpp
index 3ea093f8f8..36f58416e2 100644
--- a/lib/Transforms/NaCl/ExpandVarArgs.cpp
+++ b/lib/Transforms/NaCl/ExpandVarArgs.cpp
@@ -72,15 +72,7 @@ static void ExpandVarArgFunc(Function *Func) {
SmallVector<Type *, 8> Params(FTy->param_begin(), FTy->param_end());
Params.push_back(PtrType);
FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false);
-
- // In order to change the function's arguments, we have to recreate
- // the function.
- Function *NewFunc = Function::Create(NFTy, Func->getLinkage());
- NewFunc->copyAttributesFrom(Func);
- Func->getParent()->getFunctionList().insert(Func, NewFunc);
- NewFunc->takeName(Func);
- NewFunc->getBasicBlockList().splice(NewFunc->begin(),
- Func->getBasicBlockList());
+ Function *NewFunc = RecreateFunction(Func, NFTy);
// Declare the new argument as "noalias".
NewFunc->setAttributes(
@@ -95,8 +87,6 @@ static void ExpandVarArgFunc(Function *Func) {
NewArg->takeName(Arg);
}
- Func->replaceAllUsesWith(
- ConstantExpr::getBitCast(NewFunc, FTy->getPointerTo()));
Func->eraseFromParent();
Value *VarArgsArg = --NewFunc->arg_end();