[llvm] 72710af - [CodeGen, Target] Use MachineBasicBlock::terminators (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 31 07:57:53 PDT 2021
Author: Kazu Hirata
Date: 2021-10-31T07:57:34-07:00
New Revision: 72710af2334849dfaa9419b341617dd457292e7c
URL: https://github.com/llvm/llvm-project/commit/72710af2334849dfaa9419b341617dd457292e7c
DIFF: https://github.com/llvm/llvm-project/commit/72710af2334849dfaa9419b341617dd457292e7c.diff
LOG: [CodeGen, Target] Use MachineBasicBlock::terminators (NFC)
Added:
Modified:
llvm/lib/CodeGen/ModuloSchedule.cpp
llvm/lib/Target/AArch64/AArch64CondBrTuning.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
llvm/lib/Target/SystemZ/SystemZMachineScheduler.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/ModuloSchedule.cpp b/llvm/lib/CodeGen/ModuloSchedule.cpp
index fb133f7ca7181..120ecd7ae0595 100644
--- a/llvm/lib/CodeGen/ModuloSchedule.cpp
+++ b/llvm/lib/CodeGen/ModuloSchedule.cpp
@@ -141,13 +141,11 @@ void ModuloScheduleExpander::generatePipelinedLoop() {
// Copy any terminator instructions to the new kernel, and update
// names as needed.
- for (MachineBasicBlock::iterator I = BB->getFirstTerminator(),
- E = BB->instr_end();
- I != E; ++I) {
- MachineInstr *NewMI = MF.CloneMachineInstr(&*I);
+ for (MachineInstr &MI : BB->terminators()) {
+ MachineInstr *NewMI = MF.CloneMachineInstr(&MI);
updateInstruction(NewMI, false, MaxStageCount, 0, VRMap);
KernelBB->push_back(NewMI);
- InstrMap[NewMI] = &*I;
+ InstrMap[NewMI] = &MI;
}
NewKernel = KernelBB;
diff --git a/llvm/lib/Target/AArch64/AArch64CondBrTuning.cpp b/llvm/lib/Target/AArch64/AArch64CondBrTuning.cpp
index e90e8e3da0576..533ab3b05de93 100644
--- a/llvm/lib/Target/AArch64/AArch64CondBrTuning.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CondBrTuning.cpp
@@ -295,10 +295,7 @@ bool AArch64CondBrTuning::runOnMachineFunction(MachineFunction &MF) {
bool Changed = false;
for (MachineBasicBlock &MBB : MF) {
bool LocalChange = false;
- for (MachineBasicBlock::iterator I = MBB.getFirstTerminator(),
- E = MBB.end();
- I != E; ++I) {
- MachineInstr &MI = *I;
+ for (MachineInstr &MI : MBB.terminators()) {
switch (MI.getOpcode()) {
default:
break;
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index e83ecc30c4aef..1de2854dc2986 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -2464,19 +2464,15 @@ bool SIInstrInfo::analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
unsigned SIInstrInfo::removeBranch(MachineBasicBlock &MBB,
int *BytesRemoved) const {
- MachineBasicBlock::iterator I = MBB.getFirstTerminator();
-
unsigned Count = 0;
unsigned RemovedSize = 0;
- while (I != MBB.end()) {
- MachineBasicBlock::iterator Next = std::next(I);
+ for (MachineInstr &MI : llvm::make_early_inc_range(MBB.terminators())) {
// Skip over artificial terminators when removing instructions.
- if (I->isBranch() || I->isReturn()) {
- RemovedSize += getInstSizeInBytes(*I);
- I->eraseFromParent();
+ if (MI.isBranch() || MI.isReturn()) {
+ RemovedSize += getInstSizeInBytes(MI);
+ MI.eraseFromParent();
++Count;
}
- I = Next;
}
if (BytesRemoved)
diff --git a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
index 5b782543b3b4f..c824bac30833f 100644
--- a/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonFrameLowering.cpp
@@ -343,8 +343,8 @@ static bool hasTailCall(const MachineBasicBlock &MBB) {
/// Returns true if MBB contains an instruction that returns.
static bool hasReturn(const MachineBasicBlock &MBB) {
- for (auto I = MBB.getFirstTerminator(), E = MBB.end(); I != E; ++I)
- if (I->isReturn())
+ for (const MachineInstr &MI : MBB.terminators())
+ if (MI.isReturn())
return true;
return false;
}
diff --git a/llvm/lib/Target/SystemZ/SystemZMachineScheduler.cpp b/llvm/lib/Target/SystemZ/SystemZMachineScheduler.cpp
index 9bee5e8d18642..a6adaaa2dcefb 100644
--- a/llvm/lib/Target/SystemZ/SystemZMachineScheduler.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZMachineScheduler.cpp
@@ -106,13 +106,12 @@ void SystemZPostRASchedStrategy::enterMBB(MachineBasicBlock *NextMBB) {
// Emit incoming terminator(s). Be optimistic and assume that branch
// prediction will generally do "the right thing".
- for (MachineBasicBlock::iterator I = SinglePredMBB->getFirstTerminator();
- I != SinglePredMBB->end(); I++) {
- LLVM_DEBUG(dbgs() << "** Emitting incoming branch: "; I->dump(););
- bool TakenBranch = (I->isBranch() &&
- (TII->getBranchInfo(*I).isIndirect() ||
- TII->getBranchInfo(*I).getMBBTarget() == MBB));
- HazardRec->emitInstruction(&*I, TakenBranch);
+ for (MachineInstr &MI : SinglePredMBB->terminators()) {
+ LLVM_DEBUG(dbgs() << "** Emitting incoming branch: "; MI.dump(););
+ bool TakenBranch = (MI.isBranch() &&
+ (TII->getBranchInfo(MI).isIndirect() ||
+ TII->getBranchInfo(MI).getMBBTarget() == MBB));
+ HazardRec->emitInstruction(&MI, TakenBranch);
if (TakenBranch)
break;
}
More information about the llvm-commits
mailing list