Skip to content

[llvm] annotate interfaces in FileCheck, FrontEnd, and FuzzMutate libraries for DLL export #141864

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 4 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
30 changes: 16 additions & 14 deletions llvm/include/llvm/FileCheck/FileCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define LLVM_FILECHECK_FILECHECK_H

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/SMLoc.h"
#include <bitset>
Expand Down Expand Up @@ -91,7 +92,7 @@ class FileCheckType {
operator FileCheckKind() const { return Kind; }

int getCount() const { return Count; }
FileCheckType &setCount(int C);
LLVM_ABI FileCheckType &setCount(int C);

bool isLiteralMatch() const {
return Modifiers[FileCheckKindModifier::ModifierLiteral];
Expand All @@ -102,10 +103,10 @@ class FileCheckType {
}

// \returns a description of \p Prefix.
std::string getDescription(StringRef Prefix) const;
LLVM_ABI std::string getDescription(StringRef Prefix) const;

// \returns a description of \p Modifiers.
std::string getModifiersDescription() const;
LLVM_ABI std::string getModifiersDescription() const;
};
} // namespace Check

Expand Down Expand Up @@ -167,9 +168,10 @@ struct FileCheckDiag {
/// A note to replace the one normally indicated by MatchTy, or the empty
/// string if none.
std::string Note;
FileCheckDiag(const SourceMgr &SM, const Check::FileCheckType &CheckTy,
SMLoc CheckLoc, MatchType MatchTy, SMRange InputRange,
StringRef Note = "");
LLVM_ABI FileCheckDiag(const SourceMgr &SM,
const Check::FileCheckType &CheckTy, SMLoc CheckLoc,
MatchType MatchTy, SMRange InputRange,
StringRef Note = "");
};

class FileCheckPatternContext;
Expand All @@ -183,33 +185,33 @@ class FileCheck {
std::vector<FileCheckString> CheckStrings;

public:
explicit FileCheck(FileCheckRequest Req);
~FileCheck();
LLVM_ABI explicit FileCheck(FileCheckRequest Req);
LLVM_ABI ~FileCheck();

/// Reads the check file from \p Buffer and records the expected strings it
/// contains. Errors are reported against \p SM.
///
/// If \p ImpPatBufferIDRange, then the range (inclusive start, exclusive end)
/// of IDs for source buffers added to \p SM for implicit patterns are
/// recorded in it. The range is empty if there are none.
bool
LLVM_ABI bool
readCheckFile(SourceMgr &SM, StringRef Buffer,
std::pair<unsigned, unsigned> *ImpPatBufferIDRange = nullptr);

bool ValidateCheckPrefixes();
LLVM_ABI bool ValidateCheckPrefixes();

/// Canonicalizes whitespaces in the file. Line endings are replaced with
/// UNIX-style '\n'.
StringRef CanonicalizeFile(MemoryBuffer &MB,
SmallVectorImpl<char> &OutputBuffer);
LLVM_ABI StringRef CanonicalizeFile(MemoryBuffer &MB,
SmallVectorImpl<char> &OutputBuffer);

/// Checks the input to FileCheck provided in the \p Buffer against the
/// expected strings read from the check file and record diagnostics emitted
/// in \p Diags. Errors are recorded against \p SM.
///
/// \returns false if the input fails to satisfy the checks.
bool checkInput(SourceMgr &SM, StringRef Buffer,
std::vector<FileCheckDiag> *Diags = nullptr);
LLVM_ABI bool checkInput(SourceMgr &SM, StringRef Buffer,
std::vector<FileCheckDiag> *Diags = nullptr);
};

} // namespace llvm
Expand Down
22 changes: 12 additions & 10 deletions llvm/include/llvm/Frontend/Atomic/Atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Compiler.h"

