aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2006-11-10 00:06:24 +0000
committerTanya Lattner <tonic@nondot.org>2006-11-10 00:06:24 +0000
commitf33d66fe40634ee7a6b1af0f6064463b39b598c3 (patch)
tree03a6b9a76e881c4a399c953e97972208c970cec7
parentbad3d39af3642ffeb5c075cacbabd1267e8afecc (diff)
downloadllvm-f33d66fe40634ee7a6b1af0f6064463b39b598c3.zip
llvm-f33d66fe40634ee7a6b1af0f6064463b39b598c3.tar.gz
llvm-f33d66fe40634ee7a6b1af0f6064463b39b598c3.tar.bz2
Merging from mainline.
llvm-svn: 31611
-rw-r--r--llvm/lib/Transforms/IPO/Inliner.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index edb34be..ef239bd 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -112,8 +112,13 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
// Calls to external functions are never inlinable.
if (Callee->isExternal() ||
CallSites[CSi].getInstruction()->getParent()->getParent() ==Callee){
- std::swap(CallSites[CSi], CallSites.back());
- CallSites.pop_back();
+ if (SCC.size() == 1) {
+ std::swap(CallSites[CSi], CallSites.back());
+ CallSites.pop_back();
+ } else {
+ // Keep the 'in SCC / not in SCC' boundary correct.
+ CallSites.erase(CallSites.begin()+CSi);
+ }
--CSi;
continue;
}
@@ -131,9 +136,16 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
// Attempt to inline the function...
if (InlineCallIfPossible(CS, CG, SCCFunctions)) {
- // Remove this call site from the list.
- std::swap(CallSites[CSi], CallSites.back());
- CallSites.pop_back();
+ // Remove this call site from the list. If possible, use
+ // swap/pop_back for efficiency, but do not use it if doing so would
+ // move a call site to a function in this SCC before the
+ // 'FirstCallInSCC' barrier.
+ if (SCC.size() == 1) {
+ std::swap(CallSites[CSi], CallSites.back());
+ CallSites.pop_back();
+ } else {
+ CallSites.erase(CallSites.begin()+CSi);
+ }
--CSi;
++NumInlined;