aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-11-09 23:36:08 +0000
committerChris Lattner <sabre@nondot.org>2006-11-09 23:36:08 +0000
commit08ff1480ffcb22e946c7bb6c7d66c5d977ae3d6e (patch)
tree4653b35f5604caa46b4d27d85e325bbfc7fcea34 /lib/Transforms
parent0a629fbbca9d0507e4abec22129fac5e2118f127 (diff)
second patch to fix PR992/993.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/IPO/Inliner.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index b7c4ce1f1f..ef239bd7b9 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/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,8 +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.
- CallSites.erase(CallSites.begin()+CSi);
+ // 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;