diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-20 05:45:24 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-20 05:45:24 +0000 |
commit | 45b50d14c94465b7d8c0b5e1d5672dd2feaec72e (patch) | |
tree | 91ebc8a0c1fc37ded3ffe2ac38ba348dbcbb50f7 /llvm/lib/Transforms/Utils/InlineFunction.cpp | |
parent | 11ffd59e3753811af9e2e2da12486f51d0a18a52 (diff) | |
download | bcm5719-llvm-45b50d14c94465b7d8c0b5e1d5672dd2feaec72e.tar.gz bcm5719-llvm-45b50d14c94465b7d8c0b5e1d5672dd2feaec72e.zip |
Fix a serious code pessimization problem. If an inlined function has a single
return, clone the 'ret' BB code into the block AFTER the inlined call, not the
other way around.
llvm-svn: 15030
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/InlineFunction.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 0d7dcc34267..51fbd14ebf1 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -304,14 +304,15 @@ bool llvm::InlineFunction(CallSite CS) { // Splice the code from the return block into the block that it will return // to, which contains the code that was after the call. BasicBlock *ReturnBB = Returns[0]->getParent(); - ReturnBB->getInstList().splice(Returns[0], AfterCallBB->getInstList()); + AfterCallBB->getInstList().splice(AfterCallBB->begin(), + ReturnBB->getInstList()); - // Update PHI nodes that use the AfterCallBB to use the ReturnBB. - AfterCallBB->replaceAllUsesWith(ReturnBB); + // Update PHI nodes that use the ReturnBB to use the AfterCallBB. + ReturnBB->replaceAllUsesWith(AfterCallBB); - // Delete the return instruction now and empty AfterCallBB now. + // Delete the return instruction now and empty ReturnBB now. Returns[0]->getParent()->getInstList().erase(Returns[0]); - Caller->getBasicBlockList().erase(AfterCallBB); + Caller->getBasicBlockList().erase(ReturnBB); } // Since we are now done with the Call/Invoke, we can delete it. |