Skip to content

Commit 8147693

Browse files
committed
🍒 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 swiftlang/swift#85241.
1 parent 18ffb87 commit 8147693

27 files changed

+207
-164
lines changed

llvm/include/llvm/CAS/ActionCache.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CacheKey {
3434
// which then `getOrCompute` method can be used to avoid multiple calls to
3535
// has function.
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:
@@ -142,14 +142,16 @@ class ActionCache {
142142
};
143143

144144
/// Create an action cache in memory.
145-
std::unique_ptr<ActionCache> createInMemoryActionCache();
145+
LLVM_ABI std::unique_ptr<ActionCache> createInMemoryActionCache();
146146

147147
/// Get a reasonable default on-disk path for a persistent ActionCache for the
148148
/// current user.
149149
std::string getDefaultOnDiskActionCachePath();
150150

151151
/// Create an action cache on disk.
152-
Expected<std::unique_ptr<ActionCache>> createOnDiskActionCache(StringRef Path);
152+
LLVM_ABI Expected<std::unique_ptr<ActionCache>>
153+
createOnDiskActionCache(StringRef Path);
154+
153155
} // end namespace llvm::cas
154156

155157
#endif // LLVM_CAS_CASACTIONCACHE_H

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
@@ -67,7 +67,7 @@ class CASID {
6767
ID.print(OS);
6868
return OS;
6969
}
70-
std::string toString() const;
70+
LLVM_ABI std::string toString() const;
7171

