@@ -335,7 +335,7 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
335
335
if (&BB == &F->getEntryBlock () || DTU->isBBPendingDeletion (&BB))
336
336
continue ;
337
337
338
- if (pred_empty (&BB) && !preserveLoopPreHeader (&BB)) {
338
+ if (pred_empty (&BB) && !preserveLoopPredecessor (&BB)) {
339
339
// When processBlock makes BB unreachable it doesn't bother to fix up
340
340
// the instructions in it. We must remove BB to prevent invalid IR.
341
341
LLVM_DEBUG (dbgs () << " JT: Deleting dead block '" << BB.getName ()
@@ -1214,38 +1214,38 @@ static bool isOpDefinedInBlock(Value *Op, BasicBlock *BB) {
1214
1214
return false ;
1215
1215
}
1216
1216
1217
- // Check if BB is a loop pre-header and if it has to be preserved to avoid
1217
+ // Check if BB is a loop predecessor and if it has to be preserved to avoid
1218
1218
// invalid IR.
1219
- bool JumpThreadingPass::preserveLoopPreHeader (BasicBlock *BB) {
1219
+ bool JumpThreadingPass::preserveLoopPredecessor (BasicBlock *BB) {
1220
1220
BasicBlock *Succ = BB->getUniqueSuccessor ();
1221
- // Check if BB is a pre-header
1221
+ // Check if BB is a predecessor
1222
1222
if (!LoopHeaders.contains (Succ))
1223
1223
return false ;
1224
1224
// Check for each PHI node in Succ if it uses BB.
1225
1225
// For each PHI node fulfilling this check, check if it is used by one of its
1226
1226
// operands, so if there is a circular use. Only verify this for non-PHI
1227
1227
// instructions since self-references are OK for PHIs. And only verify this
1228
1228
// for instructions that are defined in BB.
1229
- // If we find corresponding instructions, preserve the pre-header because
1229
+ // If we find corresponding instructions, preserve the predecessor because
1230
1230
// otherwise, the PHI node may become constant and may be removed, which could
1231
1231
// lead to a circular reference.
1232
1232
return llvm::any_of (Succ->phis (), [BB](PHINode &PHI) {
1233
1233
if (PHI.getBasicBlockIndex (BB) == -1 )
1234
1234
return false ;
1235
- bool HasValueDefinedInPreHeader = false ;
1235
+ bool HasValueDefinedInPredecessor = false ;
1236
1236
bool HasPotentialSelfReference = false ;
1237
1237
for (Value *Op : PHI.operand_values ()) {
1238
1238
Instruction *Inst = dyn_cast<Instruction>(Op);
1239
1239
if (!Inst)
1240
1240
continue ;
1241
1241
if (isOpDefinedInBlock (Op, BB))
1242
- HasValueDefinedInPreHeader = true ;
1242
+ HasValueDefinedInPredecessor = true ;
1243
1243
else if (!isa<PHINode>(Inst) &&
1244
1244
llvm::any_of (Inst->operand_values (),
1245
1245
[&PHI](Value *V) { return V == &PHI; }))
1246
1246
HasPotentialSelfReference = true ;
1247
1247
}
1248
- return HasValueDefinedInPreHeader && HasPotentialSelfReference;
1248
+ return HasValueDefinedInPredecessor && HasPotentialSelfReference;
1249
1249
});
1250
1250
}
1251
1251
0 commit comments