Skip to content

[llvm] annotate interfaces in llvm/Transforms for DLL export #143413

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 10, 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
9 changes: 5 additions & 4 deletions llvm/include/llvm/Transforms/Coroutines/ABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define LLVM_TRANSFORMS_COROUTINES_ABI_H

#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Transforms/Coroutines/CoroShape.h"
#include "llvm/Transforms/Coroutines/MaterializationUtils.h"
#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
Expand All @@ -37,7 +38,7 @@ namespace coro {
// index of an ABI generator for the custom ABI object in a SmallVector passed
// to CoroSplitPass ctor.

class BaseABI {
class LLVM_ABI BaseABI {
public:
BaseABI(Function &F, coro::Shape &S,
std::function<bool(Instruction &)> IsMaterializable)
Expand All @@ -63,7 +64,7 @@ class BaseABI {
std::function<bool(Instruction &I)> IsMaterializable;
};

class SwitchABI : public BaseABI {
class LLVM_ABI SwitchABI : public BaseABI {
public:
SwitchABI(Function &F, coro::Shape &S,
std::function<bool(Instruction &)> IsMaterializable)
Expand All @@ -76,7 +77,7 @@ class SwitchABI : public BaseABI {
TargetTransformInfo &TTI) override;
};

class AsyncABI : public BaseABI {
class LLVM_ABI AsyncABI : public BaseABI {
public:
AsyncABI(Function &F, coro::Shape &S,
std::function<bool(Instruction &)> IsMaterializable)
Expand All @@ -89,7 +90,7 @@ class AsyncABI : public BaseABI {
TargetTransformInfo &TTI) override;
};

class AnyRetconABI : public BaseABI {
class LLVM_ABI AnyRetconABI : public BaseABI {
public:
AnyRetconABI(Function &F, coro::Shape &S,
std::function<bool(Instruction &)> IsMaterializable)
Expand Down
9 changes: 5 additions & 4 deletions llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"

namespace llvm {
Expand Down Expand Up @@ -237,7 +238,7 @@ class AnyCoroIdRetconInst : public AnyCoroIdInst {
enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };

public:
void checkWellFormed() const;
LLVM_ABI void checkWellFormed() const;

uint64_t getStorageSize() const {
return cast<ConstantInt>(getArgOperand(SizeArg))->getZExtValue();
Expand Down Expand Up @@ -306,7 +307,7 @@ class CoroIdAsyncInst : public AnyCoroIdInst {
enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };

public:
void checkWellFormed() const;
LLVM_ABI void checkWellFormed() const;

/// The initial async function context size. The fields of which are reserved
/// for use by the frontend. The frame will be allocated as a tail of this
Expand Down Expand Up @@ -568,7 +569,7 @@ class CoroSuspendAsyncInst : public AnyCoroSuspendInst {
MustTailCallFuncArg
};

void checkWellFormed() const;
LLVM_ABI void checkWellFormed() const;

unsigned getStorageArgumentIndex() const {
auto *Arg = cast<ConstantInt>(getArgOperand(StorageArgNoArg));
Expand Down Expand Up @@ -722,7 +723,7 @@ class CoroAsyncEndInst : public AnyCoroEndInst {
enum { FrameArg, UnwindArg, MustTailCallFuncArg };

public:
void checkWellFormed() const;
LLVM_ABI void checkWellFormed() const;

Function *getMustTailCallFunction() const {
if (arg_size() < 3)
Expand Down
27 changes: 16 additions & 11 deletions llvm/include/llvm/Transforms/Coroutines/CoroShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Transforms/Coroutines/CoroInstr.h"

namespace llvm {
Expand Down Expand Up @@ -78,18 +79,20 @@ struct Shape {
}

// Scan the function and collect the above intrinsics for later processing
void analyze(Function &F, SmallVectorImpl<CoroFrameInst *> &CoroFrames,
SmallVectorImpl<CoroSaveInst *> &UnusedCoroSaves,
CoroPromiseInst *&CoroPromise);
LLVM_ABI void analyze(Function &F,
SmallVectorImpl<CoroFrameInst *> &CoroFrames,
SmallVectorImpl<CoroSaveInst *> &UnusedCoroSaves,
CoroPromiseInst *&CoroPromise);
// If for some reason, we were not able to find coro.begin, bailout.
void invalidateCoroutine(Function &F,
SmallVectorImpl<CoroFrameInst *> &CoroFrames);
LLVM_ABI void
invalidateCoroutine(Function &F,
SmallVectorImpl<CoroFrameInst *> &CoroFrames);
// Perform ABI related initial transformation
void initABI();
LLVM_ABI void initABI();
// Remove orphaned and unnecessary intrinsics
void cleanCoroutine(SmallVectorImpl<CoroFrameInst *> &CoroFrames,
SmallVectorImpl<CoroSaveInst *> &UnusedCoroSaves,
CoroPromiseInst *CoroPromise);
LLVM_ABI void cleanCoroutine(SmallVectorImpl<CoroFrameInst *> &CoroFrames,
SmallVectorImpl<CoroSaveInst *> &UnusedCoroSaves,
CoroPromiseInst *CoroPromise);

// Field indexes for special fields in the switch lowering.
struct SwitchFieldIndex {
Expand Down Expand Up @@ -256,12 +259,14 @@ struct Shape {
/// Allocate memory according to the rules of the active lowering.
///
/// \param CG - if non-null, will be updated for the new call
Value *emitAlloc(IRBuilder<> &Builder, Value *Size, CallGraph *CG) const;
LLVM_ABI Value *emitAlloc(IRBuilder<> &Builder, Value *Size,
CallGraph *CG) const;

/// Deallocate memory according to the rules of the active lowering.
///
/// \param CG - if non-null, will be updated for the new call
void emitDealloc(IRBuilder<> &Builder, Value *Ptr, CallGraph *CG) const;
LLVM_ABI void emitDealloc(IRBuilder<> &Builder, Value *Ptr,
CallGraph *CG) const;

Shape() = default;
explicit Shape(Function &F) {
Expand Down
14 changes: 9 additions & 5 deletions llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Transforms/Coroutines/ABI.h"

namespace llvm {
Expand All @@ -31,20 +32,23 @@ struct CoroSplitPass : PassInfoMixin<CoroSplitPass> {
using BaseABITy =
std::function<std::unique_ptr<coro::BaseABI>(Function &, coro::Shape &)>;

CoroSplitPass(bool OptimizeFrame = false);
LLVM_ABI CoroSplitPass(bool OptimizeFrame = false);

CoroSplitPass(SmallVector<BaseABITy> GenCustomABIs,
bool OptimizeFrame = false);
LLVM_ABI CoroSplitPass(SmallVector<BaseABITy> GenCustomABIs,
bool OptimizeFrame = false);

LLVM_ABI
CoroSplitPass(std::function<bool(Instruction &)> MaterializableCallback,
bool OptimizeFrame = false);

LLVM_ABI
CoroSplitPass(std::function<bool(Instruction &)> MaterializableCallback,
SmallVector<BaseABITy> GenCustomABIs,
bool OptimizeFrame = false);

PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C,
CGSCCAnalysisManager &AM, LazyCallGraph &CG,
CGSCCUpdateResult &UR);

static bool isRequired() { return true; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/Compiler.h"
#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"

#ifndef LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
Expand All @@ -16,11 +17,12 @@ namespace llvm {
namespace coro {

// True if I is trivially rematerialzable, e.g. InsertElementInst
bool isTriviallyMaterializable(Instruction &I);
LLVM_ABI bool isTriviallyMaterializable(Instruction &I);

// Performs rematerialization, invoked from buildCoroutineFrame.
void doRematerializations(Function &F, SuspendCrossingInfo &Checker,
std::function<bool(Instruction &)> IsMaterializable);
LLVM_ABI void
doRematerializations(Function &F, SuspendCrossingInfo &Checker,
std::function<bool(Instruction &)> IsMaterializable);

} // namespace coro

Expand Down
9 changes: 6 additions & 3 deletions llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Transforms/Coroutines/CoroInstr.h"

namespace llvm {
Expand Down Expand Up @@ -102,19 +103,21 @@ class SuspendCrossingInfo {
ModuleSlotTracker &MST) const;
#endif

LLVM_ABI
SuspendCrossingInfo(Function &F,
const SmallVectorImpl<AnyCoroSuspendInst *> &CoroSuspends,
const SmallVectorImpl<AnyCoroEndInst *> &CoroEnds);

/// Returns true if there is a path from \p From to \p To crossing a suspend
/// point without crossing \p From a 2nd time.
bool hasPathCrossingSuspendPoint(BasicBlock *From, BasicBlock *To) const;
LLVM_ABI bool hasPathCrossingSuspendPoint(BasicBlock *From,
BasicBlock *To) const;

/// Returns true if there is a path from \p From to \p To crossing a suspend
/// point without crossing \p From a 2nd time. If \p From is the same as \p To
/// this will also check if there is a looping path crossing a suspend point.
bool hasPathOrLoopCrossingSuspendPoint(BasicBlock *From,
BasicBlock *To) const;
LLVM_ABI bool hasPathOrLoopCrossingSuspendPoint(BasicBlock *From,
BasicBlock *To) const;

bool isDefinitionAcrossSuspend(BasicBlock *DefBB, User *U) const {
auto *I = cast<Instruction>(U);
Expand Down
5 changes: 3 additions & 2 deletions llvm/include/llvm/Transforms/HipStdPar/HipStdPar.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define LLVM_TRANSFORMS_HIPSTDPAR_HIPSTDPAR_H

#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

Expand All @@ -27,15 +28,15 @@ class Module;
class HipStdParAcceleratorCodeSelectionPass
: public PassInfoMixin<HipStdParAcceleratorCodeSelectionPass> {
public:
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);

static bool isRequired() { return true; }
};

class HipStdParAllocationInterpositionPass
: public PassInfoMixin<HipStdParAllocationInterpositionPass> {
public:
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);

static bool isRequired() { return true; }
};
Expand Down
10 changes: 5 additions & 5 deletions llvm/include/llvm/Transforms/IPO.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,29 @@ class raw_ostream;
/// createDeadArgEliminationPass - This pass removes arguments from functions
/// which are not used by the body of the function.
///
ModulePass *createDeadArgEliminationPass();
LLVM_ABI ModulePass *createDeadArgEliminationPass();

/// DeadArgHacking pass - Same as DAE, but delete arguments of external
/// functions as well. This is definitely not safe, and should only be used by
/// bugpoint.
ModulePass *createDeadArgHackingPass();
LLVM_ABI ModulePass *createDeadArgHackingPass();

//===----------------------------------------------------------------------===//
//
/// createLoopExtractorPass - This pass extracts all natural loops from the
/// program into a function if it can.
///
Pass *createLoopExtractorPass();
LLVM_ABI Pass *createLoopExtractorPass();

/// createSingleLoopExtractorPass - This pass extracts one natural loop from the
/// program into a function if it can. This is used by bugpoint.
///
Pass *createSingleLoopExtractorPass();
LLVM_ABI Pass *createSingleLoopExtractorPass();

//===----------------------------------------------------------------------===//
/// createBarrierNoopPass - This pass is purely a module pass barrier in a pass
/// manager.
ModulePass *createBarrierNoopPass();
LLVM_ABI ModulePass *createBarrierNoopPass();

/// What to do with the summary when running passes that operate on it.
enum class PassSummaryAction {
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/Transforms/IPO/AlwaysInliner.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H

#include "llvm/IR/PassManager.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

Expand All @@ -36,14 +37,13 @@ class AlwaysInlinerPass : public PassInfoMixin<AlwaysInlinerPass> {
AlwaysInlinerPass(bool InsertLifetime = true)
: InsertLifetime(InsertLifetime) {}

PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &);
static bool isRequired() { return true; }
};

/// Create a legacy pass manager instance of a pass to inline and remove
/// functions marked as "always_inline".
Pass *createAlwaysInlinerLegacyPass(bool InsertLifetime = true);

LLVM_ABI Pass *createAlwaysInlinerLegacyPass(bool InsertLifetime = true);
}

#endif // LLVM_TRANSFORMS_IPO_ALWAYSINLINER_H
Loading