From 3ea5cb0df1a992b900b6eefb9da2505792c2c819 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 10 Sep 2002 17:03:06 +0000 Subject: Simplify code (somtimes dramatically), by using the new "auto-insert" feature of instruction constructors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3655 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/FunctionResolution.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'lib/Transforms/IPO/FunctionResolution.cpp') diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index 778cad5f60..9c63dca249 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -60,21 +60,16 @@ static void ConvertCallTo(CallInst *CI, Function *Dest) { for (unsigned i = 1; i < CI->getNumOperands(); ++i) { Value *V = CI->getOperand(i); - if (V->getType() != ParamTys[i-1]) { // Must insert a cast... - Instruction *Cast = new CastInst(V, ParamTys[i-1]); - BBI = ++BB->getInstList().insert(BBI, Cast); - V = Cast; - } + if (V->getType() != ParamTys[i-1]) // Must insert a cast... + V = new CastInst(V, ParamTys[i-1], "argcast", BBI); Params.push_back(V); } - Instruction *NewCall = new CallInst(Dest, Params); - // Replace the old call instruction with a new call instruction that calls // the real function. // - BBI = ++BB->getInstList().insert(BBI, NewCall); + Instruction *NewCall = new CallInst(Dest, Params, "", BBI); // Remove the old call instruction from the program... BB->getInstList().remove(BBI); @@ -104,11 +99,10 @@ static void ConvertCallTo(CallInst *CI, Function *Dest) { // value of the function is actually USED. // if (!CI->use_empty()) { + // Insert the new cast instruction... CastInst *NewCast = new CastInst(NewCall, CI->getType(), - NewCall->getName()); + NewCall->getName(), BBI); CI->replaceAllUsesWith(NewCast); - // Insert the new cast instruction... - BB->getInstList().insert(BBI, NewCast); } } -- cgit v1.2.3-18-g5258