Skip to content

[llvm] annotate interfaces in llvm/LTO for DLL export #142499

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

#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBufferRef.h"
#include <memory>
Expand All @@ -24,7 +25,7 @@ namespace ifs {
struct IFSStub;

/// Attempt to read a binary ELF file from a MemoryBuffer.
Expected<std::unique_ptr<IFSStub>> readELFFile(MemoryBufferRef Buf);
LLVM_ABI Expected<std::unique_ptr<IFSStub>> readELFFile(MemoryBufferRef Buf);

/// Attempt to write a binary ELF stub.
/// This function determines appropriate ELFType using the passed ELFTarget and
Expand All @@ -34,8 +35,8 @@ Expected<std::unique_ptr<IFSStub>> readELFFile(MemoryBufferRef Buf);
/// @param Stub Source ELFStub to generate a binary ELF stub from.
/// @param WriteIfChanged Whether or not to preserve timestamp if
/// the output stays the same.
Error writeBinaryStub(StringRef FilePath, const IFSStub &Stub,
bool WriteIfChanged = false);
LLVM_ABI Error writeBinaryStub(StringRef FilePath, const IFSStub &Stub,
bool WriteIfChanged = false);

} // end namespace ifs
} // end namespace llvm
Expand Down
26 changes: 14 additions & 12 deletions llvm/include/llvm/InterfaceStub/IFSHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#define LLVM_INTERFACESTUB_IFSHANDLER_H

#include "IFSStub.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/VersionTuple.h"
#include <memory>
Expand All @@ -36,29 +37,30 @@ struct IFSStub;
const VersionTuple IFSVersionCurrent(3, 0);

/// Attempts to read an IFS interface file from a StringRef buffer.
Expected<std::unique_ptr<IFSStub>> readIFSFromBuffer(StringRef Buf);
LLVM_ABI Expected<std::unique_ptr<IFSStub>> readIFSFromBuffer(StringRef Buf);

/// Attempts to write an IFS interface file to a raw_ostream.
Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub);
LLVM_ABI Error writeIFSToOutputStream(raw_ostream &OS, const IFSStub &Stub);

/// Override the target platform inforation in the text stub.
Error overrideIFSTarget(IFSStub &Stub, std::optional<IFSArch> OverrideArch,
std::optional<IFSEndiannessType> OverrideEndianness,
std::optional<IFSBitWidthType> OverrideBitWidth,
std::optional<std::string> OverrideTriple);
LLVM_ABI Error
overrideIFSTarget(IFSStub &Stub, std::optional<IFSArch> OverrideArch,
std::optional<IFSEndiannessType> OverrideEndianness,
std::optional<IFSBitWidthType> OverrideBitWidth,
std::optional<std::string> OverrideTriple);

/// Validate the target platform inforation in the text stub.
Error validateIFSTarget(IFSStub &Stub, bool ParseTriple);
LLVM_ABI Error validateIFSTarget(IFSStub &Stub, bool ParseTriple);

/// Strips target platform information from the text stub.
void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
bool StripEndianness, bool StripBitWidth);
LLVM_ABI void stripIFSTarget(IFSStub &Stub, bool StripTriple, bool StripArch,
bool StripEndianness, bool StripBitWidth);

Error filterIFSSyms(IFSStub &Stub, bool StripUndefined,
const std::vector<std::string> &Exclude = {});
LLVM_ABI Error filterIFSSyms(IFSStub &Stub, bool StripUndefined,
const std::vector<std::string> &Exclude = {});

/// Parse llvm triple string into a IFSTarget struct.
IFSTarget parseTriple(StringRef TripleStr);
LLVM_ABI IFSTarget parseTriple(StringRef TripleStr);

} // end namespace ifs
} // end namespace llvm
Expand Down
25 changes: 13 additions & 12 deletions llvm/include/llvm/InterfaceStub/IFSStub.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#ifndef LLVM_INTERFACESTUB_IFSSTUB_H
#define LLVM_INTERFACESTUB_IFSSTUB_H

#include "llvm/Support/Compiler.h"
#include "llvm/Support/VersionTuple.h"
#include <optional>
#include <vector>
Expand Down Expand Up @@ -69,7 +70,7 @@ struct IFSTarget {
std::optional<IFSEndiannessType> Endianness;
std::optional<IFSBitWidthType> BitWidth;

bool empty();
LLVM_ABI bool empty();
};

