Skip to content

Commit 030d710

Browse files
committed
[llvm] annotate recently added interfaces for DLL export (llvm#150101)
This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates symbols that were recently added to LLVM without proper annotations. The annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. This effort is tracked in llvm#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). The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The following manual adjustments were also applied after running IDS: - Add `LLVM_EXPORT_TEMPLATE` and `LLVM_TEMPLATE_ABI` annotations to explicitly instantiated instances of `llvm::object::SFrameParser`. 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 8454a9a commit 030d710

File tree

9 files changed

+55
-48
lines changed

9 files changed

+55
-48
lines changed

llvm/include/llvm/Analysis/IR2Vec.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,28 +164,28 @@ class Vocabulary {
164164

165165
public:
166166
Vocabulary() = default;
167-
Vocabulary(VocabVector &&Vocab);
167+
LLVM_ABI Vocabulary(VocabVector &&Vocab);
168168

169-
bool isValid() const;
170-
unsigned getDimension() const;
171-
size_t size() const;
169+
LLVM_ABI bool isValid() const;
170+
LLVM_ABI unsigned getDimension() const;
171+
LLVM_ABI size_t size() const;
172172

173173
/// Helper function to get vocabulary key for a given Opcode
174-
static StringRef getVocabKeyForOpcode(unsigned Opcode);
174+
LLVM_ABI static StringRef getVocabKeyForOpcode(unsigned Opcode);
175175

176176
/// Helper function to get vocabulary key for a given TypeID
177-
static StringRef getVocabKeyForTypeID(Type::TypeID TypeID);
177+
LLVM_ABI static StringRef getVocabKeyForTypeID(Type::TypeID TypeID);
178178

179179
/// Helper function to get vocabulary key for a given OperandKind
180-
static StringRef getVocabKeyForOperandKind(OperandKind Kind);
180+
LLVM_ABI static StringRef getVocabKeyForOperandKind(OperandKind Kind);
181181

182182
/// Helper function to classify an operand into OperandKind
183-
static OperandKind getOperandKind(const Value *Op);
183+
LLVM_ABI static OperandKind getOperandKind(const Value *Op);
184184

185185
/// Accessors to get the embedding for a given entity.
186-
const ir2vec::Embedding &operator[](unsigned Opcode) const;
187-
const ir2vec::Embedding &operator[](Type::TypeID TypeId) const;
188-
const ir2vec::Embedding &operator[](const Value *Arg) const;
186+
LLVM_ABI const ir2vec::Embedding &operator[](unsigned Opcode) const;
187+
LLVM_ABI const ir2vec::Embedding &operator[](Type::TypeID TypeId) const;
188+
LLVM_ABI const ir2vec::Embedding &operator[](const Value *Arg) const;
189189

190190
/// Const Iterator type aliases
191191
using const_iterator = VocabVector::const_iterator;
@@ -212,13 +212,13 @@ class Vocabulary {
212212
/// Returns the string key for a given index position in the vocabulary.
213213
/// This is useful for debugging or printing the vocabulary. Do not use this
214214
/// for embedding generation as string based lookups are inefficient.
215-
static StringRef getStringKey(unsigned Pos);
215+
LLVM_ABI static StringRef getStringKey(unsigned Pos);
216216

217217
/// Create a dummy vocabulary for testing purposes.
218-
static VocabVector createDummyVocabForTest(unsigned Dim = 1);
218+
LLVM_ABI static VocabVector createDummyVocabForTest(unsigned Dim = 1);
219219

220-
bool invalidate(Module &M, const PreservedAnalyses &PA,
221-
ModuleAnalysisManager::Invalidator &Inv) const;
220+
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
221+
ModuleAnalysisManager::Invalidator &Inv) const;
222222
};
223223

224224
/// Embedder provides the interface to generate embeddings (vector

llvm/include/llvm/BinaryFormat/SFrame.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define LLVM_BINARYFORMAT_SFRAME_H
1717

1818
#include "llvm/ADT/BitmaskEnum.h"
19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/Support/DataTypes.h"
2021
#include "llvm/Support/Endian.h"
2122

llvm/include/llvm/CodeGen/GCMetadata.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ class GCFunctionInfo {
101101
// are live per safe point (1.5% on 64-bit hosts).
102102

103103
public:
104-
GCFunctionInfo(const Function &F, GCStrategy &S);
105-
~GCFunctionInfo();
104+
LLVM_ABI GCFunctionInfo(const Function &F, GCStrategy &S);
105+
LLVM_ABI ~GCFunctionInfo();
106106

107107
/// Handle invalidation explicitly.
108-
bool invalidate(Function &F, const PreservedAnalyses &PA,
109-
FunctionAnalysisManager::Invalidator &Inv);
108+
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA,
109+
FunctionAnalysisManager::Invalidator &Inv);
110110

111111
/// getFunction - Return the function to which this metadata applies.
112112
const Function &getFunction() const { return F; }
@@ -163,8 +163,8 @@ class GCStrategyMap {
163163
GCStrategyMap(GCStrategyMap &&) = default;
164164

165165
/// Handle invalidation explicitly.
166-
bool invalidate(Module &M, const PreservedAnalyses &PA,
167-
ModuleAnalysisManager::Invalidator &Inv);
166+
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
167+
ModuleAnalysisManager::Invalidator &Inv);
168168

169169
using iterator = MapT::iterator;
170170
using const_iterator = MapT::const_iterator;
@@ -205,7 +205,7 @@ class CollectorMetadataAnalysis
205205

206206
public:
207207
using Result = GCStrategyMap;
208-
Result run(Module &M, ModuleAnalysisManager &MAM);
208+
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &MAM);
209209
};
210210

