Skip to content

[llvm] annotate interfaces in llvm/IR for DLL export #141650

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 2, 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
8 changes: 5 additions & 3 deletions llvm/include/llvm/IR/AbstractCallSite.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Compiler.h"
#include <cassert>

namespace llvm {
Expand Down Expand Up @@ -95,15 +96,16 @@ class AbstractCallSite {
/// If the use is not a callee use of a call or invoke instruction, the
/// callback metadata is used to determine the argument <-> parameter mapping
/// as well as the callee of the abstract call site.
AbstractCallSite(const Use *U);
LLVM_ABI AbstractCallSite(const Use *U);

/// Add operand uses of \p CB that represent callback uses into
/// \p CallbackUses.
///
/// All uses added to \p CallbackUses can be used to create abstract call
/// sites for which AbstractCallSite::isCallbackCall() will return true.
static void getCallbackUses(const CallBase &CB,
SmallVectorImpl<const Use *> &CallbackUses);
LLVM_ABI static void
getCallbackUses(const CallBase &CB,
SmallVectorImpl<const Use *> &CallbackUses);

/// Conversion operator to conveniently check for a valid/initialized ACS.
explicit operator bool() const { return CB != nullptr; }
Expand Down
9 changes: 5 additions & 4 deletions llvm/include/llvm/IR/Analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define LLVM_IR_ANALYSIS_H

#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

Expand Down Expand Up @@ -56,8 +57,8 @@ template <typename IRUnitT> class AllAnalysesOn {

template <typename IRUnitT> AnalysisSetKey AllAnalysesOn<IRUnitT>::SetKey;

extern template class AllAnalysesOn<Module>;
extern template class AllAnalysesOn<Function>;
extern template class LLVM_TEMPLATE_ABI AllAnalysesOn<Module>;
extern template class LLVM_TEMPLATE_ABI AllAnalysesOn<Function>;

/// Represents analyses that only rely on functions' control flow.
///
Expand All @@ -74,7 +75,7 @@ class CFGAnalyses {
static AnalysisSetKey *ID() { return &SetKey; }

private:
static AnalysisSetKey SetKey;
LLVM_ABI static AnalysisSetKey SetKey;
};

/// A set of analyses that are preserved following a run of a transformation
Expand Down Expand Up @@ -310,7 +311,7 @@ class PreservedAnalyses {

private:
/// A special key used to indicate all analyses.
static AnalysisSetKey AllAnalysesKey;
LLVM_ABI static AnalysisSetKey AllAnalysesKey;

/// The IDs of analyses and analysis sets that are preserved.
SmallPtrSet<void *, 2> PreservedIDs;
Expand Down
89 changes: 45 additions & 44 deletions llvm/include/llvm/IR/Argument.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "llvm/ADT/Twine.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Compiler.h"
#include <optional>

namespace llvm {
Expand All @@ -37,8 +38,8 @@ class Argument final : public Value {

public:
/// Argument constructor.
explicit Argument(Type *Ty, const Twine &Name = "", Function *F = nullptr,
unsigned ArgNo = 0);
LLVM_ABI explicit Argument(Type *Ty, const Twine &Name = "",
Function *F = nullptr, unsigned ArgNo = 0);

inline const Function *getParent() const { return Parent; }
inline Function *getParent() { return Parent; }
Expand All @@ -56,133 +57,133 @@ class Argument final : public Value {
/// addrspace(0).
/// If AllowUndefOrPoison is true, respect the semantics of nonnull attribute
/// and return true even if the argument can be undef or poison.
bool hasNonNullAttr(bool AllowUndefOrPoison = true) const;
LLVM_ABI bool hasNonNullAttr(bool AllowUndefOrPoison = true) const;

/// If this argument has the dereferenceable attribute, return the number of
/// bytes known to be dereferenceable. Otherwise, zero is returned.
uint64_t getDereferenceableBytes() const;
LLVM_ABI uint64_t getDereferenceableBytes() const;

/// If this argument has the dereferenceable_or_null attribute, return the
/// number of bytes known to be dereferenceable. Otherwise, zero is returned.
uint64_t getDereferenceableOrNullBytes() const;
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const;

/// If this argument has nofpclass attribute, return the mask representing
/// disallowed floating-point values. Otherwise, fcNone is returned.
FPClassTest getNoFPClass() const;
LLVM_ABI FPClassTest getNoFPClass() const;

/// If this argument has a range attribute, return the value range of the
/// argument. Otherwise, std::nullopt is returned.
std::optional<ConstantRange> getRange() const;
LLVM_ABI std::optional<ConstantRange> getRange() const;

/// Return true if this argument has the byval attribute.
bool hasByValAttr() const;
LLVM_ABI bool hasByValAttr() const;

/// Return true if this argument has the byref attribute.
bool hasByRefAttr() const;
LLVM_ABI bool hasByRefAttr() const;

/// Return true if this argument has the swiftself attribute.
bool hasSwiftSelfAttr() const;
LLVM_ABI bool hasSwiftSelfAttr() const;

/// Return true if this argument has the swifterror attribute.
bool hasSwiftErrorAttr() const;
LLVM_ABI bool hasSwiftErrorAttr() const;

/// Return true if this argument has the byval, inalloca, or preallocated
/// attribute. These attributes represent arguments being passed by value,
/// with an associated copy between the caller and callee
bool hasPassPointeeByValueCopyAttr() const;
LLVM_ABI bool hasPassPointeeByValueCopyAttr() const;

/// If this argument satisfies has hasPassPointeeByValueAttr, return the
/// in-memory ABI size copied to the stack for the call. Otherwise, return 0.
uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const;
LLVM_ABI uint64_t getPassPointeeByValueCopySize(const DataLayout &DL) const;

/// Return true if this argument has the byval, sret, inalloca, preallocated,
/// or byref attribute. These attributes represent arguments being passed by
/// value (which may or may not involve a stack copy)
bool hasPointeeInMemoryValueAttr() const;
LLVM_ABI bool hasPointeeInMemoryValueAttr() const;

/// If hasPointeeInMemoryValueAttr returns true, the in-memory ABI type is
/// returned. Otherwise, nullptr.
Type *getPointeeInMemoryValueType() const;
LLVM_ABI Type *getPointeeInMemoryValueType() const;

/// If this is a byval or inalloca argument, return its alignment.
/// FIXME: Remove this function once transition to Align is over.
/// Use getParamAlign() instead.
LLVM_DEPRECATED("Use getParamAlign() instead", "getParamAlign")
uint64_t getParamAlignment() const;
LLVM_ABI LLVM_DEPRECATED("Use getParamAlign() instead",
"getParamAlign") uint64_t getParamAlignment() const;

/// If this is a byval or inalloca argument, return its alignment.
MaybeAlign getParamAlign() const;
LLVM_ABI MaybeAlign getParamAlign() const;

MaybeAlign getParamStackAlign() const;
LLVM_ABI MaybeAlign getParamStackAlign() const;

/// If this is a byval argument, return its type.
Type *getParamByValType() const;
LLVM_ABI Type *getParamByValType() const;

/// If this is an sret argument, return its type.
Type *getParamStructRetType() const;
LLVM_ABI Type *getParamStructRetType() const;

/// If this is a byref argument, return its type.
Type *getParamByRefType() const;
LLVM_ABI Type *getParamByRefType() const;

/// If this is an inalloca argument, return its type.
Type *getParamInAllocaType() const;
LLVM_ABI Type *getParamInAllocaType() const;

/// Return true if this argument has the nest attribute.
bool hasNestAttr() const;
LLVM_ABI bool hasNestAttr() const;

/// Return true if this argument has the noalias attribute.
bool hasNoAliasAttr() const;
LLVM_ABI bool hasNoAliasAttr() const;

/// Return true if this argument has the nocapture attribute.
bool hasNoCaptureAttr() const;
LLVM_ABI bool hasNoCaptureAttr() const;

/// Return true if this argument has the nofree attribute.
bool hasNoFreeAttr() const;
LLVM_ABI bool hasNoFreeAttr() const;

/// Return true if this argument has the sret attribute.
bool hasStructRetAttr() const;
LLVM_ABI bool hasStructRetAttr() const;

/// Return true if this argument has the inreg attribute.
bool hasInRegAttr() const;
LLVM_ABI bool hasInRegAttr() const;

/// Return true if this argument has the returned attribute.
bool hasReturnedAttr() const;
LLVM_ABI bool hasReturnedAttr() const;

/// Return true if this argument has the readonly or readnone attribute.
bool onlyReadsMemory() const;
LLVM_ABI bool onlyReadsMemory() const;

/// Return true if this argument has the inalloca attribute.
bool hasInAllocaAttr() const;
LLVM_ABI bool hasInAllocaAttr() const;

/// Return true if this argument has the preallocated attribute.
bool hasPreallocatedAttr() const;
LLVM_ABI bool hasPreallocatedAttr() const;

/// Return true if this argument has the zext attribute.
bool hasZExtAttr() const;
LLVM_ABI bool hasZExtAttr() const;

/// Return true if this argument has the sext attribute.
bool hasSExtAttr() const;
LLVM_ABI bool hasSExtAttr() const;

/// Add attributes to an argument.
void addAttrs(AttrBuilder &B);
LLVM_ABI void addAttrs(AttrBuilder &B);

void addAttr(Attribute::AttrKind Kind);
LLVM_ABI void addAttr(Attribute::AttrKind Kind);

void addAttr(Attribute Attr);
LLVM_ABI void addAttr(Attribute Attr);

/// Remove attributes from an argument.
void removeAttr(Attribute::AttrKind Kind);
LLVM_ABI void removeAttr(Attribute::AttrKind Kind);

void removeAttrs(const AttributeMask &AM);
LLVM_ABI void removeAttrs(const AttributeMask &AM);

/// Check if an argument has a given attribute.
bool hasAttribute(Attribute::AttrKind Kind) const;
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const;

bool hasAttribute(StringRef Kind) const;
LLVM_ABI bool hasAttribute(StringRef Kind) const;

Attribute getAttribute(Attribute::AttrKind Kind) const;
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const;

AttributeSet getAttributes() const;
LLVM_ABI AttributeSet getAttributes() const;

/// Method for support type inquiry through isa, cast, and dyn_cast.
static bool classof(const Value *V) {
Expand Down
4 changes: 3 additions & 1 deletion llvm/include/llvm/IR/AssemblyAnnotationWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#ifndef LLVM_IR_ASSEMBLYANNOTATIONWRITER_H
#define LLVM_IR_ASSEMBLYANNOTATIONWRITER_H

#include "llvm/Support/Compiler.h"

namespace llvm {

class Function;
Expand All @@ -24,7 +26,7 @@ class Instruction;
class Value;
class formatted_raw_ostream;

class AssemblyAnnotationWriter {
class LLVM_ABI AssemblyAnnotationWriter {
public:
virtual ~AssemblyAnnotationWriter();

Expand Down
21 changes: 12 additions & 9 deletions llvm/include/llvm/IR/Assumptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

Expand All @@ -29,7 +30,7 @@ constexpr StringRef AssumptionAttrKey = "llvm.assume";

/// A set of known assumption strings that are accepted without warning and
/// which can be recommended as typo correction.
extern StringSet<> KnownAssumptionStrings;
LLVM_ABI extern StringSet<> KnownAssumptionStrings;

/// Helper that allows to insert a new assumption string in the known assumption
/// set by creating a (static) object.
Expand All @@ -49,25 +50,27 @@ struct KnownAssumptionString {
};

/// Return true if \p F has the assumption \p AssumptionStr attached.
bool hasAssumption(const Function &F,
const KnownAssumptionString &AssumptionStr);
LLVM_ABI bool hasAssumption(const Function &F,
const KnownAssumptionString &AssumptionStr);

/// Return true if \p CB or the callee has the assumption \p AssumptionStr
/// attached.
bool hasAssumption(const CallBase &CB,
const KnownAssumptionString &AssumptionStr);
LLVM_ABI bool hasAssumption(const CallBase &CB,
const KnownAssumptionString &AssumptionStr);

/// Return the set of all assumptions for the function \p F.
DenseSet<StringRef> getAssumptions(const Function &F);
LLVM_ABI DenseSet<StringRef> getAssumptions(const Function &F);

/// Return the set of all assumptions for the call \p CB.
DenseSet<StringRef> getAssumptions(const CallBase &CB);
LLVM_ABI DenseSet<StringRef> getAssumptions(const CallBase &CB);

/// Appends the set of assumptions \p Assumptions to \F.
bool addAssumptions(Function &F, const DenseSet<StringRef> &Assumptions);
LLVM_ABI bool addAssumptions(Function &F,
const DenseSet<StringRef> &Assumptions);

/// Appends the set of assumptions \p Assumptions to \CB.
bool addAssumptions(CallBase &CB, const DenseSet<StringRef> &Assumptions);
LLVM_ABI bool addAssumptions(CallBase &CB,
const DenseSet<StringRef> &Assumptions);

} // namespace llvm

Expand Down
Loading
Loading