namespace llvm {
class AtomicInfo {
Expand Down Expand Up @@ -55,13 +56,13 @@ class AtomicInfo {

LLVMContext &getLLVMContext() const { return Builder->getContext(); }

bool shouldCastToInt(Type *ValTy, bool CmpXchg);
LLVM_ABI bool shouldCastToInt(Type *ValTy, bool CmpXchg);

Value *EmitAtomicLoadOp(AtomicOrdering AO, bool IsVolatile,
bool CmpXchg = false);
LLVM_ABI Value *EmitAtomicLoadOp(AtomicOrdering AO, bool IsVolatile,
bool CmpXchg = false);

CallInst *EmitAtomicLibcall(StringRef fnName, Type *ResultType,
ArrayRef<Value *> Args);
LLVM_ABI CallInst *EmitAtomicLibcall(StringRef fnName, Type *ResultType,
ArrayRef<Value *> Args);

Value *getAtomicSizeValue() const {
LLVMContext &ctx = getLLVMContext();
Expand All @@ -73,7 +74,7 @@ class AtomicInfo {
AtomicSizeInBits / BitsPerByte);
}

std::pair<Value *, Value *>
LLVM_ABI std::pair<Value *, Value *>
EmitAtomicCompareExchangeLibcall(Value *ExpectedVal, Value *DesiredVal,
AtomicOrdering Success,
AtomicOrdering Failure);
Expand All @@ -86,19 +87,20 @@ class AtomicInfo {
return castToAtomicIntPointer(getAtomicPointer());
}

std::pair<Value *, Value *>
LLVM_ABI std::pair<Value *, Value *>
EmitAtomicCompareExchangeOp(Value *ExpectedVal, Value *DesiredVal,
AtomicOrdering Success, AtomicOrdering Failure,
bool IsVolatile = false, bool IsWeak = false);

std::pair<Value *, Value *>
LLVM_ABI std::pair<Value *, Value *>
EmitAtomicCompareExchange(Value *ExpectedVal, Value *DesiredVal,
AtomicOrdering Success, AtomicOrdering Failure,
bool IsVolatile, bool IsWeak);

std::pair<LoadInst *, AllocaInst *> EmitAtomicLoadLibcall(AtomicOrdering AO);
LLVM_ABI std::pair<LoadInst *, AllocaInst *>
EmitAtomicLoadLibcall(AtomicOrdering AO);

void EmitAtomicStoreLibcall(AtomicOrdering AO, Value *Source);
LLVM_ABI void EmitAtomicStoreLibcall(AtomicOrdering AO, Value *Source);
};
} // end namespace llvm

Expand Down
6 changes: 4 additions & 2 deletions llvm/include/llvm/Frontend/Driver/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#ifndef LLVM_FRONTEND_DRIVER_CODEGENOPTIONS_H
#define LLVM_FRONTEND_DRIVER_CODEGENOPTIONS_H

#include "llvm/Support/Compiler.h"

namespace llvm {
class Triple;
class TargetLibraryInfoImpl;
Expand Down Expand Up @@ -46,8 +48,8 @@ enum class VectorLibrary {
AMDLIBM // AMD vector math library.
};

TargetLibraryInfoImpl *createTLII(const llvm::Triple &TargetTriple,
VectorLibrary Veclib);
LLVM_ABI TargetLibraryInfoImpl *createTLII(const llvm::Triple &TargetTriple,
VectorLibrary Veclib);

} // end namespace llvm::driver

Expand Down
10 changes: 6 additions & 4 deletions llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#define LLVM_FRONTEND_HLSL_HLSLROOTSIGNATURE_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/raw_ostream.h"
#include <variant>
Expand Down Expand Up @@ -123,7 +124,7 @@ struct DescriptorTable {
uint32_t NumClauses = 0;
};

raw_ostream &operator<<(raw_ostream &OS, const DescriptorTable &Table);
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const DescriptorTable &Table);

static const uint32_t NumDescriptorsUnbounded = 0xffffffff;
static const uint32_t DescriptorTableOffsetAppend = 0xffffffff;
Expand Down Expand Up @@ -153,7 +154,8 @@ struct DescriptorTableClause {
}
};

raw_ostream &operator<<(raw_ostream &OS, const DescriptorTableClause &Clause);
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
const DescriptorTableClause &Clause);

struct StaticSampler {
Register Reg;
Expand All @@ -179,7 +181,7 @@ using RootElement =
std::variant<RootFlags, RootConstants, RootDescriptor, DescriptorTable,
DescriptorTableClause, StaticSampler>;

void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements);
LLVM_ABI void dumpRootElements(raw_ostream &OS, ArrayRef<RootElement> Elements);

