@@ -144,40 +144,44 @@ void OptimizeHopToExecutor::allocateBlockStates() {
144
144
// / Solve the dataflow in forward direction.
145
145
void OptimizeHopToExecutor::solveDataflowForward () {
146
146
bool changed = false ;
147
+ bool firstRound = true ;
147
148
do {
148
149
changed = false ;
149
150
for (BlockState &state : blockStates) {
150
151
int newEntry = state.entry ;
151
152
for (SILBasicBlock *pred : state.block ->getPredecessorBlocks ()) {
152
153
newEntry = BlockState::merge (newEntry, block2State[pred]->exit );
153
154
}
154
- if (newEntry != state.entry || state. exit == BlockState::NotSet ) {
155
+ if (newEntry != state.entry || firstRound ) {
155
156
changed = true ;
156
157
state.entry = newEntry;
157
158
if (state.intra == BlockState::NotSet)
158
159
state.exit = state.entry ;
159
160
}
160
161
}
162
+ firstRound = false ;
161
163
} while (changed);
162
164
}
163
165
164
166
// / Solve the dataflow in backward direction.
165
167
void OptimizeHopToExecutor::solveDataflowBackward () {
166
168
bool changed = false ;
169
+ bool firstRound = true ;
167
170
do {
168
171
changed = false ;
169
172
for (BlockState &state : llvm::reverse (blockStates)) {
170
173
int newExit = state.exit ;
171
174
for (SILBasicBlock *succ : state.block ->getSuccessorBlocks ()) {
172
175
newExit = BlockState::merge (newExit, block2State[succ]->entry );
173
176
}
174
- if (newExit != state.exit || state. entry == BlockState::NotSet ) {
177
+ if (newExit != state.exit || firstRound ) {
175
178
changed = true ;
176
179
state.exit = newExit;
177
180
if (state.intra == BlockState::NotSet)
178
181
state.entry = state.exit ;
179
182
}
180
183
}
184
+ firstRound = false ;
181
185
} while (changed);
182
186
}
183
187
@@ -255,7 +259,7 @@ bool OptimizeHopToExecutor::removeDeadHopToExecutors() {
255
259
// might require a dedicated executor, don't remove a preceeding
256
260
// hop_to_executor instruction.
257
261
for (BlockState &state : blockStates) {
258
- state.exit = (state.block ->getTerminator ()-> isFunctionExiting () ?
262
+ state.exit = (state.block ->getSuccessors (). empty () ?
259
263
BlockState::NoExecutorNeeded : BlockState::NotSet);
260
264
state.intra = BlockState::NotSet;
261
265
for (SILInstruction &inst : llvm::reverse (*state.block )) {
0 commit comments