From 1da60f1d44cc2157a8832993952bfea95e8cb6d6 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Mon, 16 Nov 2020 22:09:14 -0800 Subject: [PATCH] [Transforms] Use pred_empty (NFC) --- llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp | 2 +- llvm/lib/Transforms/Utils/CloneFunction.cpp | 3 +-- llvm/lib/Transforms/Utils/InlineFunction.cpp | 2 +- llvm/lib/Transforms/Utils/LoopSimplify.cpp | 2 +- llvm/lib/Transforms/Utils/LowerSwitch.cpp | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp b/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp index fddf28c..bfe8db8 100644 --- a/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp +++ b/llvm/lib/Transforms/Scalar/LowerConstantIntrinsics.cpp @@ -78,7 +78,7 @@ static bool replaceConditionalBranchesOnConstant(Instruction *II, Other->removePredecessor(Source); BI->eraseFromParent(); BranchInst::Create(Target, Source); - if (pred_begin(Other) == pred_end(Other)) + if (pred_empty(Other)) HasDeadBlocks = true; } } diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 3225495..786287b 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -675,8 +675,7 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, // Check if this block has become dead during inlining or other // simplifications. Note that the first block will appear dead, as it has // not yet been wired up properly. - if (I != Begin && (pred_begin(&*I) == pred_end(&*I) || - I->getSinglePredecessor() == &*I)) { + if (I != Begin && (pred_empty(&*I) || I->getSinglePredecessor() == &*I)) { BasicBlock *DeadBB = &*I++; DeleteDeadBlock(DeadBB); continue; diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp index 75ffb40..54c5825 100644 --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -2471,7 +2471,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, // If we inlined any musttail calls and the original return is now // unreachable, delete it. It can only contain a bitcast and ret. - if (InlinedMustTailCalls && pred_begin(AfterCallBB) == pred_end(AfterCallBB)) + if (InlinedMustTailCalls && pred_empty(AfterCallBB)) AfterCallBB->eraseFromParent(); // We should always be able to fold the entry block of the function into the diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp index 6c09baf..817dfc2 100644 --- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp +++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp @@ -689,7 +689,7 @@ ReprocessLoop: LLVM_DEBUG(dbgs() << "LoopSimplify: Eliminating exiting block " << ExitingBlock->getName() << "\n"); - assert(pred_begin(ExitingBlock) == pred_end(ExitingBlock)); + assert(pred_empty(ExitingBlock)); Changed = true; LI->removeBlock(ExitingBlock); diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp index a297d6d..b207599 100644 --- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp +++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp @@ -518,7 +518,7 @@ void ProcessSwitchInst(SwitchInst *SI, OrigBlock->getInstList().erase(SI); // If the Default block has no more predecessors just add it to DeleteList. - if (pred_begin(OldDefault) == pred_end(OldDefault)) + if (pred_empty(OldDefault)) DeleteList.insert(OldDefault); } -- 2.7.4