[llvm] [Opt] Enable statically-linked plugin support (PR #79227)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 12:22:20 PST 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 31359840247b7d458ea8104373eea3f0cef95e16 99ea48f0f2b212a7499a9e3633fbee50866050cd -- llvm/tools/opt/test/opt-printplugin.cpp llvm/lib/Passes/PassPlugin.cpp llvm/tools/opt/driver/opt.cpp llvm/tools/opt/lib/NewPMDriver.cpp llvm/tools/opt/lib/NewPMDriver.h llvm/tools/opt/lib/optdriver.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/tools/opt/lib/NewPMDriver.cpp b/llvm/tools/opt/lib/NewPMDriver.cpp
index fdfb4df532..7c76e8a1e8 100644
--- a/llvm/tools/opt/lib/NewPMDriver.cpp
+++ b/llvm/tools/opt/lib/NewPMDriver.cpp
@@ -57,12 +57,12 @@ cl::opt<bool> VerifyEachDebugInfoPreserve(
     cl::desc("Start each pass with collecting and end it with checking of "
              "debug info preservation."));
 
-cl::opt<std::string>
-    VerifyDIPreserveExport("verify-di-preserve-export",
-                   cl::desc("Export debug info preservation failures into "
-                            "specified (JSON) file (should be abs path as we use"
-                            " append mode to insert new JSON objects)"),
-                   cl::value_desc("filename"), cl::init(""));
+cl::opt<std::string> VerifyDIPreserveExport(
+    "verify-di-preserve-export",
+    cl::desc("Export debug info preservation failures into "
+             "specified (JSON) file (should be abs path as we use"
+             " append mode to insert new JSON objects)"),
+    cl::value_desc("filename"), cl::init(""));
 
 } // namespace llvm
 
@@ -163,7 +163,6 @@ static cl::opt<bool> DisablePipelineVerification(
              "-print-pipeline-passes can be used to create a pipeline."),
     cl::Hidden);
 
-
 static cl::opt<PGOKind>
     PGOKindFlag("pgo-kind", cl::init(NoPGO), cl::Hidden,
                 cl::desc("The kind of profile guided optimization"),
@@ -174,8 +173,8 @@ static cl::opt<PGOKind>
                                       "Use instrumented profile to guide PGO."),
                            clEnumValN(SampleUse, "pgo-sample-use-pipeline",
                                       "Use sampled profile to guide PGO.")));
-static cl::opt<std::string> ProfileFile("profile-file",
-                                 cl::desc("Path to the profile."), cl::Hidden);
+static cl::opt<std::string>
+    ProfileFile("profile-file", cl::desc("Path to the profile."), cl::Hidden);
 static cl::opt<std::string>
     MemoryProfileFile("memory-profile-file",
                       cl::desc("Path to the memory profile."), cl::Hidden);
@@ -411,8 +410,7 @@ bool llvm::runPassPipeline(
   } else if (VerifyEachDebugInfoPreserve) {
     Debugify.setDebugInfoBeforePass(DebugInfoBeforePass);
     Debugify.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
-    Debugify.setOrigDIVerifyBugsReportFilePath(
-      VerifyDIPreserveExport);
+    Debugify.setOrigDIVerifyBugsReportFilePath(VerifyDIPreserveExport);
     Debugify.registerCallbacks(PIC, MAM);
   }
 
diff --git a/llvm/tools/opt/lib/NewPMDriver.h b/llvm/tools/opt/lib/NewPMDriver.h
index 19cabd1543..c9d66855f3 100644
--- a/llvm/tools/opt/lib/NewPMDriver.h
+++ b/llvm/tools/opt/lib/NewPMDriver.h
@@ -45,14 +45,9 @@ enum OutputKind {
   OK_OutputThinLTOBitcode,
 };
 enum VerifierKind { VK_NoVerifier, VK_VerifyOut, VK_VerifyEachPass };
-enum PGOKind {
-  NoPGO,
-  InstrGen,
-  InstrUse,
-  SampleUse
-};
+enum PGOKind { NoPGO, InstrGen, InstrUse, SampleUse };
 enum CSPGOKind { NoCSPGO, CSInstrGen, CSInstrUse };
-}
+} // namespace opt_tool
 
 void printPasses(raw_ostream &OS);
 
diff --git a/llvm/tools/opt/test/opt-printplugin.cpp b/llvm/tools/opt/test/opt-printplugin.cpp
index 2bb1e3ca5e..386a23e4f1 100644
--- a/llvm/tools/opt/test/opt-printplugin.cpp
+++ b/llvm/tools/opt/test/opt-printplugin.cpp
@@ -1,4 +1,5 @@
-//===- opt-printplugin.cpp - The LLVM Modular Optimizer -------------------------------===//
+//===- opt-printplugin.cpp - The LLVM Modular Optimizer
+//-------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -43,15 +44,15 @@ public:
 };
 
 void registerPlugin(PassBuilder &PB) {
-            PB.registerPipelineParsingCallback(
-                [](StringRef Name, llvm::ModulePassManager &PM,
-                   ArrayRef<llvm::PassBuilder::PipelineElement>) {
-                  if (Name == "printpass") {
-                    PM.addPass(PrintPass());
-                    return true;
-                  }
-                  return false;
-                });
+  PB.registerPipelineParsingCallback(
+      [](StringRef Name, llvm::ModulePassManager &PM,
+         ArrayRef<llvm::PassBuilder::PipelineElement>) {
+        if (Name == "printpass") {
+          PM.addPass(PrintPass());
+          return true;
+        }
+        return false;
+      });
 }
 
 } // namespace
@@ -61,6 +62,6 @@ extern "C" int optMain(int argc, char **argv,
                            PassBuilderCallbacks);
 
 int main(int argc, char **argv) {
-    std::function<void(llvm::PassBuilder &)> plugins[] = {registerPlugin};
-    return optMain(argc, argv, plugins);
+  std::function<void(llvm::PassBuilder &)> plugins[] = {registerPlugin};
+  return optMain(argc, argv, plugins);
 }

``````````

</details>


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


More information about the llvm-commits mailing list