[PATCH] [AtomicExpand] Fix a crash bug when lowering unordered loads to cmpxchg
authorPhilip Reames <listmail@philipreames.com>
Tue, 19 Mar 2019 17:20:49 +0000 (17:20 +0000)
committerEmilio Pozuelo Monfort <pochu@debian.org>
Fri, 18 Sep 2020 09:47:25 +0000 (10:47 +0100)
Add tests for wider atomic loads and stores.  In the process, fix a crasher where we appearently handled unorder stores, but not loads, when lowering to cmpxchg idioms.

llvm-svn: 356482

Gbp-Pq: Name AtomicExpand-Fix-a-crash-bug-when-lowering-unordered-loads.patch

lib/CodeGen/AtomicExpandPass.cpp

index e28fc6fb9d4fb60dc47675b1989a9354e2b52914..b58490f1ef5955ed87eec60353cb122ab2264540 100644 (file)
@@ -423,6 +423,9 @@ bool AtomicExpand::expandAtomicLoadToLL(LoadInst *LI) {
 bool AtomicExpand::expandAtomicLoadToCmpXchg(LoadInst *LI) {
   IRBuilder<> Builder(LI);
   AtomicOrdering Order = LI->getOrdering();
+  if (Order == AtomicOrdering::Unordered)
+    Order = AtomicOrdering::Monotonic;
+
   Value *Addr = LI->getPointerOperand();
   Type *Ty = cast<PointerType>(Addr->getType())->getElementType();
   Constant *DummyVal = Constant::getNullValue(Ty);