aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2020-06-30 09:54:45 +0000
committerGuillaume Chatelet <gchatelet@google.com>2020-06-30 09:54:45 +0000
commit2c5ff48e61b5611dee5696c103e654c98d7e43f1 (patch)
treeae0a021b51d4e2bf66fc74795c295eaf10b5dec9 /llvm/lib/IR/Instructions.cpp
parent621f84567920bf5a8d79789f01a622115ec8252d (diff)
downloadllvm-2c5ff48e61b5611dee5696c103e654c98d7e43f1.zip
llvm-2c5ff48e61b5611dee5696c103e654c98d7e43f1.tar.gz
llvm-2c5ff48e61b5611dee5696c103e654c98d7e43f1.tar.bz2
[Alignment][NFC] Migrate AtomicExpandPass to Align
This is a followup on D78403. I'm unsure about `getAtomicOpAlign` overloads that take `AtomicRMWInst` and `AtomicCmpXchgInst`, shouldn't `getAlign` provide the correct answer already? Differential Revision: https://reviews.llvm.org/D81369
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 2087188..69a119b 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -1542,6 +1542,13 @@ AtomicCmpXchgInst::AtomicCmpXchgInst(Value *Ptr, Value *Cmp, Value *NewVal,
Init(Ptr, Cmp, NewVal, SuccessOrdering, FailureOrdering, SSID);
}
+Align AtomicCmpXchgInst::getAlign() const {
+ // The default here is to assume it has NATURAL alignment, not
+ // DataLayout-specified alignment.
+ const DataLayout &DL = getModule()->getDataLayout();
+ return Align(DL.getTypeStoreSize(getCompareOperand()->getType()));
+}
+
//===----------------------------------------------------------------------===//
// AtomicRMWInst Implementation
//===----------------------------------------------------------------------===//
@@ -1623,6 +1630,13 @@ StringRef AtomicRMWInst::getOperationName(BinOp Op) {
llvm_unreachable("invalid atomicrmw operation");
}
+Align AtomicRMWInst::getAlign() const {
+ // The default here is to assume it has NATURAL alignment, not
+ // DataLayout-specified alignment.
+ const DataLayout &DL = getModule()->getDataLayout();
+ return Align(DL.getTypeStoreSize(getValOperand()->getType()));
+}
+
//===----------------------------------------------------------------------===//
// FenceInst Implementation
//===----------------------------------------------------------------------===//