File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -112,8 +112,13 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
112
112
// Calls to external functions are never inlinable.
113
113
if (Callee->isExternal () ||
114
114
CallSites[CSi].getInstruction ()->getParent ()->getParent () ==Callee){
115
- std::swap (CallSites[CSi], CallSites.back ());
116
- CallSites.pop_back ();
115
+ if (SCC.size () == 1 ) {
116
+ std::swap (CallSites[CSi], CallSites.back ());
117
+ CallSites.pop_back ();
118
+ } else {
119
+ // Keep the 'in SCC / not in SCC' boundary correct.
120
+ CallSites.erase (CallSites.begin ()+CSi);
121
+ }
117
122
--CSi;
118
123
continue ;
119
124
}
@@ -131,9 +136,16 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
131
136
132
137
// Attempt to inline the function...
133
138
if (InlineCallIfPossible (CS, CG, SCCFunctions)) {
134
- // Remove this call site from the list.
135
- std::swap (CallSites[CSi], CallSites.back ());
136
- CallSites.pop_back ();
139
+ // Remove this call site from the list. If possible, use
140
+ // swap/pop_back for efficiency, but do not use it if doing so would
141
+ // move a call site to a function in this SCC before the
142
+ // 'FirstCallInSCC' barrier.
143
+ if (SCC.size () == 1 ) {
144
+ std::swap (CallSites[CSi], CallSites.back ());
145
+ CallSites.pop_back ();
146
+ } else {
147
+ CallSites.erase (CallSites.begin ()+CSi);
148
+ }
137
149
--CSi;
138
150
139
151
++NumInlined;
You can’t perform that action at this time.
0 commit comments