Skip to content

Commit 7b28cc0

Browse files
authored
AMDGPU: Query MachineModuleInfo from PM instead of MachineFunction (#99679)
1 parent 57ccd42 commit 7b28cc0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

llvm/lib/Target/AMDGPU/SIMemoryLegalizer.cpp

Lines changed: 8 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>
@@ -806,9 +806,8 @@ SIAtomicAddrSpace SIMemOpAccess::toSIAtomicAddrSpace(unsigned AS) const {
806806
return SIAtomicAddrSpace::OTHER;
807807
}
808808

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

813812
std::optional<SIMemOpInfo> SIMemOpAccess::constructFromMIWithMMO(
814813
const MachineBasicBlock::iterator &MI) const {
@@ -2802,7 +2801,10 @@ bool SIMemoryLegalizer::expandAtomicCmpxchgOrRmw(const SIMemOpInfo &MOI,
28022801
bool SIMemoryLegalizer::runOnMachineFunction(MachineFunction &MF) {
28032802
bool Changed = false;
28042803

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

28082810
for (auto &MBB : MF) {

0 commit comments

Comments
 (0)