[clang] [flang] [llvm] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 29 16:49:20 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 76f2fa8163e406914996b7c3bce127ee585fd3f7 737685e4e09c3be8a56566e436a7ae28771e2dcc --extensions cpp,h -- clang/lib/CodeGen/BackendUtil.cpp clang/lib/Interpreter/DeviceOffload.cpp clang/lib/Interpreter/Wasm.cpp clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp flang/lib/Frontend/FrontendActions.cpp llvm/include/llvm/CodeGen/MachineModuleInfo.h llvm/include/llvm/Target/TargetMachine.h llvm/lib/CodeGen/LLVMTargetMachine.cpp llvm/lib/CodeGen/MachineModuleInfo.cpp llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp llvm/lib/ExecutionEngine/Orc/CompileUtils.cpp llvm/lib/LTO/LTOBackend.cpp llvm/lib/LTO/ThinLTOCodeGenerator.cpp llvm/lib/Target/NVPTX/NVPTXTargetMachine.h llvm/lib/Target/TargetMachineC.cpp llvm/tools/llc/llc.cpp llvm/tools/llvm-exegesis/lib/Assembler.cpp llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp llvm/unittests/CodeGen/AMDGPUMetadataTest.cpp llvm/unittests/CodeGen/AsmPrinterDwarfTest.cpp llvm/unittests/MI/LiveIntervalTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 78b7fcedcd..399920f9d3 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -158,7 +158,7 @@ std::unique_ptr<MemoryBuffer> MCJIT::emitObject(Module *M) {
   // generateCodeForModule.
 
   legacy::PassManager PM;
-  auto * LLVMTM = static_cast<LLVMTargetMachine*>(TM.get());
+  auto *LLVMTM = static_cast<LLVMTargetMachine *>(TM.get());
   MachineModuleInfo MMI(LLVMTM);
   Ctx = &MMI.getContext();
 
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index 15b5daea7f..85bba51788 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -418,7 +418,7 @@ static void codegen(const Config &Conf, TargetMachine *TM,
   TM->Options.ObjectFilenameForDebug = Stream->ObjectPathName;
 
   legacy::PassManager CodeGenPasses;
-  MachineModuleInfo MMI(static_cast<LLVMTargetMachine*>(TM));
+  MachineModuleInfo MMI(static_cast<LLVMTargetMachine *>(TM));
   TargetLibraryInfoImpl TLII(Triple(Mod.getTargetTriple()));
   CodeGenPasses.add(new TargetLibraryInfoWrapperPass(TLII));
   CodeGenPasses.add(
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 4b522a4f3c..fdc9794064 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -334,7 +334,7 @@ std::unique_ptr<MemoryBuffer> codegenModule(Module &TheModule,
   {
     raw_svector_ostream OS(OutputBuffer);
     legacy::PassManager PM;
-    MachineModuleInfo MMI(static_cast<LLVMTargetMachine*>(&TM));
+    MachineModuleInfo MMI(static_cast<LLVMTargetMachine *>(&TM));
 
     // Setup the codegen now.
     if (TM.addPassesToEmitFile(PM, MMI, OS, nullptr,
diff --git a/llvm/lib/Target/TargetMachineC.cpp b/llvm/lib/Target/TargetMachineC.cpp
index 5a2918827a..bae4f3e1da 100644
--- a/llvm/lib/Target/TargetMachineC.cpp
+++ b/llvm/lib/Target/TargetMachineC.cpp
@@ -296,7 +296,7 @@ static LLVMBool LLVMTargetMachineEmit(LLVMTargetMachineRef T, LLVMModuleRef M,
   Module* Mod = unwrap(M);
 
   legacy::PassManager pass;
-  MachineModuleInfo MMI(static_cast<LLVMTargetMachine*>(TM));
+  MachineModuleInfo MMI(static_cast<LLVMTargetMachine *>(TM));
 
   std::string error;
 
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 21c492c87e..758a6dad0f 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -692,8 +692,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
     // Construct a custom pass pipeline that starts after instruction
     // selection.
     if (!getRunPassNames().empty()) {
-      auto *MMIWP =
-          new MachineModuleInfoWrapperPass(MMI);
+      auto *MMIWP = new MachineModuleInfoWrapperPass(MMI);
       if (!MIR) {
         WithColor::warning(errs(), argv[0])
             << "run-pass is for .mir file only.\n";
@@ -722,9 +721,9 @@ static int compileModule(char **argv, LLVMContext &Context) {
       TPC.setInitialized();
       PM.add(createPrintMIRPass(*OS));
       PM.add(createFreeMachineFunctionPass());
-    } else if (Target->addPassesToEmitFile(
-                   PM, MMI, *OS, DwoOut ? &DwoOut->os() : nullptr,
-                   codegen::getFileType(), NoVerify)) {
+    } else if (Target->addPassesToEmitFile(PM, MMI, *OS,
+                                           DwoOut ? &DwoOut->os() : nullptr,
+                                           codegen::getFileType(), NoVerify)) {
       reportError("target does not support generation of this file type");
     }
 
diff --git a/llvm/tools/llvm-exegesis/lib/Assembler.cpp b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
index 4472186d6a..97307b7007 100644
--- a/llvm/tools/llvm-exegesis/lib/Assembler.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Assembler.cpp
@@ -235,8 +235,8 @@ BitVector getFunctionReservedRegs(const TargetMachine &TM) {
   // TODO: This only works for targets implementing LLVMTargetMachine.
   const LLVMTargetMachine &LLVMTM = static_cast<const LLVMTargetMachine &>(TM);
   MachineModuleInfo MMI(&LLVMTM);
-  MachineFunction &MF = createVoidVoidPtrMachineFunction(
-      FunctionID, Module.get(), &MMI);
+  MachineFunction &MF =
+      createVoidVoidPtrMachineFunction(FunctionID, Module.get(), &MMI);
   // Saving reserved registers for client.
   return MF.getSubtarget().getRegisterInfo()->getReservedRegs(MF);
 }
@@ -250,8 +250,8 @@ Error assembleToStream(const ExegesisTarget &ET,
   std::unique_ptr<Module> Module =
       createModule(Context, TM->createDataLayout());
   MachineModuleInfo MMI(TM.get());
-  MachineFunction &MF = createVoidVoidPtrMachineFunction(
-      FunctionID, Module.get(), &MMI);
+  MachineFunction &MF =
+      createVoidVoidPtrMachineFunction(FunctionID, Module.get(), &MMI);
   MF.ensureAlignment(kFunctionAlignment);
 
   // We need to instruct the passes that we're done with SSA and virtual
diff --git a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
index 63766f5490..a5e86a1b2f 100644
--- a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
+++ b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
@@ -97,7 +97,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
 
   // Build up a PM to do instruction selection.
   legacy::PassManager PM;
-  MachineModuleInfo MMI(static_cast<LLVMTargetMachine*>(TM.get()));
+  MachineModuleInfo MMI(static_cast<LLVMTargetMachine *>(TM.get()));
   TargetLibraryInfoImpl TLII(TM->getTargetTriple());
   PM.add(new TargetLibraryInfoWrapperPass(TLII));
   raw_null_ostream OS;
diff --git a/llvm/unittests/MI/LiveIntervalTest.cpp b/llvm/unittests/MI/LiveIntervalTest.cpp
index 5ebae2ced8..c1b3ce1c56 100644
--- a/llvm/unittests/MI/LiveIntervalTest.cpp
+++ b/llvm/unittests/MI/LiveIntervalTest.cpp
@@ -54,8 +54,7 @@ std::unique_ptr<LLVMTargetMachine> createTargetMachine() {
                              std::nullopt, CodeGenOptLevel::Aggressive)));
 }
 
-std::unique_ptr<Module> parseMIR(LLVMContext &Context,
-                                 MachineModuleInfo &MMI,
+std::unique_ptr<Module> parseMIR(LLVMContext &Context, MachineModuleInfo &MMI,
                                  std::unique_ptr<MIRParser> &MIR,
                                  const LLVMTargetMachine &TM,
                                  StringRef MIRCode) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/110443


More information about the cfe-commits mailing list