211211
/// An analysis pass which caches information about the Function.
@@ -217,7 +217,7 @@ class GCFunctionAnalysis : public AnalysisInfoMixin<GCFunctionAnalysis> {
217217

218218
public:
219219
using Result = GCFunctionInfo;
220-
Result run(Function &F, FunctionAnalysisManager &FAM);
220+
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM);
221221
};
222222

223223
/// LowerIntrinsics - This pass rewrites calls to the llvm.gcread or
@@ -228,7 +228,7 @@ class GCFunctionAnalysis : public AnalysisInfoMixin<GCFunctionAnalysis> {
228228
/// This pass requires `CollectorMetadataAnalysis`.
229229
class GCLoweringPass : public PassInfoMixin<GCLoweringPass> {
230230
public:
231-
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
231+
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
232232
};
233233

234234
/// An analysis pass which caches information about the entire Module.
@@ -244,7 +244,7 @@ class GCModuleInfo : public ImmutablePass {
244244
/// Lookup the GCStrategy object associated with the given gc name.
245245
/// Objects are owned internally; No caller should attempt to delete the
246246
/// returned objects.
247-
GCStrategy *getGCStrategy(const StringRef Name);
247+
LLVM_ABI GCStrategy *getGCStrategy(const StringRef Name);
248248

249249
/// List of per function info objects. In theory, Each of these
250250
/// may be associated with a different GC.
@@ -265,14 +265,14 @@ class GCModuleInfo : public ImmutablePass {
265265
public:
266266
using iterator = SmallVector<std::unique_ptr<GCStrategy>, 1>::const_iterator;
267267

268-
static char ID;
268+
LLVM_ABI static char ID;
269269

270-
GCModuleInfo();
270+
LLVM_ABI GCModuleInfo();
271271

272272
/// clear - Resets the pass. Any pass, which uses GCModuleInfo, should
273273
/// call it in doFinalization().
274274
///
275-
void clear();
275+
LLVM_ABI void clear();
276276

277277
/// begin/end - Iterators for used strategies.
278278
///
@@ -282,7 +282,7 @@ class GCModuleInfo : public ImmutablePass {
282282
/// get - Look up function metadata. This is currently assumed
283283
/// have the side effect of initializing the associated GCStrategy. That
284284
/// will soon change.
285-
GCFunctionInfo &getFunctionInfo(const Function &F);
285+
LLVM_ABI GCFunctionInfo &getFunctionInfo(const Function &F);
286286
};
287287

288288
} // end namespace llvm

llvm/include/llvm/ExecutionEngine/Orc/EPCIndirectionUtils.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
1818
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
1919
#include "llvm/ExecutionEngine/Orc/LazyReexports.h"
20+
#include "llvm/Support/Compiler.h"
2021

2122
#include <mutex>
2223

@@ -33,7 +34,7 @@ class EPCIndirectionUtils {
3334
public:
3435
/// ABI support base class. Used to write resolver, stub, and trampoline
3536
/// blocks.
36-
class ABISupport {
37+
class LLVM_ABI ABISupport {
3738
protected:
3839
ABISupport(unsigned PointerSize, unsigned TrampolineSize, unsigned StubSize,
3940
unsigned StubToPointerMaxDisplacement, unsigned ResolverCodeSize)
@@ -81,7 +82,7 @@ class EPCIndirectionUtils {
8182
CreateWithABI(ExecutorProcessControl &EPC);
8283

8384
/// Create based on the ExecutorProcessControl triple.
84-
static Expected<std::unique_ptr<EPCIndirectionUtils>>
85+
LLVM_ABI static Expected<std::unique_ptr<EPCIndirectionUtils>>
8586
Create(ExecutorProcessControl &EPC);
8687

8788
/// Create based on the ExecutorProcessControl triple.
@@ -98,27 +99,27 @@ class EPCIndirectionUtils {
9899

99100
/// Release memory for resources held by this instance. This *must* be called
100101
/// prior to destruction of the class.
101-
Error cleanup();
102+
LLVM_ABI Error cleanup();
102103

103104
/// Write resolver code to the executor process and return its address.
104105
/// This must be called before any call to createTrampolinePool or
105106
/// createLazyCallThroughManager.
106-
Expected<ExecutorAddr> writeResolverBlock(ExecutorAddr ReentryFnAddr,
107-
ExecutorAddr ReentryCtxAddr);
107+
LLVM_ABI Expected<ExecutorAddr>
108+
writeResolverBlock(ExecutorAddr ReentryFnAddr, ExecutorAddr ReentryCtxAddr);
108109

109110
/// Returns the address of the Resolver block. Returns zero if the
110111
/// writeResolverBlock method has not previously been called.
111112
ExecutorAddr getResolverBlockAddress() const { return ResolverBlockAddr; }
112113

113114
/// Create an IndirectStubsManager for the executor process.
114-
std::unique_ptr<IndirectStubsManager> createIndirectStubsManager();
115+
LLVM_ABI std::unique_ptr<IndirectStubsManager> createIndirectStubsManager();
115116

116117
/// Create a TrampolinePool for the executor process.
117-
TrampolinePool &getTrampolinePool();
118+
LLVM_ABI TrampolinePool &getTrampolinePool();
118119

119120
/// Create a LazyCallThroughManager.
120121
/// This function should only be called once.
121-
LazyCallThroughManager &
122+
LLVM_ABI LazyCallThroughManager &
122123
createLazyCallThroughManager(ExecutionSession &ES,
123124
ExecutorAddr ErrorHandlerAddr);
124125

@@ -170,7 +171,7 @@ class EPCIndirectionUtils {
170171
/// called.
171172
///
172173
/// This function is experimental and likely subject to revision.
173-
Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU);
174+
LLVM_ABI Error setUpInProcessLCTMReentryViaEPCIU(EPCIndirectionUtils &EPCIU);
174175

175176
namespace detail {
176177

llvm/include/llvm/ExecutionEngine/Orc/SpeculateAnalyses.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/Analysis/BranchProbabilityInfo.h"
1717
#include "llvm/ExecutionEngine/Orc/Core.h"
1818
#include "llvm/ExecutionEngine/Orc/Speculation.h"
19+
#include "llvm/Support/Compiler.h"
1920

2021
namespace llvm {
2122

@@ -24,8 +25,8 @@ namespace orc {
2425
// Provides common code.
2526
class SpeculateQuery {
2627
protected:
27-
void findCalles(const BasicBlock *, DenseSet<StringRef> &);
28-
bool isStraightLine(const Function &F);
28+
LLVM_ABI void findCalles(const BasicBlock *, DenseSet<StringRef> &);
29+
LLVM_ABI bool isStraightLine(const Function &F);
2930

3031
public:
3132
using ResultTy = std::optional<DenseMap<StringRef, DenseSet<StringRef>>>;
@@ -37,7 +38,7 @@ class BlockFreqQuery : public SpeculateQuery {
3738

3839
public:
3940
// Find likely next executables based on IR Block Frequency
40-
ResultTy operator()(Function &F);
41+
LLVM_ABI ResultTy operator()(Function &F);
4142
};
4243

4344
// This Query generates a sequence of basic blocks which follows the order of
@@ -73,7 +74,7 @@ class SequenceBBQuery : public SpeculateQuery {
7374
VisitedBlocksInfoTy &);
7475

7576
public:
76-
ResultTy operator()(Function &F);
77+
LLVM_ABI ResultTy operator()(Function &F);
7778
};
7879

7980
} // namespace orc

llvm/include/llvm/IR/GCStrategy.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#ifndef LLVM_IR_GCSTRATEGY_H
4848
#define LLVM_IR_GCSTRATEGY_H
4949

50+
#include "llvm/Support/Compiler.h"
5051
#include "llvm/Support/Registry.h"
5152
#include <optional>
5253
#include <string>
@@ -81,7 +82,7 @@ class GCStrategy {
8182
bool UsesMetadata = false; ///< If set, backend must emit metadata tables.
8283

8384
public:
84-
GCStrategy();
85+
LLVM_ABI GCStrategy();
8586
virtual ~GCStrategy() = default;
8687

8788
/// Return the name of the GC strategy. This is the value of the collector
@@ -145,7 +146,7 @@ using GCRegistry = Registry<GCStrategy>;
145146
extern template class LLVM_TEMPLATE_ABI Registry<GCStrategy>;
146147

147148
/// Lookup the GCStrategy object associated with the given gc name.
148-
std::unique_ptr<GCStrategy> getGCStrategy(const StringRef Name);
149+
LLVM_ABI std::unique_ptr<GCStrategy> getGCStrategy(const StringRef Name);
149150

150151
} // end namespace llvm
151152

llvm/include/llvm/MC/DXContainerRootSignature.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/BinaryFormat/DXContainer.h"
10+
#include "llvm/Support/Compiler.h"
1011
#include <cstdint>
1112
#include <limits>
1213

@@ -110,9 +111,9 @@ struct RootSignatureDesc {
110111
mcdxbc::RootParametersContainer ParametersContainer;
111112
SmallVector<dxbc::RTS0::v1::StaticSampler> StaticSamplers;
112113

113-
void write(raw_ostream &OS) const;
114+
LLVM_ABI void write(raw_ostream &OS) const;
114115

115-
size_t getSize() const;
116+
LLVM_ABI size_t getSize() const;
116117
};
117118
} // namespace mcdxbc
118119
} // namespace llvm

llvm/include/llvm/Transforms/Scalar/Reassociate.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/IR/BasicBlock.h"
2929
#include "llvm/IR/PassManager.h"
3030
#include "llvm/IR/ValueHandle.h"
31+
#include "llvm/Support/Compiler.h"
3132
#include <deque>
3233

3334
namespace llvm {
@@ -96,7 +97,7 @@ class ReassociatePass : public PassInfoMixin<ReassociatePass> {
9697
bool MadeChange;
9798

9899
public:
99-
PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
100+
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &);
100101

101102
private:
102103
void BuildRankMap(Function &F, ReversePostOrderTraversal<Function *> &RPOT);

llvm/include/llvm/Transforms/Utils/Mem2Reg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515
#define LLVM_TRANSFORMS_UTILS_MEM2REG_H
1616

1717
#include "llvm/IR/PassManager.h"
18+
#include "llvm/Support/Compiler.h"
1819

1920
namespace llvm {
2021

2122
class Function;
2223

2324
class PromotePass : public PassInfoMixin<PromotePass> {
2425
public:
25-
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
26+
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2627
};
2728

2829
} // end namespace llvm

0 commit comments

Comments
 (0)