Skip to content

Commit a98662f

Browse files
committed
[Alignment][NFC] Update MachineMemOperand implementation to use MaybeAlign
Summary: This is patch is part of a series to introduce an Alignment type. See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html See this patch for the introduction of the type: https://reviews.llvm.org/D64790 Reviewers: courbet Reviewed By: courbet Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76625
1 parent 6728a9a commit a98662f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/include/llvm/CodeGen/MachineMemOperand.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class MachineMemOperand {
169169
MachinePointerInfo PtrInfo;
170170
uint64_t Size;
171171
Flags FlagVals;
172-
uint16_t BaseAlignLog2; // log_2(base_alignment) + 1
172+
Align BaseAlign;
173173
MachineAtomicInfo AtomicInfo;
174174
AAMDNodes AAInfo;
175175
const MDNode *Ranges;
@@ -229,7 +229,7 @@ class MachineMemOperand {
229229

230230
/// Return the minimum known alignment in bytes of the base address, without
231231
/// the offset.
232-
uint64_t getBaseAlignment() const { return (1ull << BaseAlignLog2) >> 1; }
232+
uint64_t getBaseAlignment() const { return BaseAlign.value(); }
233233

234234
/// Return the AA tags for the memory reference.
235235
AAMDNodes getAAInfo() const { return AAInfo; }

llvm/lib/CodeGen/MachineOperand.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,8 +1009,8 @@ MachineMemOperand::MachineMemOperand(MachinePointerInfo ptrinfo, Flags f,
10091009
const MDNode *Ranges, SyncScope::ID SSID,
10101010
AtomicOrdering Ordering,
10111011
AtomicOrdering FailureOrdering)
1012-
: PtrInfo(ptrinfo), Size(s), FlagVals(f), BaseAlignLog2(Log2_32(a) + 1),
1013-
AAInfo(AAInfo), Ranges(Ranges) {
1012+
: PtrInfo(ptrinfo), Size(s), FlagVals(f), BaseAlign(a), AAInfo(AAInfo),
1013+
Ranges(Ranges) {
10141014
assert((PtrInfo.V.isNull() || PtrInfo.V.is<const PseudoSourceValue *>() ||
10151015
isa<PointerType>(PtrInfo.V.get<const Value *>()->getType())) &&
10161016
"invalid pointer value");
@@ -1043,7 +1043,7 @@ void MachineMemOperand::refineAlignment(const MachineMemOperand *MMO) {
10431043

10441044
if (MMO->getBaseAlignment() >= getBaseAlignment()) {
10451045
// Update the alignment value.
1046-
BaseAlignLog2 = Log2_32(MMO->getBaseAlignment()) + 1;
1046+
BaseAlign = Align(MMO->getBaseAlignment());
10471047
// Also update the base and offset, because the new alignment may
10481048
// not be applicable with the old ones.
10491049
PtrInfo = MMO->PtrInfo;

0 commit comments

Comments
 (0)