Skip to content

[llvm] annotate remaining LLVM interfaces for DLL export #144746

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "llvm/ProfileData/InstrProfCorrelator.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Program.h"
Expand Down Expand Up @@ -96,8 +97,6 @@ using namespace llvm;
#include "llvm/Support/Extension.def"

namespace llvm {
extern cl::opt<bool> PrintPipelinePasses;

// Experiment to move sanitizers earlier.
static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
"sanitizer-early-opt-ep", cl::Optional,
Expand All @@ -118,7 +117,8 @@ static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr(
clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
"Mark cold functions with optnone.")));

extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate;
LLVM_ABI extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind>
ProfileCorrelate;
} // namespace llvm
namespace clang {
extern llvm::cl::opt<bool> ClSanitizeGuardChecks;
Expand Down
4 changes: 0 additions & 4 deletions flang/lib/Frontend/FrontendActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@
#include <memory>
#include <system_error>

namespace llvm {
extern cl::opt<bool> PrintPipelinePasses;
} // namespace llvm

using namespace Fortran::frontend;

constexpr llvm::StringLiteral timingIdParse = "Parse";
Expand Down
4 changes: 3 additions & 1 deletion llvm/include/llvm/ADT/APFloat.h
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,9 @@ class IEEEFloat final {

integerPart addSignificand(const IEEEFloat &);
integerPart subtractSignificand(const IEEEFloat &, integerPart);
lostFraction addOrSubtractSignificand(const IEEEFloat &, bool subtract);
// Exported for IEEEFloatUnitTestHelper.
LLVM_ABI lostFraction addOrSubtractSignificand(const IEEEFloat &,
bool subtract);
lostFraction multiplySignificand(const IEEEFloat &, IEEEFloat,
bool ignoreAddend = false);
lostFraction multiplySignificand(const IEEEFloat&);
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/APInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ class [[nodiscard]] APInt {
}

/// Overload to compute a hash_code for an APInt value.
friend hash_code hash_value(const APInt &Arg);
LLVM_ABI_FRIEND friend hash_code hash_value(const APInt &Arg);

/// This function returns a pointer to the internal storage of the APInt.
/// This is useful for writing out the APInt in binary form without any
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ADT/DynamicAPInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class DynamicAPInt {
friend DynamicAPInt operator/(int64_t A, const DynamicAPInt &B);
friend DynamicAPInt operator%(int64_t A, const DynamicAPInt &B);

friend hash_code hash_value(const DynamicAPInt &x); // NOLINT
LLVM_ABI_FRIEND friend hash_code hash_value(const DynamicAPInt &x); // NOLINT

LLVM_ABI void static_assert_layout(); // NOLINT

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/DXILResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace dxil {

// Returns the resource name from dx_resource_handlefrombinding or
// dx_resource_handlefromimplicitbinding call
StringRef getResourceNameFromBindingCall(CallInst *CI);
LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI);

/// The dx.RawBuffer target extension type
///
Expand Down
52 changes: 27 additions & 25 deletions llvm/include/llvm/Analysis/IR2Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/JSON.h"
#include <map>
Expand All @@ -57,9 +58,9 @@ enum class IR2VecKind { Symbolic };

namespace ir2vec {

extern cl::opt<float> OpcWeight;
extern cl::opt<float> TypeWeight;
extern cl::opt<float> ArgWeight;
LLVM_ABI extern cl::opt<float> OpcWeight;
LLVM_ABI extern cl::opt<float> TypeWeight;
LLVM_ABI extern cl::opt<float> ArgWeight;

/// Embedding is a datatype that wraps std::vector<double>. It provides
/// additional functionality for arithmetic and comparison operations.
Expand Down Expand Up @@ -106,16 +107,17 @@ struct Embedding {
const std::vector<double> &getData() const { return Data; }

/// Arithmetic operators
Embedding &operator+=(const Embedding &RHS);
Embedding &operator-=(const Embedding &RHS);
LLVM_ABI Embedding &operator+=(const Embedding &RHS);
LLVM_ABI Embedding &operator-=(const Embedding &RHS);

/// Adds Src Embedding scaled by Factor with the called Embedding.
/// Called_Embedding += Src * Factor
Embedding &scaleAndAdd(const Embedding &Src, float Factor);
LLVM_ABI Embedding &scaleAndAdd(const Embedding &Src, float Factor);

/// Returns true if the embedding is approximately equal to the RHS embedding
/// within the specified tolerance.
bool approximatelyEquals(const Embedding &RHS, double Tolerance = 1e-6) const;
LLVM_ABI bool approximatelyEquals(const Embedding &RHS,
double Tolerance = 1e-6) const;
};

using InstEmbeddingsMap = DenseMap<const Instruction *, Embedding>;
Expand Down Expand Up @@ -148,7 +150,7 @@ class Embedder {
mutable BBEmbeddingsMap BBVecMap;
mutable InstEmbeddingsMap InstVecMap;

Embedder(const Function &F, const Vocab &Vocabulary);
LLVM_ABI Embedder(const Function &F, const Vocab &Vocabulary);

/// Helper function to compute embeddings. It generates embeddings for all
/// the instructions and basic blocks in the function F. Logic of computing
Expand All @@ -161,38 +163,38 @@ class Embedder {

/// Lookup vocabulary for a given Key. If the key is not found, it returns a
/// zero vector.
Embedding lookupVocab(const std::string &Key) const;
LLVM_ABI Embedding lookupVocab(const std::string &Key) const;

public:
virtual ~Embedder() = default;

/// Factory method to create an Embedder object.
static Expected<std::unique_ptr<Embedder>>
LLVM_ABI static Expected<std::unique_ptr<Embedder>>
create(IR2VecKind Mode, const Function &F, const Vocab &Vocabulary);

/// Returns a map containing instructions and the corresponding embeddings for
/// the function F if it has been computed. If not, it computes the embeddings
/// for the function and returns the map.
const InstEmbeddingsMap &getInstVecMap() const;
LLVM_ABI const InstEmbeddingsMap &getInstVecMap() const;

/// Returns a map containing basic block and the corresponding embeddings for
/// the function F if it has been computed. If not, it computes the embeddings
/// for the function and returns the map.
const BBEmbeddingsMap &getBBVecMap() const;
LLVM_ABI const BBEmbeddingsMap &getBBVecMap() const;

/// Returns the embedding for a given basic block in the function F if it has
/// been computed. If not, it computes the embedding for the basic block and
/// returns it.
const Embedding &getBBVector(const BasicBlock &BB) const;
LLVM_ABI const Embedding &getBBVector(const BasicBlock &BB) const;

/// Computes and returns the embedding for the current function.
const Embedding &getFunctionVector() const;
LLVM_ABI const Embedding &getFunctionVector() const;
};

/// Class for computing the Symbolic embeddings of IR2Vec.
/// Symbolic embeddings are constructed based on the entity-level
/// representations obtained from the Vocabulary.
class SymbolicEmbedder : public Embedder {
class LLVM_ABI SymbolicEmbedder : public Embedder {
private:
/// Utility function to compute the embedding for a given type.
Embedding getTypeEmbedding(const Type *Ty) const;
Expand All @@ -219,13 +221,13 @@ class IR2VecVocabResult {

public:
IR2VecVocabResult() = default;
IR2VecVocabResult(ir2vec::Vocab &&Vocabulary);
LLVM_ABI IR2VecVocabResult(ir2vec::Vocab &&Vocabulary);

bool isValid() const { return Valid; }
const ir2vec::Vocab &getVocabulary() const;
unsigned getDimension() const;
bool invalidate(Module &M, const PreservedAnalyses &PA,
ModuleAnalysisManager::Invalidator &Inv) const;
LLVM_ABI const ir2vec::Vocab &getVocabulary() const;
LLVM_ABI unsigned getDimension() const;
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
ModuleAnalysisManager::Invalidator &Inv) const;
};

/// This analysis provides the vocabulary for IR2Vec. The vocabulary provides a
Expand All @@ -237,12 +239,12 @@ class IR2VecVocabAnalysis : public AnalysisInfoMixin<IR2VecVocabAnalysis> {
void emitError(Error Err, LLVMContext &Ctx);

public:
static AnalysisKey Key;
LLVM_ABI static AnalysisKey Key;
IR2VecVocabAnalysis() = default;
explicit IR2VecVocabAnalysis(const ir2vec::Vocab &Vocab);
explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
LLVM_ABI explicit IR2VecVocabAnalysis(const ir2vec::Vocab &Vocab);
LLVM_ABI explicit IR2VecVocabAnalysis(ir2vec::Vocab &&Vocab);
using Result = IR2VecVocabResult;
Result run(Module &M, ModuleAnalysisManager &MAM);
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &MAM);
};

/// This pass prints the IR2Vec embeddings for instructions, basic blocks, and
Expand All @@ -253,7 +255,7 @@ class IR2VecPrinterPass : public PassInfoMixin<IR2VecPrinterPass> {

public:
explicit IR2VecPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
static bool isRequired() { return true; }
};

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Analysis/ValueTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ LLVM_ABI std::optional<bool> computeKnownFPSignBit(const Value *V,

/// Return true if the sign bit of the FP value can be ignored by the user when
/// the value is zero.
bool canIgnoreSignBitOfZero(const Use &U);
LLVM_ABI bool canIgnoreSignBitOfZero(const Use &U);

/// Return true if the sign bit of the FP value can be ignored by the user when
/// the value is NaN.
bool canIgnoreSignBitOfNaN(const Use &U);
LLVM_ABI bool canIgnoreSignBitOfNaN(const Use &U);

/// If the specified value can be set by repeating the same byte in memory,
/// return the i8 value that it is represented with. This is true for all i8
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/BinaryFormat/DXContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ enum class DescriptorRangeType : uint32_t {
#include "DXContainerConstants.def"
};

ArrayRef<EnumEntry<DescriptorRangeType>> getDescriptorRangeTypes();
LLVM_ABI ArrayRef<EnumEntry<DescriptorRangeType>> getDescriptorRangeTypes();

#define ROOT_PARAMETER(Val, Enum) \
case Val: \
Expand Down
9 changes: 9 additions & 0 deletions llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,15 @@ class LLVM_ABI CallLowering {
virtual bool isTypeIsValidForThisReturn(EVT Ty) const { return false; }
};

extern template LLVM_ABI void
CallLowering::setArgFlags<Function>(CallLowering::ArgInfo &Arg, unsigned OpIdx,
const DataLayout &DL,
const Function &FuncInfo) const;

extern template LLVM_ABI void
CallLowering::setArgFlags<CallBase>(CallLowering::ArgInfo &Arg, unsigned OpIdx,
const DataLayout &DL,
const CallBase &FuncInfo) const;
} // end namespace llvm

#endif // LLVM_CODEGEN_GLOBALISEL_CALLLOWERING_H
5 changes: 3 additions & 2 deletions llvm/include/llvm/CodeGenTypes/LowLevelType.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "llvm/ADT/DenseMapInfo.h"
#include "llvm/CodeGenTypes/MachineValueType.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include <cassert>

Expand Down Expand Up @@ -140,7 +141,7 @@ class LLT {
explicit constexpr LLT()
: IsScalar(false), IsPointer(false), IsVector(false), RawData(0) {}

explicit LLT(MVT VT);
LLVM_ABI explicit LLT(MVT VT);

constexpr bool isValid() const { return IsScalar || RawData != 0; }
constexpr bool isScalar() const { return IsScalar; }
Expand Down Expand Up @@ -282,7 +283,7 @@ class LLT {
return scalar(getScalarSizeInBits());
}

void print(raw_ostream &OS) const;
LLVM_ABI void print(raw_ostream &OS) const;

#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void dump() const;
Expand Down
9 changes: 5 additions & 4 deletions llvm/include/llvm/CodeGenTypes/MachineValueType.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define LLVM_CODEGEN_MACHINEVALUETYPE_H

#include "llvm/ADT/Sequence.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/TypeSize.h"
Expand Down Expand Up @@ -65,10 +66,10 @@ namespace llvm {
bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }

/// Support for debugging, callable in GDB: VT.dump()
void dump() const;
LLVM_ABI void dump() const;

/// Implement operator<<.
void print(raw_ostream &OS) const;
LLVM_ABI void print(raw_ostream &OS) const;

/// Return true if this is a valid simple valuetype.
bool isValid() const {
Expand Down Expand Up @@ -509,11 +510,11 @@ namespace llvm {
/// otherwise they are invalid.
/// NB: This includes pointer types, which require a DataLayout to convert
/// to a concrete value type.
static MVT getVT(Type *Ty, bool HandleUnknown = false);
LLVM_ABI static MVT getVT(Type *Ty, bool HandleUnknown = false);

/// Returns an APFloat semantics tag appropriate for the value type. If this
/// is a vector type, the element semantics are returned.
const fltSemantics &getFltSemantics() const;
LLVM_ABI const fltSemantics &getFltSemantics() const;

public:
/// SimpleValueType Iteration
Expand Down
8 changes: 5 additions & 3 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFCFIPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
#define LLVM_DEBUGINFO_DWARF_DWARFCFIPRINTER_H

#include "llvm/DebugInfo/DWARF/DWARFCFIProgram.h"
#include "llvm/Support/Compiler.h"

namespace llvm {

struct DIDumpOptions;

namespace dwarf {

void printCFIProgram(const CFIProgram &P, raw_ostream &OS,
const DIDumpOptions &DumpOpts, unsigned IndentLevel,
std::optional<uint64_t> Address);
LLVM_ABI void printCFIProgram(const CFIProgram &P, raw_ostream &OS,
const DIDumpOptions &DumpOpts,
unsigned IndentLevel,
std::optional<uint64_t> Address);

} // end namespace dwarf

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFCFIProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ class CFIProgram {
};

/// Get the OperandType as a "const char *".
static const char *operandTypeString(OperandType OT);
LLVM_ABI static const char *operandTypeString(OperandType OT);

/// Retrieve the array describing the types of operands according to the enum
/// above. This is indexed by opcode.
static ArrayRef<OperandType[MaxOperands]> getOperandTypes();
LLVM_ABI static ArrayRef<OperandType[MaxOperands]> getOperandTypes();

private:
std::vector<Instruction> Instructions;
Expand Down
19 changes: 11 additions & 8 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,9 @@ class DWARFExpressionPrinter {
/// \param E to be printed
/// \param OS to this stream
/// \param GetNameForDWARFReg callback to return dwarf register name
static void print(const DWARFExpression *E, raw_ostream &OS,
DIDumpOptions DumpOpts, DWARFUnit *U, bool IsEH = false);
LLVM_ABI static void print(const DWARFExpression *E, raw_ostream &OS,
DIDumpOptions DumpOpts, DWARFUnit *U,
bool IsEH = false);

/// Print the expression in a format intended to be compact and useful to a
/// user, but not perfectly unambiguous, or capable of representing every
Expand All @@ -199,9 +200,10 @@ class DWARFExpressionPrinter {
/// \param GetNameForDWARFReg callback to return dwarf register name
///
/// \returns true if the expression was successfully printed
static bool printCompact(const DWARFExpression *E, raw_ostream &OS,
std::function<StringRef(uint64_t RegNum, bool IsEH)>
GetNameForDWARFReg = nullptr);
LLVM_ABI static bool printCompact(
const DWARFExpression *E, raw_ostream &OS,
std::function<StringRef(uint64_t RegNum, bool IsEH)> GetNameForDWARFReg =
nullptr);

/// Pretty print a register opcode and operands.
/// \param U within the context of this Dwarf unit, if any.
Expand All @@ -211,9 +213,10 @@ class DWARFExpressionPrinter {
/// \param Operands to the opcode
///
/// returns true if the Op was successfully printed
static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS,
DIDumpOptions DumpOpts, uint8_t Opcode,
ArrayRef<uint64_t> Operands);
LLVM_ABI static bool prettyPrintRegisterOp(DWARFUnit *U, raw_ostream &OS,
DIDumpOptions DumpOpts,
uint8_t Opcode,
ArrayRef<uint64_t> Operands);

private:
static bool printOp(const DWARFExpression::Operation *Op, raw_ostream &OS,
Expand Down
Loading
Loading