inline bool operator==(const IFSTarget &Lhs, const IFSTarget &Rhs) {
Expand All @@ -95,8 +96,8 @@ struct IFSStub {
std::vector<IFSSymbol> Symbols;

IFSStub() = default;
IFSStub(const IFSStub &Stub);
IFSStub(IFSStub &&Stub);
LLVM_ABI IFSStub(const IFSStub &Stub);
LLVM_ABI IFSStub(IFSStub &&Stub);
virtual ~IFSStub() = default;
};

Expand All @@ -107,50 +108,50 @@ struct IFSStub {
// structure can be used for 2 different yaml schema.
struct IFSStubTriple : IFSStub {
IFSStubTriple() = default;
IFSStubTriple(const IFSStub &Stub);
IFSStubTriple(const IFSStubTriple &Stub);
IFSStubTriple(IFSStubTriple &&Stub);
LLVM_ABI IFSStubTriple(const IFSStub &Stub);
LLVM_ABI IFSStubTriple(const IFSStubTriple &Stub);
LLVM_ABI IFSStubTriple(IFSStubTriple &&Stub);
};

/// This function convert bit width type from IFS enum to ELF format
/// Currently, ELFCLASS32 and ELFCLASS64 are supported.
///
/// @param BitWidth IFS bit width type.
uint8_t convertIFSBitWidthToELF(IFSBitWidthType BitWidth);
LLVM_ABI uint8_t convertIFSBitWidthToELF(IFSBitWidthType BitWidth);

/// This function convert endianness type from IFS enum to ELF format
/// Currently, ELFDATA2LSB and ELFDATA2MSB are supported.
///
/// @param Endianness IFS endianness type.
uint8_t convertIFSEndiannessToELF(IFSEndiannessType Endianness);
LLVM_ABI uint8_t convertIFSEndiannessToELF(IFSEndiannessType Endianness);

/// This function convert symbol type from IFS enum to ELF format
/// Currently, STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_TLS are supported.
///
/// @param SymbolType IFS symbol type.
uint8_t convertIFSSymbolTypeToELF(IFSSymbolType SymbolType);
LLVM_ABI uint8_t convertIFSSymbolTypeToELF(IFSSymbolType SymbolType);

/// This function extracts ELF bit width from e_ident[EI_CLASS] of an ELF file
/// Currently, ELFCLASS32 and ELFCLASS64 are supported.
/// Other endianness types are mapped to IFSBitWidthType::Unknown.
///
/// @param BitWidth e_ident[EI_CLASS] value to extract bit width from.
IFSBitWidthType convertELFBitWidthToIFS(uint8_t BitWidth);
LLVM_ABI IFSBitWidthType convertELFBitWidthToIFS(uint8_t BitWidth);

/// This function extracts ELF endianness from e_ident[EI_DATA] of an ELF file
/// Currently, ELFDATA2LSB and ELFDATA2MSB are supported.
/// Other endianness types are mapped to IFSEndiannessType::Unknown.
///
/// @param Endianness e_ident[EI_DATA] value to extract endianness type from.
IFSEndiannessType convertELFEndiannessToIFS(uint8_t Endianness);
LLVM_ABI IFSEndiannessType convertELFEndiannessToIFS(uint8_t Endianness);

/// This function extracts symbol type from a symbol's st_info member and
/// maps it to an IFSSymbolType enum.
/// Currently, STT_NOTYPE, STT_OBJECT, STT_FUNC, and STT_TLS are supported.
/// Other symbol types are mapped to IFSSymbolType::Unknown.
///
/// @param SymbolType Binary symbol st_info to extract symbol type from.
IFSSymbolType convertELFSymbolTypeToIFS(uint8_t SymbolType);
LLVM_ABI IFSSymbolType convertELFSymbolTypeToIFS(uint8_t SymbolType);
} // namespace ifs
} // end namespace llvm

Expand Down
7 changes: 4 additions & 3 deletions llvm/include/llvm/LTO/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Target/TargetOptions.h"

#include <functional>
Expand Down Expand Up @@ -277,9 +278,9 @@ struct Config {
///
/// SaveTempsArgs can be specified to select which temps to save.
/// If SaveTempsArgs is not provided, all temps are saved.
Error addSaveTemps(std::string OutputFileName,
bool UseInputModulePath = false,
const DenseSet<StringRef> &SaveTempsArgs = {});
LLVM_ABI Error addSaveTemps(std::string OutputFileName,
bool UseInputModulePath = false,
const DenseSet<StringRef> &SaveTempsArgs = {});
};

struct LTOLLVMDiagnosticHandler : public DiagnosticHandler {
Expand Down
Loading
Loading