Skip to content

Commit 23f6a8a

Browse files
authored
Add missing LLVM_ABI annotations (llvm#167718)
This patch updates various LLVM headers to properly add the `LLVM_ABI` and `LLVM_ABI_FOR_TEST` annotations to build LLVM as a DLL on Windows. This effort is tracked in llvm#109483.
1 parent a3cdef8 commit 23f6a8a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+268
-213
lines changed

llvm/include/llvm/ADT/APFloat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1471,7 +1471,7 @@ class APFloat : public APFloatBase {
14711471

14721472
/// If this value is normal and has an exact, normal, multiplicative inverse,
14731473
/// store it in inv and return true.
1474-
bool getExactInverse(APFloat *Inv) const;
1474+
LLVM_ABI bool getExactInverse(APFloat *Inv) const;
14751475

14761476
// If this is an exact power of two, return the exponent while ignoring the
14771477
// sign bit. If it's not an exact power of 2, return INT_MIN

llvm/include/llvm/Analysis/IR2Vec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class VocabStorage {
164164
VocabStorage() = default;
165165

166166
/// Create a VocabStorage with pre-organized section data
167-
VocabStorage(std::vector<std::vector<Embedding>> &&SectionData);
167+
LLVM_ABI VocabStorage(std::vector<std::vector<Embedding>> &&SectionData);
168168

169169
VocabStorage(VocabStorage &&) = default;
170170
VocabStorage &operator=(VocabStorage &&) = default;

llvm/include/llvm/AsmParser/AsmParserContext.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ class AsmParserContext {
3434
DenseMap<Instruction *, FileLocRange> Instructions;
3535

3636
public:
37-
std::optional<FileLocRange> getFunctionLocation(const Function *) const;
38-
std::optional<FileLocRange> getBlockLocation(const BasicBlock *) const;
39-
std::optional<FileLocRange> getInstructionLocation(const Instruction *) const;
37+
LLVM_ABI std::optional<FileLocRange>
38+
getFunctionLocation(const Function *) const;
39+
LLVM_ABI std::optional<FileLocRange>
40+
getBlockLocation(const BasicBlock *) const;
41+
LLVM_ABI std::optional<FileLocRange>
42+
getInstructionLocation(const Instruction *) const;
4043
/// Get the function at the requested location range.
4144
/// If no single function occupies the queried range, or the record is
4245
/// missing, a nullptr is returned.

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ enum class RootParameterType : uint32_t {
201201

202202
LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
203203

204-
bool isValidParameterType(uint32_t V);
204+
LLVM_ABI_FOR_TEST bool isValidParameterType(uint32_t V);
205205

206206
bool isValidRangeType(uint32_t V);
207207

llvm/include/llvm/CAS/ActionCache.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CacheKey {
3434
StringRef getKey() const { return Key; }
3535

3636
CacheKey(const CASID &ID);
37-
CacheKey(const ObjectProxy &Proxy);
37+
LLVM_ABI_FOR_TEST CacheKey(const ObjectProxy &Proxy);
3838
CacheKey(const ObjectStore &CAS, const ObjectRef &Ref);
3939

4040
private:
@@ -98,10 +98,11 @@ class ActionCache {
9898
};
9999

100100
/// Create an action cache in memory.
101-
std::unique_ptr<ActionCache> createInMemoryActionCache();
101+
LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache();
102102

103103
/// Create an action cache on disk.
104-
Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path);
104+
LLVM_ABI Expected<std::unique_ptr<ActionCache>>
105+
createOnDiskActionCache(StringRef Path);
105106

106107
} // end namespace llvm::cas
107108

llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ObjectStore;
1818

1919
/// Create on-disk \c ObjectStore and \c ActionCache instances based on
2020
/// \c ondisk::UnifiedOnDiskCache, with built-in hashing.
21+
LLVM_ABI
2122
Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
2223
createOnDiskUnifiedCASDatabases(StringRef Path);
2324

llvm/include/llvm/CAS/CASID.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CASID {
7070
}
7171

7272
/// Return a printable string for CASID.
73-
std::string toString() const;
73+
LLVM_ABI std::string toString() const;
7474

7575
ArrayRef<uint8_t> getHash() const {
7676
return arrayRefFromStringRef<uint8_t>(Hash);

llvm/include/llvm/CAS/MappedFileRegionArena.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class MappedFileRegionArena {
6161
/// that information can be stored before the header, like a file magic.
6262
/// \param NewFileConstructor is for constructing new files. It has exclusive
6363
/// access to the file. Must call \c initializeBumpPtr.
64-
static Expected<MappedFileRegionArena>
64+
LLVM_ABI_FOR_TEST static Expected<MappedFileRegionArena>
6565
create(const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset,
6666
function_ref<Error(MappedFileRegionArena &)> NewFileConstructor);
6767

@@ -81,7 +81,7 @@ class MappedFileRegionArena {
8181
return data() + *Offset;
8282
}
8383
/// Allocate, returning the offset from \a data() instead of a pointer.
84-
Expected<int64_t> allocateOffset(uint64_t AllocSize);
84+
LLVM_ABI_FOR_TEST Expected<int64_t> allocateOffset(uint64_t AllocSize);
8585

8686
char *data() const { return Region.data(); }
8787
uint64_t size() const { return H->BumpPtr; }
@@ -106,7 +106,7 @@ class MappedFileRegionArena {
106106
// initialize header from offset.
107107
void initializeHeader(uint64_t HeaderOffset);
108108

109-
void destroyImpl();
109+
LLVM_ABI_FOR_TEST void destroyImpl();
110110
void moveImpl(MappedFileRegionArena &RHS) {
111111
std::swap(Region, RHS.Region);
112112
std::swap(H, RHS.H);

llvm/include/llvm/CAS/ObjectStore.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class ObjectStore {
179179

180180
public:
181181
/// Helper functions to store object and returns a ObjectProxy.
182-
Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data);
182+
LLVM_ABI_FOR_TEST Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs,
183+
StringRef Data);
183184

184185
/// Store object from StringRef.
185186
Expected<ObjectRef> storeFromString(ArrayRef<ObjectRef> Refs,
@@ -205,10 +206,10 @@ class ObjectStore {
205206
static Error createUnknownObjectError(const CASID &ID);
206207

207208
/// Create ObjectProxy from CASID. If the object doesn't exist, get an error.
208-
Expected<ObjectProxy> getProxy(const CASID &ID);
209+
LLVM_ABI Expected<ObjectProxy> getProxy(const CASID &ID);
209210
/// Create ObjectProxy from ObjectRef. If the object can't be loaded, get an
210211
/// error.
211-
Expected<ObjectProxy> getProxy(ObjectRef Ref);
212+
LLVM_ABI Expected<ObjectProxy> getProxy(ObjectRef Ref);
212213

213214
/// \returns \c std::nullopt if the object is missing from the CAS.
214215
Expected<std::optional<ObjectProxy>> getProxyIfExists(ObjectRef Ref);
@@ -329,13 +330,14 @@ class ObjectProxy {
329330
};
330331

331332
/// Create an in memory CAS.
332-
std::unique_ptr<ObjectStore> createInMemoryCAS();
333+
LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS();
333334

334335
/// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled.
335336
bool isOnDiskCASEnabled();
336337

337338
/// Create a persistent on-disk path at \p Path.
338-
Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path);
339+
LLVM_ABI Expected<std::unique_ptr<ObjectStore>>
340+
createOnDiskCAS(const Twine &Path);
339341

340342
} // namespace cas
341343
} // namespace llvm

llvm/include/llvm/CAS/OnDiskDataAllocator.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,32 +57,33 @@ class OnDiskDataAllocator {
5757
/// Get the data of \p Size stored at the given \p Offset. Note the allocator
5858
/// doesn't keep track of the allocation size, thus \p Size doesn't need to
5959
/// match the size of allocation but needs to be smaller.
60-
Expected<ArrayRef<char>> get(FileOffset Offset, size_t Size) const;
60+
LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> get(FileOffset Offset,
61+
size_t Size) const;
6162

6263
/// Allocate at least \p Size with 8-byte alignment.
63-
Expected<OnDiskPtr> allocate(size_t Size);
64+
LLVM_ABI_FOR_TEST Expected<OnDiskPtr> allocate(size_t Size);
6465

6566
/// \returns the buffer that was allocated at \p create time, with size
6667
/// \p UserHeaderSize.
6768
MutableArrayRef<uint8_t> getUserHeader() const;
6869

69-
size_t size() const;
70-
size_t capacity() const;
70+
LLVM_ABI_FOR_TEST size_t size() const;
71+
LLVM_ABI_FOR_TEST size_t capacity() const;
7172

72-
static Expected<OnDiskDataAllocator>
73+
LLVM_ABI_FOR_TEST static Expected<OnDiskDataAllocator>
7374
create(const Twine &Path, const Twine &TableName, uint64_t MaxFileSize,
7475
std::optional<uint64_t> NewFileInitialSize,
7576
uint32_t UserHeaderSize = 0,
7677
function_ref<void(void *)> UserHeaderInit = nullptr);
7778

78-
OnDiskDataAllocator(OnDiskDataAllocator &&RHS);
79-
OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS);
79+
LLVM_ABI_FOR_TEST OnDiskDataAllocator(OnDiskDataAllocator &&RHS);
80+
LLVM_ABI_FOR_TEST OnDiskDataAllocator &operator=(OnDiskDataAllocator &&RHS);
8081

8182
// No copy. Just call \a create() again.
8283
OnDiskDataAllocator(const OnDiskDataAllocator &) = delete;
8384
OnDiskDataAllocator &operator=(const OnDiskDataAllocator &) = delete;
8485

85-
~OnDiskDataAllocator();
86+
LLVM_ABI_FOR_TEST ~OnDiskDataAllocator();
8687

8788
private:
8889
struct ImplType;

0 commit comments

Comments
 (0)