[llvm] 6de6455 - Use getAlign() on atomicrmw/cmpxchg instructions, now that it's available.
James Y Knight via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 26 12:07:24 PST 2021
Author: James Y Knight
Date: 2021-02-26T15:06:15-05:00
New Revision: 6de6455752c139bd3f13443be6a5046e9199f037
URL: https://github.com/llvm/llvm-project/commit/6de6455752c139bd3f13443be6a5046e9199f037
DIFF: https://github.com/llvm/llvm-project/commit/6de6455752c139bd3f13443be6a5046e9199f037.diff
LOG: Use getAlign() on atomicrmw/cmpxchg instructions, now that it's available.
These locations were missed as part of adding alignment to the
instructions, and were still making their own alignment assumptions.
Added:
Modified:
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index b7883cbc3120..86247a41bded 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -253,23 +253,13 @@ int IRTranslator::getOrCreateFrameIndex(const AllocaInst &AI) {
Align IRTranslator::getMemOpAlign(const Instruction &I) {
if (const StoreInst *SI = dyn_cast<StoreInst>(&I))
return SI->getAlign();
- if (const LoadInst *LI = dyn_cast<LoadInst>(&I)) {
+ if (const LoadInst *LI = dyn_cast<LoadInst>(&I))
return LI->getAlign();
- }
- if (const AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&I)) {
- // TODO(PR27168): This instruction has no alignment attribute, but unlike
- // the default alignment for load/store, the default here is to assume
- // it has NATURAL alignment, not DataLayout-specified alignment.
- const DataLayout &DL = AI->getModule()->getDataLayout();
- return Align(DL.getTypeStoreSize(AI->getCompareOperand()->getType()));
- }
- if (const AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(&I)) {
- // TODO(PR27168): This instruction has no alignment attribute, but unlike
- // the default alignment for load/store, the default here is to assume
- // it has NATURAL alignment, not DataLayout-specified alignment.
- const DataLayout &DL = AI->getModule()->getDataLayout();
- return Align(DL.getTypeStoreSize(AI->getValOperand()->getType()));
- }
+ if (const AtomicCmpXchgInst *AI = dyn_cast<AtomicCmpXchgInst>(&I))
+ return AI->getAlign();
+ if (const AtomicRMWInst *AI = dyn_cast<AtomicRMWInst>(&I))
+ return AI->getAlign();
+
OptimizationRemarkMissed R("gisel-irtranslator", "", &I);
R << "unable to translate memop: " << ore::NV("Opcode", &I);
reportTranslationError(*MF, *TPC, *ORE, R);
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index dd0ce226050e..876c01f5daf5 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -28770,9 +28770,8 @@ X86TargetLowering::lowerIdempotentRMWIntoFencedLoad(AtomicRMWInst *AI) const {
Builder.CreateCall(MFence, {});
// Finally we can emit the atomic load.
- LoadInst *Loaded =
- Builder.CreateAlignedLoad(AI->getType(), AI->getPointerOperand(),
- Align(AI->getType()->getPrimitiveSizeInBits()));
+ LoadInst *Loaded = Builder.CreateAlignedLoad(
+ AI->getType(), AI->getPointerOperand(), AI->getAlign());
Loaded->setAtomic(Order, SSID);
AI->replaceAllUsesWith(Loaded);
AI->eraseFromParent();
More information about the llvm-commits
mailing list