File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
include/swift/SILOptimizer/Utils Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -136,13 +136,19 @@ bool canCloneTerminator(TermInst *termInst);
136
136
class SinkAddressProjections {
137
137
// Projections ordered from last to first in the chain.
138
138
SmallVector<SingleValueInstruction *, 4 > oldProjections;
139
+ // Cloned projections to avoid address phis.
140
+ SmallVectorImpl<SingleValueInstruction *> *newProjections;
139
141
SmallSetVector<SILValue, 4 > inBlockDefs;
140
142
141
143
// Transient per-projection data for use during cloning.
142
144
SmallVector<Operand *, 4 > usesToReplace;
143
145
llvm::SmallDenseMap<SILBasicBlock *, Operand *, 4 > firstBlockUse;
144
146
145
147
public:
148
+ SinkAddressProjections (
149
+ SmallVectorImpl<SingleValueInstruction *> *newProjections = nullptr )
150
+ : newProjections(newProjections) {}
151
+
146
152
// / Check for an address projection chain ending at \p inst. Return true if
147
153
// / the given instruction is successfully analyzed.
148
154
// /
@@ -163,6 +169,7 @@ class SinkAddressProjections {
163
169
ArrayRef<SILValue> getInBlockDefs () const {
164
170
return inBlockDefs.getArrayRef ();
165
171
}
172
+
166
173
// / Clone the chain of projections at their use sites.
167
174
// /
168
175
// / Return true if anything was done.
Original file line number Diff line number Diff line change @@ -297,9 +297,12 @@ bool SinkAddressProjections::cloneProjections() {
297
297
auto *useBB = use->getUser ()->getParent ();
298
298
auto *firstUse = firstBlockUse.lookup (useBB);
299
299
SingleValueInstruction *newProj;
300
- if (use == firstUse)
300
+ if (use == firstUse) {
301
301
newProj = cast<SingleValueInstruction>(oldProj->clone (use->getUser ()));
302
- else {
302
+ if (newProjections) {
303
+ newProjections->push_back (newProj);
304
+ }
305
+ } else {
303
306
newProj = cast<SingleValueInstruction>(firstUse->get ());
304
307
assert (newProj->getParent () == useBB);
305
308
newProj->moveFront (useBB);
You can’t perform that action at this time.
0 commit comments