[llvm] c9fca53 - [CodeGen, Target] Use pred_empty and succ_empty (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 11:11:45 PDT 2021
Author: Kazu Hirata
Date: 2021-09-10T11:11:31-07:00
New Revision: c9fca53af10eca9a0ce0e32f553b3b6eb4f0fba6
URL: https://github.com/llvm/llvm-project/commit/c9fca53af10eca9a0ce0e32f553b3b6eb4f0fba6
DIFF: https://github.com/llvm/llvm-project/commit/c9fca53af10eca9a0ce0e32f553b3b6eb4f0fba6.diff
LOG: [CodeGen, Target] Use pred_empty and succ_empty (NFC)
Added:
Modified:
llvm/lib/CodeGen/BranchFolding.cpp
llvm/lib/CodeGen/MachineBlockPlacement.cpp
llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/BranchFolding.cpp b/llvm/lib/CodeGen/BranchFolding.cpp
index 65e7e92fe1521..1638562d9d544 100644
--- a/llvm/lib/CodeGen/BranchFolding.cpp
+++ b/llvm/lib/CodeGen/BranchFolding.cpp
@@ -611,7 +611,7 @@ ProfitableToMerge(MachineBasicBlock *MBB1, MachineBasicBlock *MBB2,
// there are fallthroughs, and we don't know until after layout.
if (AfterPlacement && FullBlockTail1 && FullBlockTail2) {
auto BothFallThrough = [](MachineBasicBlock *MBB) {
- if (MBB->succ_size() != 0 && !MBB->canFallThrough())
+ if (!MBB->succ_empty() && !MBB->canFallThrough())
return false;
MachineFunction::iterator I(MBB);
MachineFunction *MF = MBB->getParent();
diff --git a/llvm/lib/CodeGen/MachineBlockPlacement.cpp b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
index 27c109242340f..8a1b4031642d7 100644
--- a/llvm/lib/CodeGen/MachineBlockPlacement.cpp
+++ b/llvm/lib/CodeGen/MachineBlockPlacement.cpp
@@ -1185,7 +1185,7 @@ bool MachineBlockPlacement::canTailDuplicateUnplacedPreds(
// The integrated tail duplication is really designed for increasing
// fallthrough from predecessors from Succ to its successors. We may need
// other machanism to handle
diff erent cases.
- if (Succ->succ_size() == 0)
+ if (Succ->succ_empty())
return true;
// Plus the already placed predecessor.
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
index 697513b5db7a1..2e6f0898e681d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMachineCFGStructurizer.cpp
@@ -606,7 +606,7 @@ MRT::initializeMRT(MachineFunction &MF, const MachineRegionInfo *RegionInfo,
DenseMap<MachineRegion *, RegionMRT *> &RegionMap) {
for (auto &MFI : MF) {
MachineBasicBlock *ExitMBB = &MFI;
- if (ExitMBB->succ_size() == 0) {
+ if (ExitMBB->succ_empty()) {
return ExitMBB;
}
}
@@ -1686,7 +1686,7 @@ void AMDGPUMachineCFGStructurizer::insertUnconditionalBranch(MachineBasicBlock *
static MachineBasicBlock *getSingleExitNode(MachineFunction &MF) {
MachineBasicBlock *result = nullptr;
for (auto &MFI : MF) {
- if (MFI.succ_size() == 0) {
+ if (MFI.succ_empty()) {
if (result == nullptr) {
result = &MFI;
} else {
diff --git a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
index 7a69d990fef42..3f36dec694e7a 100644
--- a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp
@@ -246,7 +246,7 @@ class AMDGPUCFGStructurizer : public MachineFunctionPass {
int loopendPatternMatch();
int mergeLoop(MachineLoop *LoopRep);
- /// return true iff src1Blk->succ_size() == 0 && src1Blk and src2Blk are in
+ /// return true iff src1Blk->succ_empty() && src1Blk and src2Blk are in
/// the same loop with LoopLandInfo without explicitly keeping track of
/// loopContBlks and loopBreakBlks, this is a method to get the information.
bool isSameloopDetachedContbreak(MachineBasicBlock *Src1MBB,
@@ -618,7 +618,7 @@ MachineInstr *AMDGPUCFGStructurizer::getReturnInstr(MachineBasicBlock *MBB) {
bool AMDGPUCFGStructurizer::isReturnBlock(MachineBasicBlock *MBB) {
MachineInstr *MI = getReturnInstr(MBB);
- bool IsReturn = (MBB->succ_size() == 0);
+ bool IsReturn = MBB->succ_empty();
if (MI)
assert(IsReturn);
else if (IsReturn)
@@ -809,7 +809,7 @@ bool AMDGPUCFGStructurizer::run() {
MachineBasicBlock *EntryMBB =
*GraphTraits<MachineFunction *>::nodes_begin(FuncRep);
- if (EntryMBB->succ_size() == 0) {
+ if (EntryMBB->succ_empty()) {
Finish = true;
LLVM_DEBUG(dbgs() << "Reduce to one block\n";);
} else {
@@ -1055,7 +1055,7 @@ int AMDGPUCFGStructurizer::mergeLoop(MachineLoop *LoopRep) {
bool AMDGPUCFGStructurizer::isSameloopDetachedContbreak(
MachineBasicBlock *Src1MBB, MachineBasicBlock *Src2MBB) {
- if (Src1MBB->succ_size() == 0) {
+ if (Src1MBB->succ_empty()) {
MachineLoop *LoopRep = MLI->getLoopFor(Src1MBB);
if (LoopRep&& LoopRep == MLI->getLoopFor(Src2MBB)) {
MachineBasicBlock *&TheEntry = LLInfoMap[LoopRep];
@@ -1394,7 +1394,7 @@ void AMDGPUCFGStructurizer::mergeIfthenelseBlock(MachineInstr *BranchMI,
MBB->splice(I, FalseMBB, FalseMBB->begin(),
FalseMBB->end());
MBB->removeSuccessor(FalseMBB, true);
- if (LandMBB && FalseMBB->succ_size() != 0)
+ if (LandMBB && !FalseMBB->succ_empty())
FalseMBB->removeSuccessor(LandMBB, true);
retireBlock(FalseMBB);
MLI->removeBlock(FalseMBB);
@@ -1640,8 +1640,7 @@ void AMDGPUCFGStructurizer::retireBlock(MachineBasicBlock *MBB) {
SrcBlkInfo = new BlockInformation();
SrcBlkInfo->IsRetired = true;
- assert(MBB->succ_size() == 0 && MBB->pred_size() == 0
- && "can't retire block yet");
+ assert(MBB->succ_empty() && MBB->pred_empty() && "can't retire block yet");
}
INITIALIZE_PASS_BEGIN(AMDGPUCFGStructurizer, "amdgpustructurizer",
diff --git a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
index 08e8ac6903801..d54d1d242c594 100644
--- a/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
+++ b/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
@@ -564,7 +564,7 @@ void ARMLoadStoreOpt::UpdateBaseRegUses(MachineBasicBlock &MBB,
}
// End of block was reached.
- if (MBB.succ_size() > 0) {
+ if (!MBB.succ_empty()) {
// FIXME: Because of a bug, live registers are sometimes missing from
// the successor blocks' live-in sets. This means we can't trust that
// information and *always* have to reset at the end of a block.
diff --git a/llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp b/llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp
index d36ffc3da6416..c3aa905598f10 100644
--- a/llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonEarlyIfConv.cpp
@@ -364,7 +364,7 @@ bool HexagonEarlyIfConversion::isValidCandidate(const MachineBasicBlock *B)
return true;
if (B->isEHPad() || B->hasAddressTaken())
return false;
- if (B->succ_size() == 0)
+ if (B->succ_empty())
return false;
for (auto &MI : *B) {
@@ -570,12 +570,12 @@ bool HexagonEarlyIfConversion::isProfitable(const FlowPattern &FP) const {
TotalPh = computePhiCost(FP.JoinB, FP);
PredDefs += countPredicateDefs(FP.JoinB);
} else {
- if (FP.TrueB && FP.TrueB->succ_size() > 0) {
+ if (FP.TrueB && !FP.TrueB->succ_empty()) {
MachineBasicBlock *SB = *FP.TrueB->succ_begin();
TotalPh += computePhiCost(SB, FP);
PredDefs += countPredicateDefs(SB);
}
- if (FP.FalseB && FP.FalseB->succ_size() > 0) {
+ if (FP.FalseB && !FP.FalseB->succ_empty()) {
MachineBasicBlock *SB = *FP.FalseB->succ_begin();
TotalPh += computePhiCost(SB, FP);
PredDefs += countPredicateDefs(SB);
@@ -877,7 +877,7 @@ void HexagonEarlyIfConversion::convert(const FlowPattern &FP) {
// existing terminators/successors from the split block.
MachineBasicBlock *SSB = nullptr;
FP.SplitB->erase(OldTI, FP.SplitB->end());
- while (FP.SplitB->succ_size() > 0) {
+ while (!FP.SplitB->succ_empty()) {
MachineBasicBlock *T = *FP.SplitB->succ_begin();
// It's possible that the split block had a successor that is not a pre-
// dicated block. This could only happen if there was only one block to
@@ -970,7 +970,7 @@ void HexagonEarlyIfConversion::removeBlock(MachineBasicBlock *B) {
}
}
- while (B->succ_size() > 0)
+ while (!B->succ_empty())
B->removeSuccessor(B->succ_begin());
for (auto I = B->pred_begin(), E = B->pred_end(); I != E; ++I)
More information about the llvm-commits
mailing list