class MetadataBuilder {
public:
Expand All @@ -190,7 +192,7 @@ class MetadataBuilder {
///
/// Accumulates the root signature and returns the Metadata node that is just
/// a list of all the elements
MDNode *BuildRootSignature();
LLVM_ABI MDNode *BuildRootSignature();

private:
/// Define the various builders for the different metadata types
Expand Down
25 changes: 14 additions & 11 deletions llvm/include/llvm/Frontend/Offloading/OffloadWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "llvm/ADT/ArrayRef.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Compiler.h"

namespace llvm {
namespace offloading {
Expand All @@ -22,11 +23,10 @@ using EntryArrayTy = std::pair<GlobalVariable *, GlobalVariable *>;
/// \param Suffix An optional suffix appended to the emitted symbols.
/// \param Relocatable Indicate if we need to change the offloading section to
/// create a relocatable object.
llvm::Error wrapOpenMPBinaries(llvm::Module &M,
llvm::ArrayRef<llvm::ArrayRef<char>> Images,
EntryArrayTy EntryArray,
llvm::StringRef Suffix = "",
bool Relocatable = false);
LLVM_ABI llvm::Error
wrapOpenMPBinaries(llvm::Module &M, llvm::ArrayRef<llvm::ArrayRef<char>> Images,
EntryArrayTy EntryArray, llvm::StringRef Suffix = "",
bool Relocatable = false);

/// Wraps the input fatbinary image into the module \p M as global symbols and
/// registers the images with the CUDA runtime.
Expand All @@ -35,9 +35,11 @@ llvm::Error wrapOpenMPBinaries(llvm::Module &M,
/// \param Suffix An optional suffix appended to the emitted symbols.
/// \param EmitSurfacesAndTextures Whether to emit surface and textures
/// registration code. It defaults to false.
llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images,
EntryArrayTy EntryArray, llvm::StringRef Suffix = "",
bool EmitSurfacesAndTextures = true);
LLVM_ABI llvm::Error wrapCudaBinary(llvm::Module &M,
llvm::ArrayRef<char> Images,
EntryArrayTy EntryArray,
llvm::StringRef Suffix = "",
bool EmitSurfacesAndTextures = true);

/// Wraps the input bundled image into the module \p M as global symbols and
/// registers the images with the HIP runtime.
Expand All @@ -46,9 +48,10 @@ llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef<char> Images,
/// \param Suffix An optional suffix appended to the emitted symbols.
/// \param EmitSurfacesAndTextures Whether to emit surface and textures
/// registration code. It defaults to false.
llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images,
EntryArrayTy EntryArray, llvm::StringRef Suffix = "",
bool EmitSurfacesAndTextures = true);
LLVM_ABI llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef<char> Images,
EntryArrayTy EntryArray,
llvm::StringRef Suffix = "",
bool EmitSurfacesAndTextures = true);
} // namespace offloading
} // namespace llvm

Expand Down
29 changes: 16 additions & 13 deletions llvm/include/llvm/Frontend/Offloading/Utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#ifndef LLVM_FRONTEND_OFFLOADING_UTILITY_H
#define LLVM_FRONTEND_OFFLOADING_UTILITY_H

#include "llvm/Support/Compiler.h"
#include <cstdint>
#include <memory>

