[PATCH] D130457: [IRBuilder] Add assert in CreateAtomicRMW
Alexander Shaposhnikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 24 21:58:46 PDT 2022
alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: efriedma, dmgreen.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added a subscriber: hiraditya.
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: LLVM.
Add assert in CreateAtomicRMW: Ordering != AtomicOrdering::Unordered
(https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/Verifier.cpp#L3944)
and adjust expandAtomicStore accordingly.
Test plan:
ninja check-all
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D130457
Files:
llvm/include/llvm/IR/IRBuilder.h
llvm/lib/CodeGen/AtomicExpandPass.cpp
Index: llvm/lib/CodeGen/AtomicExpandPass.cpp
===================================================================
--- llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -515,9 +515,14 @@
// It is the responsibility of the target to only signal expansion via
// shouldExpandAtomicRMW in cases where this is required and possible.
IRBuilder<> Builder(SI);
+ AtomicOrdering Ordering = SI->getOrdering();
+ assert(Ordering != AtomicOrdering::NotAtomic);
+ AtomicOrdering RMWOrdering = Ordering == AtomicOrdering::Unordered
+ ? AtomicOrdering::Monotonic
+ : Ordering;
AtomicRMWInst *AI = Builder.CreateAtomicRMW(
AtomicRMWInst::Xchg, SI->getPointerOperand(), SI->getValueOperand(),
- SI->getAlign(), SI->getOrdering());
+ SI->getAlign(), RMWOrdering);
SI->eraseFromParent();
// Now we have an appropriate swap instruction, lower it as usual.
Index: llvm/include/llvm/IR/IRBuilder.h
===================================================================
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -1714,6 +1714,8 @@
Value *Val, MaybeAlign Align,
AtomicOrdering Ordering,
SyncScope::ID SSID = SyncScope::System) {
+ assert(Ordering != AtomicOrdering::Unordered &&
+ "atomicrmw instructions cannot be unordered");
if (!Align) {
const DataLayout &DL = BB->getModule()->getDataLayout();
Align = llvm::Align(DL.getTypeStoreSize(Val->getType()));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130457.447187.patch
Type: text/x-patch
Size: 1639 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220725/757d9287/attachment.bin>
More information about the llvm-commits
mailing list