7272
ArrayRef<uint8_t> getHash() const {
7373
return arrayRefFromStringRef<uint8_t>(Hash);

llvm/include/llvm/CAS/MappedFileRegionBumpPtr.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class MappedFileRegionBumpPtr {
5050
/// \param BumpPtrOffset the offset at which to store the bump pointer.
5151
/// \param NewFileConstructor is for constructing new files. It has exclusive
5252
/// access to the file. Must call \c initializeBumpPtr.
53-
static Expected<MappedFileRegionBumpPtr>
53+
LLVM_ABI_FOR_TEST static Expected<MappedFileRegionBumpPtr>
5454
create(const Twine &Path, uint64_t Capacity, int64_t BumpPtrOffset,
5555
std::shared_ptr<ondisk::OnDiskCASLogger> Logger,
5656
function_ref<Error(MappedFileRegionBumpPtr &)> NewFileConstructor);
@@ -75,7 +75,7 @@ class MappedFileRegionBumpPtr {
7575
return data() + *Offset;
7676
}
7777
/// Allocate, returning the offset from \a data() instead of a pointer.
78-
Expected<int64_t> allocateOffset(uint64_t AllocSize);
78+
LLVM_ABI_FOR_TEST Expected<int64_t> allocateOffset(uint64_t AllocSize);
7979

8080
char *data() const { return Region.data(); }
8181
uint64_t size() const { return H->BumpPtr; }
@@ -97,7 +97,7 @@ class MappedFileRegionBumpPtr {
9797
MappedFileRegionBumpPtr &operator=(const MappedFileRegionBumpPtr &) = delete;
9898

9999
private:
100-
void destroyImpl();
100+
LLVM_ABI_FOR_TEST void destroyImpl();
101101
void moveImpl(MappedFileRegionBumpPtr &RHS) {
102102
std::swap(Region, RHS.Region);
103103
std::swap(H, RHS.H);

llvm/include/llvm/CAS/ObjectStore.h

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

226226
public:
227227
/// Helper functions to store object and returns a ObjectProxy.
228-
Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs, StringRef Data);
228+
LLVM_ABI_FOR_TEST Expected<ObjectProxy> createProxy(ArrayRef<ObjectRef> Refs,
229+
StringRef Data);
229230

230231
/// Store object from StringRef.
231232
Expected<ObjectRef> storeFromString(ArrayRef<ObjectRef> Refs,
@@ -251,10 +252,10 @@ class ObjectStore {
251252
static Error createUnknownObjectError(const CASID &ID);
252253

253254
/// Create ObjectProxy from CASID. If the object doesn't exist, get an error.
254-
Expected<ObjectProxy> getProxy(const CASID &ID);
255+
LLVM_ABI Expected<ObjectProxy> getProxy(const CASID &ID);
255256
/// Create ObjectProxy from ObjectRef. If the object can't be loaded, get an
256257
/// error.
257-
Expected<ObjectProxy> getProxy(ObjectRef Ref);
258+
LLVM_ABI Expected<ObjectProxy> getProxy(ObjectRef Ref);
258259

259260
/// \returns \c std::nullopt if the object is missing from the CAS.
260261
Expected<std::optional<ObjectProxy>> getProxyIfExists(ObjectRef Ref);
@@ -394,7 +395,8 @@ class ObjectProxy {
394395
ObjectHandle H;
395396
};
396397

397-
std::unique_ptr<ObjectStore> createInMemoryCAS();
398+
/// Create an in memory CAS.
399+
LLVM_ABI std::unique_ptr<ObjectStore> createInMemoryCAS();
398400

399401
/// \returns true if \c LLVM_ENABLE_ONDISK_CAS configuration was enabled.
400402
bool isOnDiskCASEnabled();
@@ -406,7 +408,8 @@ bool isOnDiskCASEnabled();
406408
///
407409
/// FIXME: Remove the special behaviour for getDefaultOnDiskCASStableID(). The
408410
/// client should handle this logic, if/when desired.
409-
Expected<std::unique_ptr<ObjectStore>> createOnDiskCAS(const Twine &Path);
411+
LLVM_ABI Expected<std::unique_ptr<ObjectStore>>
412+
createOnDiskCAS(const Twine &Path);
410413

411414
/// Set \p Path to a reasonable default on-disk path for a persistent CAS for
412415
/// the current user.

llvm/include/llvm/CAS/OnDiskGraphDB.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ class OnDiskGraphDB {
259259
/// already a record for this object the operation is a no-op. \param ID the
260260
/// object ID to associate the data & references with. \param Refs references
261261
/// \param Data data buffer.
262-
Error store(ObjectID ID, ArrayRef<ObjectID> Refs, ArrayRef<char> Data);
262+
LLVM_ABI_FOR_TEST Error store(ObjectID ID, ArrayRef<ObjectID> Refs,
263+
ArrayRef<char> Data);
263264

264265
/// \returns \p nullopt if the object associated with \p Ref does not exist.
265-
Expected<std::optional<ObjectHandle>> load(ObjectID Ref);
266+
LLVM_ABI_FOR_TEST Expected<std::optional<ObjectHandle>> load(ObjectID Ref);
266267

267268
/// \returns the hash bytes digest for the object reference.
268269
ArrayRef<uint8_t> getDigest(ObjectID Ref) const {
@@ -271,12 +272,13 @@ class OnDiskGraphDB {
271272

272273
/// Form a reference for the provided hash. The reference can be used as part
273274
/// of a CAS object even if it's not associated with an object yet.
274-
Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash);
275+
LLVM_ABI_FOR_TEST Expected<ObjectID> getReference(ArrayRef<uint8_t> Hash);
275276

276277
/// Get an existing reference to the object \p Digest.
277278
///
278279
/// Returns \p nullopt if the object is not stored in this CAS.
279-
std::optional<ObjectID> getExistingReference(ArrayRef<uint8_t> Digest);
280+
LLVM_ABI_FOR_TEST std::optional<ObjectID>
281+
getExistingReference(ArrayRef<uint8_t> Digest);
280282

281283
/// Check whether the object associated with \p Ref is stored in the CAS.
282284
/// Note that this function will fault-in according to the policy.
@@ -289,7 +291,7 @@ class OnDiskGraphDB {
289291
}
290292

291293
/// \returns the data part of the provided object handle.
292-
ArrayRef<char> getObjectData(ObjectHandle Node) const;
294+
LLVM_ABI_FOR_TEST ArrayRef<char> getObjectData(ObjectHandle Node) const;
293295

294296
object_refs_range getObjectRefs(ObjectHandle Node) const {
295297
InternalRefArrayRef Refs = getInternalRefs(Node);
@@ -300,7 +302,7 @@ class OnDiskGraphDB {
300302
///
301303
/// NOTE: There's a possibility that the returned size is not including a
302304
/// large object if the process crashed right at the point of inserting it.
303-
size_t getStorageSize() const;
305+
LLVM_ABI_FOR_TEST size_t getStorageSize() const;
304306

305307
/// \returns The precentage of space utilization of hard space limits.
306308
///
@@ -335,13 +337,13 @@ class OnDiskGraphDB {
335337
/// \param Policy If \p UpstreamDB is provided, controls how nodes are copied
336338
/// to primary store. This is recorded at creation time and subsequent opens
337339
/// need to pass the same policy otherwise the \p open will fail.
338-
static Expected<std::unique_ptr<OnDiskGraphDB>>
340+
LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskGraphDB>>
339341
open(StringRef Path, StringRef HashName, unsigned HashByteSize,
340342
std::unique_ptr<OnDiskGraphDB> UpstreamDB = nullptr,
341343
std::shared_ptr<OnDiskCASLogger> Logger = nullptr,
342344
FaultInPolicy Policy = FaultInPolicy::FullTree);
343345

344-
~OnDiskGraphDB();
346+
LLVM_ABI_FOR_TEST ~OnDiskGraphDB();
345347

346348
private:
347349
struct IndexProxy;
@@ -354,7 +356,9 @@ class OnDiskGraphDB {
354356
OnlyInUpstreamDB,
355357
};
356358

357-
ObjectPresence getObjectPresence(ObjectID Ref, bool CheckUpstream) const;
359+
/// Check if object exists and if it is on upstream only.
360+
LLVM_ABI_FOR_TEST ObjectPresence
361+
getObjectPresence(ObjectID Ref, bool CheckUpstream) const;
358362

359363
bool containsObject(ObjectID Ref, bool CheckUpstream) const {
360364
switch (getObjectPresence(Ref, CheckUpstream)) {
@@ -393,7 +397,9 @@ class OnDiskGraphDB {
393397
void getStandalonePath(StringRef FileSuffix, const IndexProxy &I,
394398
SmallVectorImpl<char> &Path) const;
395399

396-
ArrayRef<uint8_t> getDigest(InternalRef Ref) const;
400+
LLVM_ABI_FOR_TEST ArrayRef<uint8_t>
401+
getDigest(InternalRef Ref) const;
402+
397403
ArrayRef<uint8_t> getDigest(const IndexProxy &I) const;
398404

399405
IndexProxy getIndexProxyFromRef(InternalRef Ref) const;
@@ -403,7 +409,8 @@ class OnDiskGraphDB {
403409
IndexProxy
404410
getIndexProxyFromPointer(OnDiskHashMappedTrie::const_pointer P) const;
405411

406-
InternalRefArrayRef getInternalRefs(ObjectHandle Node) const;
412+
LLVM_ABI_FOR_TEST InternalRefArrayRef
413+
getInternalRefs(ObjectHandle Node) const;
407414

408415
void recordStandaloneSizeIncrease(size_t SizeIncrease);
409416

llvm/include/llvm/CAS/OnDiskKeyValueDB.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ class OnDiskKeyValueDB {
2828
///
2929
/// \returns the value associated with the \p Key. It may be different than
3030
/// \p Value if another value is already associated with this key.
31-
Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key, ArrayRef<char> Value);
31+
LLVM_ABI_FOR_TEST Expected<ArrayRef<char>> put(ArrayRef<uint8_t> Key,
32+
ArrayRef<char> Value);
3233

3334
/// \returns the value associated with the \p Key, or \p std::nullopt if the
3435
/// key does not exist.
35-
Expected<std::optional<ArrayRef<char>>> get(ArrayRef<uint8_t> Key);
36+
LLVM_ABI_FOR_TEST Expected<std::optional<ArrayRef<char>>>
37+
get(ArrayRef<uint8_t> Key);
3638

3739
/// \returns Total size of stored data.
3840
size_t getStorageSize() const {
@@ -55,13 +57,13 @@ class OnDiskKeyValueDB {
5557
/// \param KeySize Size for the key hash bytes.
5658
/// \param ValueName Identifier name for the values.
5759
/// \param ValueSize Size for the value bytes.
58-
static Expected<std::unique_ptr<OnDiskKeyValueDB>>
60+
LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<OnDiskKeyValueDB>>
5961
open(StringRef Path, StringRef HashName, unsigned KeySize,
6062
StringRef ValueName, size_t ValueSize,
6163
std::shared_ptr<OnDiskCASLogger> Logger = nullptr);
6264

6365
using CheckValueT = function_ref<Error(FileOffset Offset, ArrayRef<char>)>;
64-
Error validate(CheckValueT CheckValue) const;
66+
LLVM_ABI_FOR_TEST Error validate(CheckValueT CheckValue) const;
6567

6668
private:
6769
OnDiskKeyValueDB(size_t ValueSize, OnDiskHashMappedTrie Cache)

llvm/include/llvm/CAS/UnifiedOnDiskCache.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class UnifiedOnDiskCache {
7777
/// \param FaultInPolicy Controls how nodes are copied to primary store. This
7878
/// is recorded at creation time and subsequent opens need to pass the same
7979
/// policy otherwise the \p open will fail.
80-
static Expected<std::unique_ptr<UnifiedOnDiskCache>>
80+
LLVM_ABI_FOR_TEST static Expected<std::unique_ptr<UnifiedOnDiskCache>>
8181
open(StringRef Path, std::optional<uint64_t> SizeLimit, StringRef HashName,
8282
unsigned HashByteSize,
8383
OnDiskGraphDB::FaultInPolicy FaultInPolicy =
@@ -118,20 +118,20 @@ class UnifiedOnDiskCache {
118118
/// \param CheckSizeLimit if true it will check whether the primary store has
119119
/// exceeded its intended size limit. If false the check is skipped even if a
120120
/// \p SizeLimit was passed to the \p open call.
121-
Error close(bool CheckSizeLimit = true);
121+
LLVM_ABI_FOR_TEST Error close(bool CheckSizeLimit = true);
122122

123123
/// Set the size for limiting growth. This has an effect for when the instance
124124
/// is closed.
125-
void setSizeLimit(std::optional<uint64_t> SizeLimit);
125+
LLVM_ABI_FOR_TEST void setSizeLimit(std::optional<uint64_t> SizeLimit);
126126

127127
/// \returns the storage size of the cache data.
128-
uint64_t getStorageSize() const;
128+
LLVM_ABI_FOR_TEST uint64_t getStorageSize() const;
129129

130130
/// \returns whether the primary store has exceeded the intended size limit.
131131
/// This can return false even if the overall size of the opened directory is
132132
/// over the \p SizeLimit passed to \p open. To know whether garbage
133133
/// collection needs to be triggered or not, call \p needsGarbaseCollection.
134-
bool hasExceededSizeLimit() const;
134+
LLVM_ABI_FOR_TEST bool hasExceededSizeLimit() const;
135135

136136
/// \returns whether there are unused data that can be deleted using a
137137
/// \p collectGarbage call.
@@ -146,12 +146,12 @@ class UnifiedOnDiskCache {
146146
///
147147
/// It is recommended that garbage-collection is triggered concurrently in the
148148
/// background, so that it has minimal effect on the workload of the process.
149-
static Error collectGarbage(StringRef Path,
150-
ondisk::OnDiskCASLogger *Logger = nullptr);
149+
LLVM_ABI_FOR_TEST static Error
150+
collectGarbage(StringRef Path, ondisk::OnDiskCASLogger *Logger = nullptr);
151151

152152
Error collectGarbage();
153153

154-
~UnifiedOnDiskCache();
154+
LLVM_ABI_FOR_TEST ~UnifiedOnDiskCache();
155155

156156
Error validateActionCache();
157157

llvm/include/llvm/IR/BasicBlock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ class BasicBlock final : public Value, // Basic blocks are data objects also
750750
/// instructions, so the order should be validated no more than once after
751751
/// each ordering to ensure that transforms have the same algorithmic
752752
/// complexity when asserts are enabled as when they are disabled.
753-
void validateInstrOrdering() const;
753+
LLVM_ABI_FOR_TEST void validateInstrOrdering() const;
754754
};
755755

756756
// Create wrappers for C Binding types (see CBindingWrapping.h).

llvm/include/llvm/SandboxIR/Argument.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class Argument : public sandboxir::Value {
2929
assert(isa<llvm::Argument>(Val) && "Expected Argument!");
3030
}
3131
void printAsOperand(raw_ostream &OS) const;
32-
void dumpOS(raw_ostream &OS) const final;
32+
LLVM_ABI_FOR_TEST void dumpOS(raw_ostream &OS) const final;
3333
#endif
3434
};
3535

0 commit comments

Comments
 (0)