[PATCH] D57122: Add copyWithSizeAndOffset to MMOs for splitting
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 23 22:01:36 PST 2019
arsenm updated this revision to Diff 183249.
arsenm marked an inline comment as done.
arsenm added a comment.
It turns out this already exists, just in MachineFunction. It does require fixing a bug in how alignment is handled when there's no base value
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57122/new/
https://reviews.llvm.org/D57122
Files:
lib/CodeGen/GlobalISel/LegalizerHelper.cpp
lib/CodeGen/MachineFunction.cpp
Index: lib/CodeGen/MachineFunction.cpp
===================================================================
--- lib/CodeGen/MachineFunction.cpp
+++ lib/CodeGen/MachineFunction.cpp
@@ -395,19 +395,18 @@
MachineMemOperand *
MachineFunction::getMachineMemOperand(const MachineMemOperand *MMO,
int64_t Offset, uint64_t Size) {
- if (MMO->getValue())
- return new (Allocator)
- MachineMemOperand(MachinePointerInfo(MMO->getValue(),
- MMO->getOffset()+Offset),
- MMO->getFlags(), Size, MMO->getBaseAlignment(),
- AAMDNodes(), nullptr, MMO->getSyncScopeID(),
- MMO->getOrdering(), MMO->getFailureOrdering());
+ const MachinePointerInfo &PtrInfo = MMO->getPointerInfo();
+
+ // If there is no pointer value, the offset isn't tracked so we need to adjust
+ // the base alignment.
+ unsigned Align = PtrInfo.V.isNull()
+ ? MinAlign(MMO->getBaseAlignment(), Offset)
+ : MMO->getBaseAlignment();
+
return new (Allocator)
- MachineMemOperand(MachinePointerInfo(MMO->getPseudoValue(),
- MMO->getOffset()+Offset),
- MMO->getFlags(), Size, MMO->getBaseAlignment(),
- AAMDNodes(), nullptr, MMO->getSyncScopeID(),
- MMO->getOrdering(), MMO->getFailureOrdering());
+ MachineMemOperand(PtrInfo.getWithOffset(Offset), MMO->getFlags(), Size,
+ Align, AAMDNodes(), nullptr, MMO->getSyncScopeID(),
+ MMO->getOrdering(), MMO->getFailureOrdering());
}
MachineMemOperand *
Index: lib/CodeGen/GlobalISel/LegalizerHelper.cpp
===================================================================
--- lib/CodeGen/GlobalISel/LegalizerHelper.cpp
+++ lib/CodeGen/GlobalISel/LegalizerHelper.cpp
@@ -489,20 +489,18 @@
LLT OffsetTy = LLT::scalar(
MRI.getType(MI.getOperand(1).getReg()).getScalarSizeInBits());
+ MachineFunction &MF = MIRBuilder.getMF();
SmallVector<unsigned, 2> DstRegs;
for (int i = 0; i < NumParts; ++i) {
unsigned DstReg = MRI.createGenericVirtualRegister(NarrowTy);
unsigned SrcReg = 0;
- unsigned Adjustment = i * NarrowSize / 8;
- unsigned Alignment = MinAlign(MMO.getAlignment(), Adjustment);
+ unsigned Offset = i * NarrowSize / 8;
- MachineMemOperand *SplitMMO = MIRBuilder.getMF().getMachineMemOperand(
- MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
- NarrowSize / 8, Alignment, MMO.getAAInfo(), MMO.getRanges(),
- MMO.getSyncScopeID(), MMO.getOrdering(), MMO.getFailureOrdering());
+ MachineMemOperand *SplitMMO =
+ MF.getMachineMemOperand(&MMO, Offset, NarrowSize / 8);
MIRBuilder.materializeGEP(SrcReg, MI.getOperand(1).getReg(), OffsetTy,
- Adjustment);
+ Offset);
MIRBuilder.buildLoad(DstReg, SrcReg, *SplitMMO);
@@ -563,18 +561,16 @@
SmallVector<unsigned, 2> SrcRegs;
extractParts(MI.getOperand(0).getReg(), NarrowTy, NumParts, SrcRegs);
+ MachineFunction &MF = MIRBuilder.getMF();
for (int i = 0; i < NumParts; ++i) {
unsigned DstReg = 0;
- unsigned Adjustment = i * NarrowSize / 8;
- unsigned Alignment = MinAlign(MMO.getAlignment(), Adjustment);
+ unsigned Offset = i * NarrowSize / 8;
- MachineMemOperand *SplitMMO = MIRBuilder.getMF().getMachineMemOperand(
- MMO.getPointerInfo().getWithOffset(Adjustment), MMO.getFlags(),
- NarrowSize / 8, Alignment, MMO.getAAInfo(), MMO.getRanges(),
- MMO.getSyncScopeID(), MMO.getOrdering(), MMO.getFailureOrdering());
+ MachineMemOperand *SplitMMO =
+ MF.getMachineMemOperand(&MMO, Offset, NarrowSize / 8);
MIRBuilder.materializeGEP(DstReg, MI.getOperand(1).getReg(), OffsetTy,
- Adjustment);
+ Offset);
MIRBuilder.buildStore(SrcRegs[i], DstReg, *SplitMMO);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57122.183249.patch
Type: text/x-patch
Size: 4241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190124/9970e89c/attachment.bin>
More information about the llvm-commits
mailing list