Skip to content

Commit f61b171

Browse files
!fixup address reviews
1 parent 585631e commit f61b171

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

llvm/include/llvm/Transforms/Utils/LockstepReverseIterator.h

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
namespace llvm {
1919

20-
struct NoActiveBlocksOption {
21-
template <typename... Args> NoActiveBlocksOption(Args...) {}
22-
};
20+
struct NoActiveBlocksOption {};
2321

2422
struct ActiveBlocksOption {
2523
protected:
@@ -46,28 +44,25 @@ class LockstepReverseIterator
4644
: public std::conditional_t<EarlyFailure, NoActiveBlocksOption,
4745
ActiveBlocksOption> {
4846
private:
49-
using BasicBlockT = BasicBlock;
50-
using InstructionT = Instruction;
51-
52-
ArrayRef<BasicBlockT *> Blocks;
53-
SmallVector<InstructionT *, 4> Insts;
47+
ArrayRef<BasicBlock *> Blocks;
48+
SmallVector<Instruction *, 4> Insts;
5449
bool Fail;
5550

5651
public:
57-
LockstepReverseIterator(ArrayRef<BasicBlockT *> Blocks) : Blocks(Blocks) {
52+
LockstepReverseIterator(ArrayRef<BasicBlock *> Blocks) : Blocks(Blocks) {
5853
reset();
5954
}
6055

6156
void reset() {
6257
Fail = false;
6358
if constexpr (!EarlyFailure) {
6459
this->ActiveBlocks.clear();
65-
for (BasicBlockT *BB : Blocks)
60+
for (BasicBlock *BB : Blocks)
6661
this->ActiveBlocks.insert(BB);
6762
}
6863
Insts.clear();
69-
for (BasicBlockT *BB : Blocks) {
70-
InstructionT *Prev = BB->getTerminator()->getPrevNonDebugInstruction();
64+
for (BasicBlock *BB : Blocks) {
65+
Instruction *Prev = BB->getTerminator()->getPrevNonDebugInstruction();
7166
if (!Prev) {
7267
// Block wasn't big enough - only contained a terminator.
7368
if constexpr (EarlyFailure) {
@@ -85,21 +80,21 @@ class LockstepReverseIterator
8580
}
8681

8782
bool isValid() const { return !Fail; }
88-
ArrayRef<InstructionT *> operator*() const { return Insts; }
83+
ArrayRef<Instruction *> operator*() const { return Insts; }
8984

9085
// Note: This needs to return a SmallSetVector as the elements of
9186
// ActiveBlocks will be later copied to Blocks using std::copy. The
9287
// resultant order of elements in Blocks needs to be deterministic.
9388
// Using SmallPtrSet instead causes non-deterministic order while
9489
// copying. And we cannot simply sort Blocks as they need to match the
9590
// corresponding Values.
96-
template <bool C = EarlyFailure, std::enable_if_t<!C, int> = 0>
97-
SmallSetVector<BasicBlockT *, 4> &getActiveBlocks() {
91+
SmallSetVector<BasicBlock *, 4> &getActiveBlocks() {
92+
static_assert(!EarlyFailure, "Unknown method");
9893
return this->ActiveBlocks;
9994
}
10095

101-
template <bool C = EarlyFailure, std::enable_if_t<!C, int> = 0>
102-
void restrictToBlocks(SmallSetVector<BasicBlockT *, 4> &Blocks) {
96+
void restrictToBlocks(SmallSetVector<BasicBlock *, 4> &Blocks) {
97+
static_assert(!EarlyFailure, "Unknown method");
10398
for (auto It = Insts.begin(); It != Insts.end();) {
10499
if (!Blocks.contains((*It)->getParent())) {
105100
this->ActiveBlocks.remove((*It)->getParent());
@@ -113,9 +108,9 @@ class LockstepReverseIterator
113108
void operator--() {
114109
if (Fail)
115110
return;
116-
SmallVector<InstructionT *, 4> NewInsts;
117-
for (InstructionT *Inst : Insts) {
118-
InstructionT *Prev = Inst->getPrevNonDebugInstruction();
111+
SmallVector<Instruction *, 4> NewInsts;
112+
for (Instruction *Inst : Insts) {
113+
Instruction *Prev = Inst->getPrevNonDebugInstruction();
119114
if (!Prev) {
120115
if constexpr (!EarlyFailure) {
121116
this->ActiveBlocks.remove(Inst->getParent());
@@ -137,9 +132,9 @@ class LockstepReverseIterator
137132
void operator++() {
138133
if (Fail)
139134
return;
140-
SmallVector<InstructionT *, 4> NewInsts;
141-
for (InstructionT *Inst : Insts) {
142-
InstructionT *Next = Inst->getNextNonDebugInstruction();
135+
SmallVector<Instruction *, 4> NewInsts;
136+
for (Instruction *Inst : Insts) {
137+
Instruction *Next = Inst->getNextNonDebugInstruction();
143138
// Already at end of block.
144139
if (!Next) {
145140
Fail = true;

0 commit comments

Comments
 (0)