[llvm] 93b263a - [SimplifyCFG] Drop unused `LockstepReverseIterator` class (NFC)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 22 02:26:35 PST 2025
Author: Antonio Frighetto
Date: 2025-02-22T11:26:13+01:00
New Revision: 93b263a01cf898e609d3896edd0ce95789491bcd
URL: https://github.com/llvm/llvm-project/commit/93b263a01cf898e609d3896edd0ce95789491bcd
DIFF: https://github.com/llvm/llvm-project/commit/93b263a01cf898e609d3896edd0ce95789491bcd.diff
LOG: [SimplifyCFG] Drop unused `LockstepReverseIterator` class (NFC)
Unmaintained code has been removed.
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 44cefcd9745e6..21a267d41bd8e 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1774,77 +1774,6 @@ static bool isSafeCheapLoadStore(const Instruction *I,
getLoadStoreAlignment(I) < Value::MaximumAlignment;
}
-namespace {
-
-// LockstepReverseIterator - Iterates through instructions
-// in a set of blocks in reverse order from the first non-terminator.
-// For example (assume all blocks have size n):
-// LockstepReverseIterator I([B1, B2, B3]);
-// *I-- = [B1[n], B2[n], B3[n]];
-// *I-- = [B1[n-1], B2[n-1], B3[n-1]];
-// *I-- = [B1[n-2], B2[n-2], B3[n-2]];
-// ...
-class LockstepReverseIterator {
- ArrayRef<BasicBlock *> Blocks;
- SmallVector<Instruction *, 4> Insts;
- bool Fail;
-
-public:
- LockstepReverseIterator(ArrayRef<BasicBlock *> Blocks) : Blocks(Blocks) {
- reset();
- }
-
- void reset() {
- Fail = false;
- Insts.clear();
- for (auto *BB : Blocks) {
- Instruction *Inst = BB->getTerminator();
- for (Inst = Inst->getPrevNode(); Inst && isa<DbgInfoIntrinsic>(Inst);)
- Inst = Inst->getPrevNode();
- if (!Inst) {
- // Block wasn't big enough.
- Fail = true;
- return;
- }
- Insts.push_back(Inst);
- }
- }
-
- bool isValid() const { return !Fail; }
-
- void operator--() {
- if (Fail)
- return;
- for (auto *&Inst : Insts) {
- for (Inst = Inst->getPrevNode(); Inst && isa<DbgInfoIntrinsic>(Inst);)
- Inst = Inst->getPrevNode();
- // Already at beginning of block.
- if (!Inst) {
- Fail = true;
- return;
- }
- }
- }
-
- void operator++() {
- if (Fail)
- return;
- for (auto *&Inst : Insts) {
- for (Inst = Inst->getNextNode(); Inst && isa<DbgInfoIntrinsic>(Inst);)
- Inst = Inst->getNextNode();
- // Already at end of block.
- if (!Inst) {
- Fail = true;
- return;
- }
- }
- }
-
- ArrayRef<Instruction *> operator*() const { return Insts; }
-};
-
-} // end anonymous namespace
-
/// Hoist any common code in the successor blocks up into the block. This
/// function guarantees that BB dominates all successors. If AllInstsEqOnly is
/// given, only perform hoisting in case all successors blocks contain matching
@@ -1896,7 +1825,7 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
if (!AllSame)
return false;
if (AllSame) {
- LockstepReverseIterator LRI(Succs);
+ LockstepReverseIterator<true> LRI(Succs);
while (LRI.isValid()) {
Instruction *I0 = (*LRI)[0];
if (any_of(*LRI, [I0](Instruction *I) {
More information about the llvm-commits
mailing list