Skip to content

Commit

Permalink
[IR] Don't include PassInstrumentation.h in PassManager.h (NFC) (#96219)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
nikic authored Jun 21, 2024
1 parent f2f1845 commit 36c6632
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 33 deletions.
25 changes: 25 additions & 0 deletions llvm/include/llvm/IR/PassInstrumentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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
33 changes: 0 additions & 33 deletions llvm/include/llvm/IR/PassManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
///
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/PassManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Target/TargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class MCSubtargetInfo;
class MCSymbol;
class raw_pwrite_stream;
class PassBuilder;
class PassInstrumentationCallbacks;
struct PerFunctionMIParsingState;
class SMDiagnostic;
class SMRange;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Transforms/Utils/Debugify.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/FuzzMutate/IRMutator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions llvm/unittests/Analysis/InlineCostTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions polly/lib/Support/DumpFunctionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "polly/Support/DumpFunctionPass.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassInstrumentation.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
Expand Down

0 comments on commit 36c6632

Please sign in to comment.