Skip to content

Commit 63da545

Browse files
authored
Revert "Reland "AtomicExpand: Allow incrementally legalizing atomicrmw"" (#107307)
Reverts #106793 `Next == E` is not enough: https://lab.llvm.org/buildbot/#/builders/169/builds/2834 `Next` is deleted by `processAtomicInstr`
1 parent 5e19fd1 commit 63da545

File tree

5 files changed

+691
-836
lines changed

5 files changed

+691
-836
lines changed

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -351,30 +351,17 @@ bool AtomicExpandImpl::run(Function &F, const TargetMachine *TM) {
351351

352352
bool MadeChange = false;
353353

354-
for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE;) {
355-
BasicBlock *BB = &*BBI;
356-
++BBI;
357-
358-
BasicBlock::iterator Next;
359-
360-
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;
361-
I = Next) {
362-
Instruction &Inst = *I;
363-
Next = std::next(I);
364-
365-
if (processAtomicInstr(&Inst)) {
366-
MadeChange = true;
367-
368-
// Detect control flow change and resume iteration from the original
369-
// block to inspect any newly inserted blocks. This allows incremental
370-
// legalization of atomicrmw and cmpxchg.
371-
if (Next == E || BB != Next->getParent()) {
372-
BBI = BB->getIterator();
373-
BBE = F.end();
374-
break;
375-
}
376-
}
377-
}
354+
SmallVector<Instruction *, 1> AtomicInsts;
355+
356+
// Changing control-flow while iterating through it is a bad idea, so gather a
357+
// list of all atomic instructions before we start.
358+
for (Instruction &I : instructions(F))
359+
if (I.isAtomic() && !isa<FenceInst>(&I))
360+
AtomicInsts.push_back(&I);
361+
362+
for (auto *I : AtomicInsts) {
363+
if (processAtomicInstr(I))
364+
MadeChange = true;
378365
}
379366

380367
return MadeChange;

0 commit comments

Comments
 (0)