diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-05-09 01:05:50 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-05-09 01:05:50 +0000 |
| commit | d0525a29d1fe364c7a5b4542fdd0de8f8e9817da (patch) | |
| tree | 915b782346e1108763ead68d8951982cace72baf /llvm/lib/Transforms | |
| parent | 21d1dde72a45e5539204d72c23fe7e0a128f7ce4 (diff) | |
| download | bcm5719-llvm-d0525a29d1fe364c7a5b4542fdd0de8f8e9817da.tar.gz bcm5719-llvm-d0525a29d1fe364c7a5b4542fdd0de8f8e9817da.zip | |
Preserve calling conventions when doing IPO
llvm-svn: 21798
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Transforms/IPO/PruneEH.cpp | 9 |
3 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index fd5a5d0215f..59232ed2bce 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -394,6 +394,7 @@ Function *ArgPromotion::DoPromotion(Function *F, // Create the new function body and insert it into the module... Function *NF = new Function(NFTy, F->getLinkage(), F->getName()); + NF->setCallingConv(F->getCallingConv()); F->getParent()->getFunctionList().insert(F, NF); // Get the alias analysis information that we need to update to reflect our @@ -411,7 +412,8 @@ Function *ArgPromotion::DoPromotion(Function *F, // Loop over the operands, inserting GEP and loads in the caller as // appropriate. CallSite::arg_iterator AI = CS.arg_begin(); - for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E; ++I, ++AI) + for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); + I != E; ++I, ++AI) if (!ArgsToPromote.count(I)) Args.push_back(*AI); // Unmodified argument else if (!I->use_empty()) { @@ -441,8 +443,10 @@ Function *ArgPromotion::DoPromotion(Function *F, if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) { New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(), Args, "", Call); + cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); } else { New = new CallInst(NF, Args, "", Call); + cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); if (cast<CallInst>(Call)->isTailCall()) cast<CallInst>(New)->setTailCall(); } diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index 2dbc5c3169a..05fae52bfe1 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -400,6 +400,7 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { // Create the new function body and insert it into the module... Function *NF = new Function(NFTy, F->getLinkage(), F->getName()); + NF->setCallingConv(F->getCallingConv()); F->getParent()->getFunctionList().insert(F, NF); // Loop over all of the callers of the function, transforming the call sites @@ -428,8 +429,10 @@ void DAE::RemoveDeadArgumentsFromFunction(Function *F) { if (InvokeInst *II = dyn_cast<InvokeInst>(Call)) { New = new InvokeInst(NF, II->getNormalDest(), II->getUnwindDest(), Args, "", Call); + cast<InvokeInst>(New)->setCallingConv(CS.getCallingConv()); } else { New = new CallInst(NF, Args, "", Call); + cast<CallInst>(New)->setCallingConv(CS.getCallingConv()); if (cast<CallInst>(Call)->isTailCall()) cast<CallInst>(New)->setTailCall(); } diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index f7bf2418824..7b979d36f23 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -144,10 +144,11 @@ bool PruneEH::SimplifyFunction(Function *F) { if (DoesNotUnwind.count(CG[F])) { // Insert a call instruction before the invoke... std::string Name = II->getName(); II->setName(""); - Value *Call = new CallInst(II->getCalledValue(), - std::vector<Value*>(II->op_begin()+3, - II->op_end()), - Name, II); + CallInst *Call = new CallInst(II->getCalledValue(), + std::vector<Value*>(II->op_begin()+3, + II->op_end()), + Name, II); + Call->setCallingConv(II->getCallingConv()); // Anything that used the value produced by the invoke instruction // now uses the value produced by the call instruction. |

