10 changes: 4 additions & 6 deletions llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ static bool HoistThenElseCodeToIf(BranchInst *BI,
do {
// If we are hoisting the terminator instruction, don't move one (making a
// broken BB), instead clone it, and remove BI.
if (isa<TerminatorInst>(I1))
if (I1->isTerminator())
goto HoistTerminator;

// If we're going to hoist a call, make sure that the two instructions we're
Expand Down Expand Up @@ -2336,8 +2336,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
IfBlock1 = nullptr;
} else {
DomBlock = *pred_begin(IfBlock1);
for (BasicBlock::iterator I = IfBlock1->begin(); !isa<TerminatorInst>(I);
++I)
for (BasicBlock::iterator I = IfBlock1->begin(); !I->isTerminator(); ++I)
if (!AggressiveInsts.count(&*I) && !isa<DbgInfoIntrinsic>(I)) {
// This is not an aggressive instruction that we can promote.
// Because of this, we won't be able to get rid of the control flow, so
Expand All @@ -2350,8 +2349,7 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
IfBlock2 = nullptr;
} else {
DomBlock = *pred_begin(IfBlock2);
for (BasicBlock::iterator I = IfBlock2->begin(); !isa<TerminatorInst>(I);
++I)
for (BasicBlock::iterator I = IfBlock2->begin(); !I->isTerminator(); ++I)
if (!AggressiveInsts.count(&*I) && !isa<DbgInfoIntrinsic>(I)) {
// This is not an aggressive instruction that we can promote.
// Because of this, we won't be able to get rid of the control flow, so
Expand Down Expand Up @@ -2922,7 +2920,7 @@ static bool mergeConditionalStoreToAddress(BasicBlock *PTB, BasicBlock *PFB,
isa<StoreInst>(I))
++N;
// Free instructions.
else if (isa<TerminatorInst>(I) || IsaBitcastOfPointerType(I))
else if (I.isTerminator() || IsaBitcastOfPointerType(I))
continue;
else
return false;
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/bugpoint/CrashDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ bool ReduceCrashingInstructions::TestInsts(
// Convert list to set for fast lookup...
SmallPtrSet<Instruction *, 32> Instructions;
for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
assert(!isa<TerminatorInst>(Insts[i]));
assert(!Insts[i]->isTerminator());
Instructions.insert(cast<Instruction>(VMap[Insts[i]]));
}

Expand All @@ -717,7 +717,7 @@ bool ReduceCrashingInstructions::TestInsts(
for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI)
for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) {
Instruction *Inst = &*I++;
if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst) &&
if (!Instructions.count(Inst) && !Inst->isTerminator() &&
!Inst->isEHPad() && !Inst->getType()->isTokenTy() &&
!Inst->isSwiftError()) {
if (!Inst->getType()->isVoidTy())
Expand Down Expand Up @@ -950,7 +950,7 @@ static Error ReduceInsts(BugDriver &BD, BugTester TestFn) {
for (const Function &F : BD.getProgram())
for (const BasicBlock &BB : F)
for (const Instruction &I : BB)
if (!isa<TerminatorInst>(&I))
if (!I.isTerminator())
Insts.push_back(&I);

Expected<bool> Result =
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/Utils/Local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ struct SalvageDebugInfoTest : ::testing::Test {
auto DI = dyn_cast<DbgValueInst>(&I);
if (!DI) {
// The function should only contain debug values and a terminator.
ASSERT_TRUE(isa<TerminatorInst>(&I));
ASSERT_TRUE(I.isTerminator());
continue;
}
EXPECT_EQ(DI->getVariable()->getName(), "x");
Expand Down
4 changes: 2 additions & 2 deletions polly/lib/Analysis/ScopBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ void ScopBuilder::buildAccessFunctions() {
}

bool ScopBuilder::shouldModelInst(Instruction *Inst, Loop *L) {
return !isa<TerminatorInst>(Inst) && !isIgnoredIntrinsic(Inst) &&
return !Inst->isTerminator() && !isIgnoredIntrinsic(Inst) &&
!canSynthesize(Inst, *scop, &SE, L);
}

Expand Down Expand Up @@ -1399,7 +1399,7 @@ static void verifyUses(Scop *S, LoopInfo &LI, DominatorTree &DT) {
continue;

// Branch conditions are encoded in the statement domains.
if (isa<TerminatorInst>(&Inst) && Stmt->isBlockStmt())
if (Inst.isTerminator() && Stmt->isBlockStmt())
continue;

// Verify all uses.
Expand Down
3 changes: 2 additions & 1 deletion polly/lib/Analysis/ScopDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,8 @@ bool ScopDetection::isValidInstruction(Instruction &Inst,
auto *PHI = dyn_cast<PHINode>(OpInst);
if (PHI) {
for (User *U : PHI->users()) {
if (!isa<TerminatorInst>(U))
auto *UI = dyn_cast<Instruction>(U);
if (!UI || !UI->isTerminator())
return false;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion polly/lib/Support/VirtualInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static bool isRoot(const Instruction *Inst) {

// Terminator instructions (in region statements) are required for control
// flow.
if (isa<TerminatorInst>(Inst))
if (Inst->isTerminator())
return true;

// Writes to memory must be honored.
Expand Down