Skip to content

Revert "AtomicExpand: Allow incrementally legalizing atomicrmw" #106792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions llvm/lib/CodeGen/AtomicExpandPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// legalizaton of atomicrmw and cmpxchg.
if (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;
Expand Down
Loading
Loading