Skip to content

Commit 24a1fca

Browse files
committed
more precise naming
1 parent 573c2a9 commit 24a1fca

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

llvm/include/llvm/Transforms/Scalar/JumpThreading.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
169169
bool processGuards(BasicBlock *BB);
170170
bool threadGuard(BasicBlock *BB, IntrinsicInst *Guard, BranchInst *BI);
171171

172-
bool preserveLoopPreHeader(BasicBlock *BB);
172+
bool preserveLoopPredecessor(BasicBlock *BB);
173173

174174
private:
175175
BasicBlock *splitBlockPreds(BasicBlock *BB, ArrayRef<BasicBlock *> Preds,

llvm/lib/Transforms/Scalar/JumpThreading.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ bool JumpThreadingPass::runImpl(Function &F_, FunctionAnalysisManager *FAM_,
335335
if (&BB == &F->getEntryBlock() || DTU->isBBPendingDeletion(&BB))
336336
continue;
337337

338-
if (pred_empty(&BB) && !preserveLoopPreHeader(&BB)) {
338+
if (pred_empty(&BB) && !preserveLoopPredecessor(&BB)) {
339339
// When processBlock makes BB unreachable it doesn't bother to fix up
340340
// the instructions in it. We must remove BB to prevent invalid IR.
341341
LLVM_DEBUG(dbgs() << " JT: Deleting dead block '" << BB.getName()
@@ -1214,38 +1214,38 @@ static bool isOpDefinedInBlock(Value *Op, BasicBlock *BB) {
12141214
return false;
12151215
}
12161216

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
12181218
// invalid IR.
1219-
bool JumpThreadingPass::preserveLoopPreHeader(BasicBlock *BB) {
1219+
bool JumpThreadingPass::preserveLoopPredecessor(BasicBlock *BB) {
12201220
BasicBlock *Succ = BB->getUniqueSuccessor();
1221-
// Check if BB is a pre-header
1221+
// Check if BB is a predecessor
12221222
if (!LoopHeaders.contains(Succ))
12231223
return false;
12241224
// Check for each PHI node in Succ if it uses BB.
12251225
// For each PHI node fulfilling this check, check if it is used by one of its
12261226
// operands, so if there is a circular use. Only verify this for non-PHI
12271227
// instructions since self-references are OK for PHIs. And only verify this
12281228
// 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
12301230
// otherwise, the PHI node may become constant and may be removed, which could
12311231
// lead to a circular reference.
12321232
return llvm::any_of(Succ->phis(), [BB](PHINode &PHI) {
12331233
if (PHI.getBasicBlockIndex(BB) == -1)
12341234
return false;
1235-
bool HasValueDefinedInPreHeader = false;
1235+
bool HasValueDefinedInPredecessor = false;
12361236
bool HasPotentialSelfReference = false;
12371237
for (Value *Op : PHI.operand_values()) {
12381238
Instruction *Inst = dyn_cast<Instruction>(Op);
12391239
if (!Inst)
12401240
continue;
12411241
if (isOpDefinedInBlock(Op, BB))
1242-
HasValueDefinedInPreHeader = true;
1242+
HasValueDefinedInPredecessor = true;
12431243
else if (!isa<PHINode>(Inst) &&
12441244
llvm::any_of(Inst->operand_values(),
12451245
[&PHI](Value *V) { return V == &PHI; }))
12461246
HasPotentialSelfReference = true;
12471247
}
1248-
return HasValueDefinedInPreHeader && HasPotentialSelfReference;
1248+
return HasValueDefinedInPredecessor && HasPotentialSelfReference;
12491249
});
12501250
}
12511251

0 commit comments

Comments
 (0)