diff options
author | Antonio Frighetto <me@antoniofrighetto.com> | 2025-02-22 11:11:52 +0100 |
---|---|---|
committer | Antonio Frighetto <me@antoniofrighetto.com> | 2025-02-22 11:21:36 +0100 |
commit | 48a6df36040d59a4807b0fa9ac46c343900e5225 (patch) | |
tree | 30347ceecfc9668b0a2a1bce10d1084300d20c04 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | b09dfbd6995bf83ce9546807ccc285c6d957f6db (diff) | |
download | llvm-48a6df36040d59a4807b0fa9ac46c343900e5225.zip llvm-48a6df36040d59a4807b0fa9ac46c343900e5225.tar.gz llvm-48a6df36040d59a4807b0fa9ac46c343900e5225.tar.bz2 |
Reapply "[Utils] Consolidate `LockstepReverseIterator` into own header (NFC)"
Common code has been unified and generalized.
Original commit: 123dca9b56e1359d8ec7771ea3bd0afd4b1ea6af
Previously reverted due to accidentally merged incompletely. The issue has
been addressed by restoring missing code.
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 27b7ec4..44cefcd 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -74,6 +74,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" +#include "llvm/Transforms/Utils/LockstepReverseIterator.h" #include "llvm/Transforms/Utils/ValueMapper.h" #include <algorithm> #include <cassert> @@ -2499,7 +2500,7 @@ static bool sinkCommonCodeFromPredecessors(BasicBlock *BB, int ScanIdx = 0; SmallPtrSet<Value*,4> InstructionsToSink; - LockstepReverseIterator LRI(UnconditionalPreds); + LockstepReverseIterator<true> LRI(UnconditionalPreds); while (LRI.isValid() && canSinkInstructions(*LRI, PHIOperands)) { LLVM_DEBUG(dbgs() << "SINK: instruction can be sunk: " << *(*LRI)[0] @@ -2529,7 +2530,7 @@ static bool sinkCommonCodeFromPredecessors(BasicBlock *BB, // Okay, we *could* sink last ScanIdx instructions. But how many can we // actually sink before encountering instruction that is unprofitable to // sink? - auto ProfitableToSinkInstruction = [&](LockstepReverseIterator &LRI) { + auto ProfitableToSinkInstruction = [&](LockstepReverseIterator<true> &LRI) { unsigned NumPHIInsts = 0; for (Use &U : (*LRI)[0]->operands()) { auto It = PHIOperands.find(&U); |