diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-09-04 13:43:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 13:43:41 -0700 |
commit | 63da545ccdd41d9eb2392a8d0e848a65eb24f5fa (patch) | |
tree | 5591043ef64f1ff1bc4df8255dbdac7171dd6a6b /llvm/lib/CodeGen/AtomicExpandPass.cpp | |
parent | 5e19fd172063c8957a35c7fa3596620f79ebba97 (diff) | |
download | llvm-63da545ccdd41d9eb2392a8d0e848a65eb24f5fa.zip llvm-63da545ccdd41d9eb2392a8d0e848a65eb24f5fa.tar.gz llvm-63da545ccdd41d9eb2392a8d0e848a65eb24f5fa.tar.bz2 |
Revert "Reland "AtomicExpand: Allow incrementally legalizing atomicrmw"" (#107307)
Reverts llvm/llvm-project#106793
`Next == E` is not enough:
https://lab.llvm.org/buildbot/#/builders/169/builds/2834
`Next` is deleted by `processAtomicInstr`
Diffstat (limited to 'llvm/lib/CodeGen/AtomicExpandPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AtomicExpandPass.cpp | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp index 2da723a0..39a7055 100644 --- a/llvm/lib/CodeGen/AtomicExpandPass.cpp +++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp @@ -351,30 +351,17 @@ bool AtomicExpandImpl::run(Function &F, const TargetMachine *TM) { bool MadeChange = false; - for (Function::iterator BBI = F.begin(), BBE = F.end(); BBI != BBE;) { - BasicBlock *BB = &*BBI; - ++BBI; - - BasicBlock::iterator Next; - - for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; - I = Next) { - Instruction &Inst = *I; - Next = std::next(I); - - if (processAtomicInstr(&Inst)) { - MadeChange = true; - - // Detect control flow change and resume iteration from the original - // block to inspect any newly inserted blocks. This allows incremental - // legalization of atomicrmw and cmpxchg. - if (Next == E || BB != Next->getParent()) { - BBI = BB->getIterator(); - BBE = F.end(); - break; - } - } - } + SmallVector<Instruction *, 1> AtomicInsts; + + // Changing control-flow while iterating through it is a bad idea, so gather a + // list of all atomic instructions before we start. + for (Instruction &I : instructions(F)) + if (I.isAtomic() && !isa<FenceInst>(&I)) + AtomicInsts.push_back(&I); + + for (auto *I : AtomicInsts) { + if (processAtomicInstr(I)) + MadeChange = true; } return MadeChange; |