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 | adfd32f8eefc804dce24d14450c10f592e643e2d (patch) | |
tree | 30714d73d0aa55afbf75cce036d969dc14dbc67a /lib/Transforms/Utils/InlineFunction.cpp | |
parent | 59a20773f8f7b45a7558e5442aa506c752353d35 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15030 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r-- | lib/Transforms/Utils/InlineFunction.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 0d7dcc3426..51fbd14ebf 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/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. |