Skip to content

[llvm] annotate interfaces in Passes for DLL export #143794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
589 changes: 301 additions & 288 deletions llvm/include/llvm/InitializePasses.h

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions llvm/include/llvm/Pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#ifdef EXPENSIVE_CHECKS
#include <cstdint>
#endif
#include "llvm/Support/Compiler.h"
#include <string>

namespace llvm {
Expand Down Expand Up @@ -95,7 +96,7 @@ const char *to_string(ThinOrFullLTOPhase Phase);
/// interprocedural optimization or you do not fit into any of the more
/// constrained passes described below.
///
class Pass {
class LLVM_ABI Pass {
AnalysisResolver *Resolver = nullptr; // Used to resolve analysis
const void *PassID;
PassKind Kind;
Expand Down Expand Up @@ -252,7 +253,7 @@ class Pass {
/// interprocedural optimizations and analyses. ModulePasses may do anything
/// they want to the program.
///
class ModulePass : public Pass {
class LLVM_ABI ModulePass : public Pass {
public:
explicit ModulePass(char &pid) : Pass(PT_Module, pid) {}

Expand Down Expand Up @@ -282,7 +283,7 @@ class ModulePass : public Pass {
/// ImmutablePass class - This class is used to provide information that does
/// not need to be run. This is useful for things like target information.
///
class ImmutablePass : public ModulePass {
class LLVM_ABI ImmutablePass : public ModulePass {
public:
explicit ImmutablePass(char &pid) : ModulePass(pid) {}

Expand Down Expand Up @@ -311,7 +312,7 @@ class ImmutablePass : public ModulePass {
/// 2. Optimizing a function does not cause the addition or removal of any
/// functions in the module
///
class FunctionPass : public Pass {
class LLVM_ABI FunctionPass : public Pass {
public:
explicit FunctionPass(char &pid) : Pass(PT_Function, pid) {}

Expand All @@ -338,13 +339,13 @@ class FunctionPass : public Pass {
/// If the user specifies the -time-passes argument on an LLVM tool command line
/// then the value of this boolean will be true, otherwise false.
/// This is the storage for the -time-passes option.
extern bool TimePassesIsEnabled;
LLVM_ABI extern bool TimePassesIsEnabled;
/// If TimePassesPerRun is true, there would be one line of report for
/// each pass invocation.
/// If TimePassesPerRun is false, there would be only one line of
/// report for each pass (even there are more than one pass objects).
/// (For new pass manager only)
extern bool TimePassesPerRun;
LLVM_ABI extern bool TimePassesPerRun;

} // end namespace llvm

Expand Down
16 changes: 9 additions & 7 deletions llvm/include/llvm/PassAnalysisSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
#include <tuple>
#include <utility>
Expand Down Expand Up @@ -69,14 +70,14 @@ class AnalysisUsage {

///@{
/// Add the specified ID to the required set of the usage info for a pass.
AnalysisUsage &addRequiredID(const void *ID);
AnalysisUsage &addRequiredID(char &ID);
LLVM_ABI AnalysisUsage &addRequiredID(const void *ID);
LLVM_ABI AnalysisUsage &addRequiredID(char &ID);
template<class PassClass>
AnalysisUsage &addRequired() {
return addRequiredID(PassClass::ID);
}

AnalysisUsage &addRequiredTransitiveID(char &ID);
LLVM_ABI AnalysisUsage &addRequiredTransitiveID(char &ID);
template<class PassClass>
AnalysisUsage &addRequiredTransitive() {
return addRequiredTransitiveID(PassClass::ID);
Expand Down Expand Up @@ -124,7 +125,7 @@ class AnalysisUsage {
/// preserved by this pass. If no such Pass exists, do nothing. This can be
/// useful when a pass is trivially preserved, but may not be linked in. Be
/// careful about spelling!
AnalysisUsage &addPreserved(StringRef Arg);
LLVM_ABI AnalysisUsage &addPreserved(StringRef Arg);

/// Set by analyses that do not transform their input at all
void setPreservesAll() { PreservesAll = true; }
Expand All @@ -139,7 +140,7 @@ class AnalysisUsage {
///
/// This function annotates the AnalysisUsage info object to say that analyses
/// that only depend on the CFG are preserved by this pass.
void setPreservesCFG();
LLVM_ABI void setPreservesCFG();

const VectorType &getRequiredSet() const { return Required; }
const VectorType &getRequiredTransitiveSet() const {
Expand Down Expand Up @@ -174,7 +175,8 @@ class AnalysisResolver {
}

/// Find pass that is implementing PI. Initialize pass for Function F.
std::tuple<Pass *, bool> findImplPass(Pass *P, AnalysisID PI, Function &F);
LLVM_ABI std::tuple<Pass *, bool> findImplPass(Pass *P, AnalysisID PI,
Function &F);

void addAnalysisImplsPair(AnalysisID PI, Pass *P) {
if (findImplPass(PI) == P)
Expand All @@ -189,7 +191,7 @@ class AnalysisResolver {
}

/// Return analysis result or null if it doesn't exist.
Pass *getAnalysisIfAvailable(AnalysisID ID) const;
LLVM_ABI Pass *getAnalysisIfAvailable(AnalysisID ID) const;

private:
/// This keeps track of which passes implements the interfaces that are
Expand Down
17 changes: 9 additions & 8 deletions llvm/include/llvm/PassRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/RWMutex.h"
#include <memory>
#include <vector>
Expand Down Expand Up @@ -49,36 +50,36 @@ class PassRegistry {

public:
PassRegistry() = default;
~PassRegistry();
LLVM_ABI ~PassRegistry();

/// getPassRegistry - Access the global registry object, which is
/// automatically initialized at application launch and destroyed by
/// llvm_shutdown.
static PassRegistry *getPassRegistry();
LLVM_ABI static PassRegistry *getPassRegistry();

/// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
/// type identifier (&MyPass::ID).
const PassInfo *getPassInfo(const void *TI) const;
LLVM_ABI const PassInfo *getPassInfo(const void *TI) const;

/// getPassInfo - Look up a pass' corresponding PassInfo, indexed by the pass'
/// argument string.
const PassInfo *getPassInfo(StringRef Arg) const;
LLVM_ABI const PassInfo *getPassInfo(StringRef Arg) const;

/// registerPass - Register a pass (by means of its PassInfo) with the
/// registry. Required in order to use the pass with a PassManager.
void registerPass(const PassInfo &PI, bool ShouldFree = false);
LLVM_ABI void registerPass(const PassInfo &PI, bool ShouldFree = false);

/// enumerateWith - Enumerate the registered passes, calling the provided
/// PassRegistrationListener's passEnumerate() callback on each of them.
void enumerateWith(PassRegistrationListener *L);
LLVM_ABI void enumerateWith(PassRegistrationListener *L);

/// addRegistrationListener - Register the given PassRegistrationListener
/// to receive passRegistered() callbacks whenever a new pass is registered.
void addRegistrationListener(PassRegistrationListener *L);
LLVM_ABI void addRegistrationListener(PassRegistrationListener *L);

/// removeRegistrationListener - Unregister a PassRegistrationListener so that
/// it no longer receives passRegistered() callbacks.
void removeRegistrationListener(PassRegistrationListener *L);
LLVM_ABI void removeRegistrationListener(PassRegistrationListener *L);
};

} // end namespace llvm
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/PassSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/PassInfo.h"
#include "llvm/PassRegistry.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/Threading.h"
#include <functional>
Expand Down Expand Up @@ -112,7 +113,7 @@ struct PassRegistrationListener {

/// enumeratePasses - Iterate over the registered passes, calling the
/// passEnumerate callback on each PassInfo object.
void enumeratePasses();
LLVM_ABI void enumeratePasses();

/// passEnumerate - Callback function invoked when someone calls
/// enumeratePasses on this PassRegistrationListener object.
Expand Down
13 changes: 7 additions & 6 deletions llvm/include/llvm/Passes/OptimizationLevel.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifndef LLVM_PASSES_OPTIMIZATIONLEVEL_H
#define LLVM_PASSES_OPTIMIZATIONLEVEL_H

#include "llvm/Support/Compiler.h"
#include <assert.h>

namespace llvm {
Expand All @@ -38,7 +39,7 @@ class OptimizationLevel final {
/// Disable as many optimizations as possible. This doesn't completely
/// disable the optimizer in all cases, for example always_inline functions
/// can be required to be inlined for correctness.
static const OptimizationLevel O0;
LLVM_ABI static const OptimizationLevel O0;

/// Optimize quickly without destroying debuggability.
///
Expand All @@ -54,7 +55,7 @@ class OptimizationLevel final {
/// vectorization, or fusion don't make sense here due to the degree to
/// which the executed code differs from the source code, and the compile
/// time cost.
static const OptimizationLevel O1;
LLVM_ABI static const OptimizationLevel O1;
/// Optimize for fast execution as much as possible without triggering
/// significant incremental compile time or code size growth.
///
Expand All @@ -71,7 +72,7 @@ class OptimizationLevel final {
///
/// This is expected to be a good default optimization level for the vast
/// majority of users.
static const OptimizationLevel O2;
LLVM_ABI static const OptimizationLevel O2;
/// Optimize for fast execution as much as possible.
///
/// This mode is significantly more aggressive in trading off compile time
Expand All @@ -86,7 +87,7 @@ class OptimizationLevel final {
/// order to make even significantly slower compile times at least scale
/// reasonably. This does not preclude very substantial constant factor
/// costs though.
static const OptimizationLevel O3;
LLVM_ABI static const OptimizationLevel O3;
/// Similar to \c O2 but tries to optimize for small code size instead of
/// fast execution without triggering significant incremental execution
/// time slowdowns.
Expand All @@ -97,15 +98,15 @@ class OptimizationLevel final {
/// A consequence of the different core goal is that this should in general
/// produce substantially smaller executables that still run in
/// a reasonable amount of time.
static const OptimizationLevel Os;
LLVM_ABI static const OptimizationLevel Os;
/// A very specialized mode that will optimize for code size at any and all
/// costs.
///
/// This is useful primarily when there are absolute size limitations and
/// any effort taken to reduce the size is worth it regardless of the
/// execution time impact. You should expect this level to produce rather
/// slow, but very small, code.
static const OptimizationLevel Oz;
LLVM_ABI static const OptimizationLevel Oz;

bool isOptimizingForSpeed() const { return SizeLevel == 0 && SpeedLevel > 0; }

Expand Down
Loading
Loading