Skip to content

Commit 7e928f9

Browse files
authored
[llvm] fix missing and incorrect LLVM_ABI annotations (#147399)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch adds `LLVM_ABI` annotations to some recently added symbols that were previously missed. It also removes `LLVM_ABI` from symbols where it is problematic. The LLVM annotation currently has no meaningful impact on the LLVM build; however, it is a prerequisite to support an LLVM Windows DLL (shared library) build. ## Overview These changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. NOTE: I am using a modified version of IDS with local patches so it removes unnecessary export annotations. These local IDS changes generated all of the `LLVM_ABI` deletions in this PR. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
1 parent 1915fa1 commit 7e928f9

File tree

17 files changed

+77
-76
lines changed

17 files changed

+77
-76
lines changed

llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class FunctionPropertiesInfo {
4545
LLVM_ABI static FunctionPropertiesInfo
4646
getFunctionPropertiesInfo(Function &F, FunctionAnalysisManager &FAM);
4747

48-
bool operator==(const FunctionPropertiesInfo &FPI) const;
48+
LLVM_ABI bool operator==(const FunctionPropertiesInfo &FPI) const;
4949

5050
bool operator!=(const FunctionPropertiesInfo &FPI) const {
5151
return !(*this == FPI);

llvm/include/llvm/Analysis/IR2Vec.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ struct Embedding {
123123
LLVM_ABI bool approximatelyEquals(const Embedding &RHS,
124124
double Tolerance = 1e-4) const;
125125

126-
void print(raw_ostream &OS) const;
126+
LLVM_ABI void print(raw_ostream &OS) const;
127127
};
128128

129129
using InstEmbeddingsMap = DenseMap<const Instruction *, Embedding>;
@@ -272,7 +272,7 @@ class IR2VecVocabPrinterPass : public PassInfoMixin<IR2VecVocabPrinterPass> {
272272

273273
public:
274274
explicit IR2VecVocabPrinterPass(raw_ostream &OS) : OS(OS) {}
275-
PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
275+
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
276276
static bool isRequired() { return true; }
277277
};
278278

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class TargetLibraryInfoImpl {
136136
AMDLIBM // AMD Math Vector library.
137137
};
138138

139-
LLVM_ABI TargetLibraryInfoImpl() = delete;
139+
TargetLibraryInfoImpl() = delete;
140140
LLVM_ABI explicit TargetLibraryInfoImpl(const Triple &T);
141141

142142
// Provide value semantics.

llvm/include/llvm/CodeGen/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ LLVM_ABI FunctionPass *createSelectOptimizePass();
619619
LLVM_ABI FunctionPass *createCallBrPass();
620620

621621
/// Creates Windows Secure Hot Patch pass. \see WindowsSecureHotPatching.cpp
622-
ModulePass *createWindowsSecureHotPatchingPass();
622+
LLVM_ABI ModulePass *createWindowsSecureHotPatchingPass();
623623

624624
/// Lowers KCFI operand bundles for indirect calls.
625625
LLVM_ABI FunctionPass *createKCFIPass();

llvm/include/llvm/DebugInfo/DWARF/DWARFDataExtractor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class DWARFDataExtractor : public DWARFDataExtractorBase<DWARFDataExtractor> {
4242

4343
/// Extracts a value and applies a relocation to the result if
4444
/// one exists for the given offset.
45-
LLVM_ABI uint64_t getRelocatedValueImpl(uint32_t Size, uint64_t *Off,
46-
uint64_t *SecNdx, Error *Err) const {
45+
uint64_t getRelocatedValueImpl(uint32_t Size, uint64_t *Off, uint64_t *SecNdx,
46+
Error *Err) const {
4747
if (SecNdx)
4848
*SecNdx = object::SectionedAddress::UndefSection;
4949
if (!Section)

llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFCFIProgram.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class CFIProgram {
7979
/// to EndOffset upon successful parsing, or indicates the offset
8080
/// where a problem occurred in case an error is returned.
8181
template <typename T>
82-
LLVM_ABI Error parse(DWARFDataExtractorBase<T> &Data, uint64_t *Offset,
83-
uint64_t EndOffset) {
82+
Error parse(DWARFDataExtractorBase<T> &Data, uint64_t *Offset,
83+
uint64_t EndOffset) {
8484
// See DWARF standard v3, section 7.23
8585
const uint8_t DWARF_CFI_PRIMARY_OPCODE_MASK = 0xc0;
8686
const uint8_t DWARF_CFI_PRIMARY_OPERAND_MASK = 0x3f;

llvm/include/llvm/DebugInfo/DWARF/LowLevel/DWARFDataExtractorSimple.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,24 @@ class DWARFDataExtractorBase : public DataExtractor {
3939
Other.getAddressSize()) {}
4040

4141
/// Extracts a value and returns it as adjusted by the Relocator
42-
LLVM_ABI uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off,
43-
uint64_t *SectionIndex = nullptr,
44-
Error *Err = nullptr) const {
42+
uint64_t getRelocatedValue(uint32_t Size, uint64_t *Off,
43+
uint64_t *SectionIndex = nullptr,
44+
Error *Err = nullptr) const {
4545
return static_cast<const Relocator *>(this)->getRelocatedValueImpl(
4646
Size, Off, SectionIndex, Err);
4747
}
4848

49-
LLVM_ABI uint64_t getRelocatedValue(Cursor &C, uint32_t Size,
50-
uint64_t *SectionIndex = nullptr) const {
49+
uint64_t getRelocatedValue(Cursor &C, uint32_t Size,
50+
uint64_t *SectionIndex = nullptr) const {
5151
return getRelocatedValue(Size, &getOffset(C), SectionIndex, &getError(C));
5252
}
5353

5454
/// Extracts an address-sized value.
55-
LLVM_ABI uint64_t getRelocatedAddress(uint64_t *Off,
56-
uint64_t *SecIx = nullptr) const {
55+
uint64_t getRelocatedAddress(uint64_t *Off, uint64_t *SecIx = nullptr) const {
5756
return getRelocatedValue(getAddressSize(), Off, SecIx);
5857
}
5958

60-
LLVM_ABI uint64_t getRelocatedAddress(Cursor &C,
61-
uint64_t *SecIx = nullptr) const {
59+
uint64_t getRelocatedAddress(Cursor &C, uint64_t *SecIx = nullptr) const {
6260
return getRelocatedValue(getAddressSize(), &getOffset(C), SecIx,
6361
&getError(C));
6462
}
@@ -68,7 +66,7 @@ class DWARFDataExtractorBase : public DataExtractor {
6866
/// 64-bit length. Returns the actual length, and the DWARF format which is
6967
/// encoded in the field. In case of errors, it returns {0, DWARF32} and
7068
/// leaves the offset unchanged.
71-
LLVM_ABI std::pair<uint64_t, dwarf::DwarfFormat>
69+
std::pair<uint64_t, dwarf::DwarfFormat>
7270
getInitialLength(uint64_t *Off, Error *Err = nullptr) const {
7371
ErrorAsOutParameter ErrAsOut(Err);
7472
if (Err && *Err)
@@ -100,18 +98,16 @@ class DWARFDataExtractorBase : public DataExtractor {
10098
return {0, dwarf::DWARF32};
10199
}
102100

103-
LLVM_ABI std::pair<uint64_t, dwarf::DwarfFormat>
104-
getInitialLength(Cursor &C) const {
101+
std::pair<uint64_t, dwarf::DwarfFormat> getInitialLength(Cursor &C) const {
105102
return getInitialLength(&getOffset(C), &getError(C));
106103
}
107104

108105
/// Extracts a DWARF-encoded pointer in \p Offset using \p Encoding.
109106
/// There is a DWARF encoding that uses a PC-relative adjustment.
110107
/// For these values, \p AbsPosOffset is used to fix them, which should
111108
/// reflect the absolute address of this pointer.
112-
LLVM_ABI std::optional<uint64_t>
113-
getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
114-
uint64_t PCRelOffset) const {
109+
std::optional<uint64_t> getEncodedPointer(uint64_t *Offset, uint8_t Encoding,
110+
uint64_t PCRelOffset) const {
115111
if (Encoding == dwarf::DW_EH_PE_omit)
116112
return std::nullopt;
117113

llvm/include/llvm/Frontend/OpenMP/DirectiveNameParser.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "llvm/ADT/StringMap.h"
1414
#include "llvm/ADT/StringRef.h"
1515
#include "llvm/Frontend/OpenMP/OMP.h"
16+
#include "llvm/Support/Compiler.h"
1617

1718
#include <memory>
1819

@@ -44,7 +45,7 @@ namespace llvm::omp {
4445
/// }
4546
/// }
4647
struct DirectiveNameParser {
47-
DirectiveNameParser(SourceLanguage L = SourceLanguage::C);
48+
LLVM_ABI DirectiveNameParser(SourceLanguage L = SourceLanguage::C);
4849

4950
struct State {
5051
Directive Value = Directive::OMPD_unknown;
@@ -62,9 +63,9 @@ struct DirectiveNameParser {
6263
};
6364

6465
const State *initial() const { return &InitialState; }
65-
const State *consume(const State *Current, StringRef Tok) const;
66+
LLVM_ABI const State *consume(const State *Current, StringRef Tok) const;
6667

67-
static SmallVector<StringRef> tokenize(StringRef N);
68+
LLVM_ABI static SmallVector<StringRef> tokenize(StringRef N);
6869

6970
private:
7071
void insertName(StringRef Name, Directive D);

llvm/include/llvm/IR/DebugInfoMetadata.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -870,22 +870,22 @@ class DIBasicType : public DIType {
870870
SizeInBits, AlignInBits, Encoding, NumExtraInhabitants,
871871
Flags, Storage, ShouldCreate);
872872
}
873-
LLVM_ABI static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
874-
MDString *Name, uint64_t SizeInBits,
875-
uint32_t AlignInBits, unsigned Encoding,
876-
uint32_t NumExtraInhabitants,
877-
DIFlags Flags, StorageType Storage,
878-
bool ShouldCreate = true) {
873+
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
874+
MDString *Name, uint64_t SizeInBits,
875+
uint32_t AlignInBits, unsigned Encoding,
876+
uint32_t NumExtraInhabitants, DIFlags Flags,
877+
StorageType Storage, bool ShouldCreate = true) {
879878
auto *SizeInBitsNode = ConstantAsMetadata::get(
880879
ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
881880
return getImpl(Context, Tag, Name, SizeInBitsNode, AlignInBits, Encoding,
882881
NumExtraInhabitants, Flags, Storage, ShouldCreate);
883882
}
884-
static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
885-
MDString *Name, Metadata *SizeInBits,
886-
uint32_t AlignInBits, unsigned Encoding,
887-
uint32_t NumExtraInhabitants, DIFlags Flags,
888-
StorageType Storage, bool ShouldCreate = true);
883+
LLVM_ABI static DIBasicType *getImpl(LLVMContext &Context, unsigned Tag,
884+
MDString *Name, Metadata *SizeInBits,
885+
uint32_t AlignInBits, unsigned Encoding,
886+
uint32_t NumExtraInhabitants,
887+
DIFlags Flags, StorageType Storage,
888+
bool ShouldCreate = true);
889889

890890
TempDIBasicType cloneImpl() const {
891891
return getTemporary(getContext(), getTag(), getRawName(),
@@ -1005,7 +1005,7 @@ class DIFixedPointType : public DIBasicType {
10051005
SizeInBits, AlignInBits, Encoding, Flags, Kind, Factor,
10061006
Numerator, Denominator, Storage, ShouldCreate);
10071007
}
1008-
LLVM_ABI static DIFixedPointType *
1008+
static DIFixedPointType *
10091009
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
10101010
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
10111011
DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
@@ -1016,7 +1016,7 @@ class DIFixedPointType : public DIBasicType {
10161016
Flags, Kind, Factor, Numerator, Denominator, Storage,
10171017
ShouldCreate);
10181018
}
1019-
static DIFixedPointType *
1019+
LLVM_ABI static DIFixedPointType *
10201020
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
10211021
Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
10221022
DIFlags Flags, unsigned Kind, int Factor, APInt Numerator,
@@ -1127,23 +1127,23 @@ class DIStringType : public DIType {
11271127
StringLength, StrLenExp, StrLocationExp, SizeInBitsNode,
11281128
AlignInBits, Encoding, Storage, ShouldCreate);
11291129
}
1130-
LLVM_ABI static DIStringType *
1131-
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
1132-
Metadata *StringLength, Metadata *StrLenExp, Metadata *StrLocationExp,
1133-
uint64_t SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1134-
StorageType Storage, bool ShouldCreate = true) {
1130+
static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
1131+
MDString *Name, Metadata *StringLength,
1132+
Metadata *StrLenExp, Metadata *StrLocationExp,
1133+
uint64_t SizeInBits, uint32_t AlignInBits,
1134+
unsigned Encoding, StorageType Storage,
1135+
bool ShouldCreate = true) {
11351136
auto *SizeInBitsNode = ConstantAsMetadata::get(
11361137
ConstantInt::get(Type::getInt64Ty(Context), SizeInBits));
11371138
return getImpl(Context, Tag, Name, StringLength, StrLenExp, StrLocationExp,
11381139
SizeInBitsNode, AlignInBits, Encoding, Storage,
11391140
ShouldCreate);
11401141
}
1141-
static DIStringType *getImpl(LLVMContext &Context, unsigned Tag,
1142-
MDString *Name, Metadata *StringLength,
1143-
Metadata *StrLenExp, Metadata *StrLocationExp,
1144-
Metadata *SizeInBits, uint32_t AlignInBits,
1145-
unsigned Encoding, StorageType Storage,
1146-
bool ShouldCreate = true);
1142+
LLVM_ABI static DIStringType *
1143+
getImpl(LLVMContext &Context, unsigned Tag, MDString *Name,
1144+
Metadata *StringLength, Metadata *StrLenExp, Metadata *StrLocationExp,
1145+
Metadata *SizeInBits, uint32_t AlignInBits, unsigned Encoding,
1146+
StorageType Storage, bool ShouldCreate = true);
11471147

11481148
TempDIStringType cloneImpl() const {
11491149
return getTemporary(getContext(), getTag(), getRawName(),

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ class IRBuilderBase {
960960
const Twine &Name = "");
961961

962962
/// Create a call to llvm.vscale.<Ty>().
963-
LLVM_ABI Value *CreateVScale(Type *Ty, const Twine &Name = "") {
963+
Value *CreateVScale(Type *Ty, const Twine &Name = "") {
964964
return CreateIntrinsic(Intrinsic::vscale, {Ty}, {}, {}, Name);
965965
}
966966

0 commit comments

Comments
 (0)