[llvm] [IR] Don't include PassInstrumentation.h in PassManager.h (NFC) (PR #96219)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 10:58:13 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-debuginfo
@llvm/pr-subscribers-llvm-ir
Author: Nikita Popov (nikic)
<details>
<summary>Changes</summary>
Move PassInstrumentationAnalysis into PassInstrumentation.h and stop including it in PassManager.h (effectively inverting the direction of the dependency).
Most places using PassManager are not interested in PassInstrumentation, and we no longer have any uses of it in PassManager.h itself (only in PassManagerImpl.h).
---
Full diff: https://github.com/llvm/llvm-project/pull/96219.diff
12 Files Affected:
- (modified) llvm/include/llvm/IR/PassInstrumentation.h (+25)
- (modified) llvm/include/llvm/IR/PassManager.h (-33)
- (modified) llvm/include/llvm/IR/PassManagerImpl.h (+1)
- (modified) llvm/include/llvm/Target/TargetMachine.h (+1)
- (modified) llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h (+1)
- (modified) llvm/include/llvm/Transforms/Scalar/LoopPassManager.h (+1)
- (modified) llvm/include/llvm/Transforms/Utils/Debugify.h (+1)
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+1)
- (modified) llvm/lib/FuzzMutate/IRMutator.cpp (+1)
- (modified) llvm/unittests/Analysis/CGSCCPassManagerTest.cpp (+1)
- (modified) llvm/unittests/Analysis/InlineCostTest.cpp (+1)
- (modified) llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp (+1)
``````````diff
diff --git a/llvm/include/llvm/IR/PassInstrumentation.h b/llvm/include/llvm/IR/PassInstrumentation.h
index 519a5e46b4373..2869aaba79344 100644
--- a/llvm/include/llvm/IR/PassInstrumentation.h
+++ b/llvm/include/llvm/IR/PassInstrumentation.h
@@ -53,6 +53,7 @@
#include "llvm/ADT/FunctionExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
+#include "llvm/IR/PassManager.h"
#include <type_traits>
#include <vector>
@@ -329,6 +330,30 @@ class PassInstrumentation {
bool isSpecialPass(StringRef PassID, const std::vector<StringRef> &Specials);
+/// Pseudo-analysis pass that exposes the \c PassInstrumentation to pass
+/// managers.
+class PassInstrumentationAnalysis
+ : public AnalysisInfoMixin<PassInstrumentationAnalysis> {
+ friend AnalysisInfoMixin<PassInstrumentationAnalysis>;
+ static AnalysisKey Key;
+
+ PassInstrumentationCallbacks *Callbacks;
+
+public:
+ /// PassInstrumentationCallbacks object is shared, owned by something else,
+ /// not this analysis.
+ PassInstrumentationAnalysis(PassInstrumentationCallbacks *Callbacks = nullptr)
+ : Callbacks(Callbacks) {}
+
+ using Result = PassInstrumentation;
+
+ template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
+ Result run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
+ return PassInstrumentation(Callbacks);
+ }
+};
+
+
} // namespace llvm
#endif
diff --git a/llvm/include/llvm/IR/PassManager.h b/llvm/include/llvm/IR/PassManager.h
index 65ba524bf49c4..97405ecffdb55 100644
--- a/llvm/include/llvm/IR/PassManager.h
+++ b/llvm/include/llvm/IR/PassManager.h
@@ -44,7 +44,6 @@
#include "llvm/IR/Analysis.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
-#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/PassManagerInternal.h"
#include "llvm/Support/TypeName.h"
#include <cassert>
@@ -143,12 +142,6 @@ getAnalysisResult(AnalysisManager<IRUnitT, AnalysisArgTs...> &AM, IRUnitT &IR,
} // namespace detail
-// Forward declare the pass instrumentation analysis explicitly queried in
-// generic PassManager code.
-// FIXME: figure out a way to move PassInstrumentationAnalysis into its own
-// header.
-class PassInstrumentationAnalysis;
-
/// Manages a sequence of passes over a particular unit of IR.
///
/// A pass manager contains a sequence of passes to run over a particular unit
@@ -238,32 +231,6 @@ extern template class PassManager<Function>;
/// Convenience typedef for a pass manager over functions.
using FunctionPassManager = PassManager<Function>;
-/// Pseudo-analysis pass that exposes the \c PassInstrumentation to pass
-/// managers. Goes before AnalysisManager definition to provide its
-/// internals (e.g PassInstrumentationAnalysis::ID) for use there if needed.
-/// FIXME: figure out a way to move PassInstrumentationAnalysis into its own
-/// header.
-class PassInstrumentationAnalysis
- : public AnalysisInfoMixin<PassInstrumentationAnalysis> {
- friend AnalysisInfoMixin<PassInstrumentationAnalysis>;
- static AnalysisKey Key;
-
- PassInstrumentationCallbacks *Callbacks;
-
-public:
- /// PassInstrumentationCallbacks object is shared, owned by something else,
- /// not this analysis.
- PassInstrumentationAnalysis(PassInstrumentationCallbacks *Callbacks = nullptr)
- : Callbacks(Callbacks) {}
-
- using Result = PassInstrumentation;
-
- template <typename IRUnitT, typename AnalysisManagerT, typename... ExtraArgTs>
- Result run(IRUnitT &, AnalysisManagerT &, ExtraArgTs &&...) {
- return PassInstrumentation(Callbacks);
- }
-};
-
/// A container for analyses that lazily runs them and caches their
/// results.
///
diff --git a/llvm/include/llvm/IR/PassManagerImpl.h b/llvm/include/llvm/IR/PassManagerImpl.h
index e4a85b0f33b26..e8a95761c3494 100644
--- a/llvm/include/llvm/IR/PassManagerImpl.h
+++ b/llvm/include/llvm/IR/PassManagerImpl.h
@@ -16,6 +16,7 @@
#define LLVM_IR_PASSMANAGERIMPL_H
#include "llvm/Support/CommandLine.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/PassManager.h"
extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index e72045391bf31..f09c3b2b347c5 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -45,6 +45,7 @@ class MCSubtargetInfo;
class MCSymbol;
class raw_pwrite_stream;
class PassBuilder;
+class PassInstrumentationCallbacks;
struct PerFunctionMIParsingState;
class SMDiagnostic;
class SMRange;
diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h b/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
index 7f2cc0ebbc07c..b52ef847d9db6 100644
--- a/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
+++ b/llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
@@ -17,6 +17,7 @@
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/ProfileData/SampleProf.h"
#include <unordered_map>
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index 7bdb4eafd107d..3858be05c61fa 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -41,6 +41,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopNestAnalysis.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/Transforms/Utils/LCSSA.h"
#include "llvm/Transforms/Utils/LoopSimplify.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
diff --git a/llvm/include/llvm/Transforms/Utils/Debugify.h b/llvm/include/llvm/Transforms/Utils/Debugify.h
index d4440942a64ef..7981b9ec70364 100644
--- a/llvm/include/llvm/Transforms/Utils/Debugify.h
+++ b/llvm/include/llvm/Transforms/Utils/Debugify.h
@@ -20,6 +20,7 @@
#include "llvm/IR/IRPrintingPasses.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index 9eafc9f90cc1b..bf0ca32e8b99f 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -40,6 +40,7 @@
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/ReplaceConstant.h"
#include "llvm/IR/Value.h"
#include "llvm/MC/TargetRegistry.h"
diff --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp
index ea630c4602ba4..3f27daad55e39 100644
--- a/llvm/lib/FuzzMutate/IRMutator.cpp
+++ b/llvm/lib/FuzzMutate/IRMutator.cpp
@@ -22,6 +22,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SourceMgr.h"
diff --git a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
index aab148c12c416..1532379c9ba02 100644
--- a/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
+++ b/llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
@@ -17,6 +17,7 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
diff --git a/llvm/unittests/Analysis/InlineCostTest.cpp b/llvm/unittests/Analysis/InlineCostTest.cpp
index 881c31f05d7e5..78e2aee95f82a 100644
--- a/llvm/unittests/Analysis/InlineCostTest.cpp
+++ b/llvm/unittests/Analysis/InlineCostTest.cpp
@@ -15,6 +15,7 @@
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/Support/SourceMgr.h"
#include "gtest/gtest.h"
diff --git a/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp b/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
index d0e8977f1245d..52bad210b583e 100644
--- a/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
+++ b/llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
@@ -15,6 +15,7 @@
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Constants.h"
+#include "llvm/IR/PassInstrumentation.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Transforms/IPO/FunctionSpecialization.h"
#include "llvm/Transforms/Utils/SCCPSolver.h"
``````````
</details>
https://github.com/llvm/llvm-project/pull/96219
More information about the llvm-commits
mailing list