Skip to content

Commit 559c11c

Browse files
committed
AMDGPU: Query MachineModuleInfo from PM instead of MachineFunction
1 parent 0f0cfcf commit 559c11c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class SIMemOpInfo final {
217217

218218
class SIMemOpAccess final {
219219
private:
220-
AMDGPUMachineModuleInfo *MMI = nullptr;
220+
const AMDGPUMachineModuleInfo *MMI = nullptr;
221221

222222
/// Reports unsupported message \p Msg for \p MI to LLVM context.
223223
void reportUnsupported(const MachineBasicBlock::iterator &MI,
@@ -241,7 +241,7 @@ class SIMemOpAccess final {
241241
public:
242242
/// Construct class to support accessing the machine memory operands
243243
/// of instructions in the machine function \p MF.
244-
SIMemOpAccess(MachineFunction &MF);
244+
SIMemOpAccess(const AMDGPUMachineModuleInfo &MMI);
245245

246246
/// \returns Load info if \p MI is a load operation, "std::nullopt" otherwise.
247247
std::optional<SIMemOpInfo>
@@ -694,6 +694,8 @@ class SIMemoryLegalizer final : public MachineFunctionPass {
694694
SIMemoryLegalizer() : MachineFunctionPass(ID) {}
695695

696696
void getAnalysisUsage(AnalysisUsage &AU) const override {
697+
AU.addRequired<MachineModuleInfoWrapperPass>();
698+
AU.addPreserved<MachineModuleInfoWrapperPass>();
697699
AU.setPreservesCFG();
698700
MachineFunctionPass::getAnalysisUsage(AU);
699701
}
@@ -806,9 +808,8 @@ SIAtomicAddrSpace SIMemOpAccess::toSIAtomicAddrSpace(unsigned AS) const {
806808
return SIAtomicAddrSpace::OTHER;
807809
}
808810

809-
SIMemOpAccess::SIMemOpAccess(MachineFunction &MF) {
810-
MMI = &MF.getMMI().getObjFileInfo<AMDGPUMachineModuleInfo>();
811-
}
811+
SIMemOpAccess::SIMemOpAccess(const AMDGPUMachineModuleInfo &MMI_)
812+
: MMI(&MMI_) {}
812813

813814
std::optional<SIMemOpInfo> SIMemOpAccess::constructFromMIWithMMO(
814815
const MachineBasicBlock::iterator &MI) const {
@@ -2802,7 +2803,10 @@ bool SIMemoryLegalizer::expandAtomicCmpxchgOrRmw(const SIMemOpInfo &MOI,
28022803
bool SIMemoryLegalizer::runOnMachineFunction(MachineFunction &MF) {
28032804
bool Changed = false;
28042805

2805-
SIMemOpAccess MOA(MF);
2806+
const MachineModuleInfo &MMI =
2807+
getAnalysis<MachineModuleInfoWrapperPass>().getMMI();
2808+
2809+
SIMemOpAccess MOA(MMI.getObjFileInfo<AMDGPUMachineModuleInfo>());
28062810
CC = SICacheControl::create(MF.getSubtarget<GCNSubtarget>());
28072811

28082812
for (auto &MBB : MF) {

0 commit comments

Comments
 (0)