Expand Down Expand Up @@ -67,7 +68,7 @@ enum OffloadEntryKindFlag : uint32_t {

/// Returns the type of the offloading entry we use to store kernels and
/// globals that will be registered with the offloading runtime.
StructType *getEntryTy(Module &M);
LLVM_ABI StructType *getEntryTy(Module &M);

/// Create an offloading section struct used to register this global at
/// runtime.
Expand All @@ -81,22 +82,23 @@ StructType *getEntryTy(Module &M);
/// \param Data Extra data storage associated with the entry.
/// \param SectionName The section this entry will be placed at.
/// \param AuxAddr An extra pointer if needed.
void emitOffloadingEntry(Module &M, object::OffloadKind Kind, Constant *Addr,
StringRef Name, uint64_t Size, uint32_t Flags,
uint64_t Data, Constant *AuxAddr = nullptr,
StringRef SectionName = "llvm_offload_entries");
LLVM_ABI void
emitOffloadingEntry(Module &M, object::OffloadKind Kind, Constant *Addr,
StringRef Name, uint64_t Size, uint32_t Flags,
uint64_t Data, Constant *AuxAddr = nullptr,
StringRef SectionName = "llvm_offload_entries");

/// Create a constant struct initializer used to register this global at
/// runtime.
/// \return the constant struct and the global variable holding the symbol name.
std::pair<Constant *, GlobalVariable *>
LLVM_ABI std::pair<Constant *, GlobalVariable *>
getOffloadingEntryInitializer(Module &M, object::OffloadKind Kind,
Constant *Addr, StringRef Name, uint64_t Size,
uint32_t Flags, uint64_t Data, Constant *AuxAddr);

/// Creates a pair of globals used to iterate the array of offloading entries by
/// accessing the section variables provided by the linker.
std::pair<GlobalVariable *, GlobalVariable *>
LLVM_ABI std::pair<GlobalVariable *, GlobalVariable *>
getOffloadEntryArray(Module &M, StringRef SectionName = "llvm_offload_entries");

namespace amdgpu {
Expand All @@ -109,8 +111,8 @@ namespace amdgpu {
/// and is compatible with either '+' or '-'. The HSA runtime returns this
/// information using the target-id, while we use the ELF header to determine
/// these features.
bool isImageCompatibleWithEnv(StringRef ImageArch, uint32_t ImageFlags,
StringRef EnvTargetID);
LLVM_ABI bool isImageCompatibleWithEnv(StringRef ImageArch, uint32_t ImageFlags,
StringRef EnvTargetID);

/// Struct for holding metadata related to AMDGPU kernels, for more information
/// about the metadata and its meaning see:
Expand Down Expand Up @@ -149,15 +151,16 @@ struct AMDGPUKernelMetaData {

/// Reads AMDGPU specific metadata from the ELF file and propagates the
/// KernelInfoMap.
Error getAMDGPUMetaDataFromImage(MemoryBufferRef MemBuffer,
StringMap<AMDGPUKernelMetaData> &KernelInfoMap,
uint16_t &ELFABIVersion);
LLVM_ABI Error getAMDGPUMetaDataFromImage(
MemoryBufferRef MemBuffer, StringMap<AMDGPUKernelMetaData> &KernelInfoMap,
uint16_t &ELFABIVersion);
} // namespace amdgpu

namespace intel {
/// Containerizes an offloading binary into the ELF binary format expected by
/// the Intel runtime offload plugin.
Error containerizeOpenMPSPIRVImage(std::unique_ptr<MemoryBuffer> &Binary);
LLVM_ABI Error
containerizeOpenMPSPIRVImage(std::unique_ptr<MemoryBuffer> &Binary);
} // namespace intel
} // namespace offloading
} // namespace llvm
Expand Down
22 changes: 12 additions & 10 deletions llvm/include/llvm/Frontend/OpenMP/OMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@
#define LLVM_FRONTEND_OPENMP_OMP_H

#include "llvm/Frontend/OpenMP/OMP.h.inc"
#include "llvm/Support/Compiler.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"

namespace llvm::omp {
ArrayRef<Directive> getLeafConstructs(Directive D);
ArrayRef<Directive> getLeafConstructsOrSelf(Directive D);
LLVM_ABI ArrayRef<Directive> getLeafConstructs(Directive D);
LLVM_ABI ArrayRef<Directive> getLeafConstructsOrSelf(Directive D);

ArrayRef<Directive>
LLVM_ABI ArrayRef<Directive>
getLeafOrCompositeConstructs(Directive D, SmallVectorImpl<Directive> &Output);

Directive getCompoundConstruct(ArrayRef<Directive> Parts);
LLVM_ABI Directive getCompoundConstruct(ArrayRef<Directive> Parts);

bool isLeafConstruct(Directive D);
bool isCompositeConstruct(Directive D);
bool isCombinedConstruct(Directive D);
LLVM_ABI bool isLeafConstruct(Directive D);
LLVM_ABI bool isCompositeConstruct(Directive D);
LLVM_ABI bool isCombinedConstruct(Directive D);

/// Can clause C have an iterator-modifier.
static constexpr inline bool canHaveIterator(Clause C) {
Expand All @@ -48,14 +49,15 @@ static constexpr inline bool canHaveIterator(Clause C) {
}

static constexpr unsigned FallbackVersion = 52;
ArrayRef<unsigned> getOpenMPVersions();
LLVM_ABI ArrayRef<unsigned> getOpenMPVersions();

/// Create a nicer version of a function name for humans to look at.
std::string prettifyFunctionName(StringRef FunctionName);
LLVM_ABI std::string prettifyFunctionName(StringRef FunctionName);

/// Deconstruct an OpenMP kernel name into the parent function name and the line
/// number.
std::string deconstructOpenMPKernelName(StringRef KernelName, unsigned &LineNo);
LLVM_ABI std::string deconstructOpenMPKernelName(StringRef KernelName,
unsigned &LineNo);

} // namespace llvm::omp

Expand Down
Loading