[llvm] [CodeGen] MachineModuleInfo: Take Target as a reference (NFC) (PR #132357)
Akshat Oke via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 21 02:06:49 PDT 2025
https://github.com/optimisan created https://github.com/llvm/llvm-project/pull/132357
None
>From f42935626f519bf386437e7e02f1db8db8549654 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Fri, 21 Mar 2025 09:06:02 +0000
Subject: [PATCH] [CodeGen] MachineModuleInfo: Take Target as a reference (NFC)
---
llvm/include/llvm/CodeGen/MachineModuleInfo.h | 4 ++--
llvm/lib/CodeGen/MachineModuleInfo.cpp | 24 +++++++++----------
llvm/tools/llc/NewPMDriver.cpp | 2 +-
3 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/MachineModuleInfo.h b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
index bec500dc609f3..2e813667d0bee 100644
--- a/llvm/include/llvm/CodeGen/MachineModuleInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineModuleInfo.h
@@ -109,9 +109,9 @@ class MachineModuleInfo {
MachineModuleInfo &operator=(MachineModuleInfo &&MMII) = delete;
public:
- explicit MachineModuleInfo(const TargetMachine *TM = nullptr);
+ explicit MachineModuleInfo(const TargetMachine &TM);
- explicit MachineModuleInfo(const TargetMachine *TM, MCContext *ExtContext);
+ explicit MachineModuleInfo(const TargetMachine &TM, MCContext *ExtContext);
MachineModuleInfo(MachineModuleInfo &&MMII);
diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp
index 6167e99aecf03..943ecc94b4bc2 100644
--- a/llvm/lib/CodeGen/MachineModuleInfo.cpp
+++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp
@@ -48,21 +48,21 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)
TheModule = MMI.TheModule;
}
-MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM)
- : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),
- TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
- nullptr, &TM->Options.MCOptions, false) {
- Context.setObjectFileInfo(TM->getObjFileLowering());
+MachineModuleInfo::MachineModuleInfo(const TargetMachine &TM)
+ : TM(TM),
+ Context(TM.getTargetTriple(), TM.getMCAsmInfo(), TM.getMCRegisterInfo(),
+ TM.getMCSubtargetInfo(), nullptr, &TM.Options.MCOptions, false) {
+ Context.setObjectFileInfo(TM.getObjFileLowering());
initialize();
}
-MachineModuleInfo::MachineModuleInfo(const TargetMachine *TM,
+MachineModuleInfo::MachineModuleInfo(const TargetMachine &TM,
MCContext *ExtContext)
- : TM(*TM), Context(TM->getTargetTriple(), TM->getMCAsmInfo(),
- TM->getMCRegisterInfo(), TM->getMCSubtargetInfo(),
- nullptr, &TM->Options.MCOptions, false),
+ : TM(TM),
+ Context(TM.getTargetTriple(), TM.getMCAsmInfo(), TM.getMCRegisterInfo(),
+ TM.getMCSubtargetInfo(), nullptr, &TM.Options.MCOptions, false),
ExternalContext(ExtContext) {
- Context.setObjectFileInfo(TM->getObjFileLowering());
+ Context.setObjectFileInfo(TM.getObjFileLowering());
initialize();
}
@@ -152,13 +152,13 @@ FunctionPass *llvm::createFreeMachineFunctionPass() {
MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(
const TargetMachine *TM)
- : ImmutablePass(ID), MMI(TM) {
+ : ImmutablePass(ID), MMI(*TM) {
initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry());
}
MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(
const TargetMachine *TM, MCContext *ExtContext)
- : ImmutablePass(ID), MMI(TM, ExtContext) {
+ : ImmutablePass(ID), MMI(*TM, ExtContext) {
initializeMachineModuleInfoWrapperPassPass(*PassRegistry::getPassRegistry());
}
diff --git a/llvm/tools/llc/NewPMDriver.cpp b/llvm/tools/llc/NewPMDriver.cpp
index fa82689ecf9ae..9343ffc44dd02 100644
--- a/llvm/tools/llc/NewPMDriver.cpp
+++ b/llvm/tools/llc/NewPMDriver.cpp
@@ -107,7 +107,7 @@ int llvm::compileModuleWithNewPM(
Opt.DebugPM = DebugPM;
Opt.RegAlloc = RegAlloc;
- MachineModuleInfo MMI(Target.get());
+ MachineModuleInfo MMI(*Target);
PassInstrumentationCallbacks PIC;
StandardInstrumentations SI(Context, Opt.DebugPM,
More information about the llvm-commits
mailing list