Skip to content

Commit 8cbb1bb

Browse files
committed
[llvm] IDS auto codemod for AsmParser, BinaryFormat, Bitcode, and Bitstream libraries
1 parent f50fe74 commit 8cbb1bb

File tree

18 files changed

+214
-198
lines changed

18 files changed

+214
-198
lines changed

llvm/include/llvm/AsmParser/Parser.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_ASMPARSER_PARSER_H
1414
#define LLVM_ASMPARSER_PARSER_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/STLFunctionalExtras.h"
1718
#include "llvm/ADT/StringRef.h"
1819
#include <memory>
@@ -44,7 +45,7 @@ typedef llvm::function_ref<std::optional<std::string>(StringRef, StringRef)>
4445
/// \param Context Context in which to allocate globals info.
4546
/// \param Slots The optional slot mapping that will be initialized during
4647
/// parsing.
47-
std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
48+
LLVM_ABI std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
4849
LLVMContext &Context,
4950
SlotMapping *Slots = nullptr);
5051

@@ -59,7 +60,7 @@ std::unique_ptr<Module> parseAssemblyFile(StringRef Filename, SMDiagnostic &Err,
5960
/// \param Context Context in which to allocate globals info.
6061
/// \param Slots The optional slot mapping that will be initialized during
6162
/// parsing.
62-
std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
63+
LLVM_ABI std::unique_ptr<Module> parseAssemblyString(StringRef AsmString,
6364
SMDiagnostic &Err,
6465
LLVMContext &Context,
6566
SlotMapping *Slots = nullptr);
@@ -84,15 +85,15 @@ struct ParsedModuleAndIndex {
8485
/// \param Slots The optional slot mapping that will be initialized during
8586
/// parsing.
8687
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
87-
ParsedModuleAndIndex parseAssemblyFileWithIndex(
88+
LLVM_ABI ParsedModuleAndIndex parseAssemblyFileWithIndex(
8889
StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
8990
SlotMapping *Slots = nullptr,
9091
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
9192
return std::nullopt;
9293
});
9394

9495
/// Only for use in llvm-as for testing; this does not produce a valid module.
95-
ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo(
96+
LLVM_ABI ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo(
9697
StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
9798
SlotMapping *Slots, DataLayoutCallbackTy DataLayoutCallback);
9899

@@ -104,7 +105,7 @@ ParsedModuleAndIndex parseAssemblyFileWithIndexNoUpgradeDebugInfo(
104105
/// Parse LLVM Assembly Index from a file
105106
/// \param Filename The name of the file to parse
106107
/// \param Err Error result info.
107-
std::unique_ptr<ModuleSummaryIndex>
108+
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
108109
parseSummaryIndexAssemblyFile(StringRef Filename, SMDiagnostic &Err);
109110

110111
/// The function is a secondary interface to the LLVM Assembly Parser. It parses
@@ -115,7 +116,7 @@ parseSummaryIndexAssemblyFile(StringRef Filename, SMDiagnostic &Err);
115116
/// Parse LLVM Assembly from a string
116117
/// \param AsmString The string containing assembly
117118
/// \param Err Error result info.
118-
std::unique_ptr<ModuleSummaryIndex>
119+
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
119120
parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
120121

121122
/// parseAssemblyFile and parseAssemblyString are wrappers around this function.
@@ -125,7 +126,7 @@ parseSummaryIndexAssemblyString(StringRef AsmString, SMDiagnostic &Err);
125126
/// \param Slots The optional slot mapping that will be initialized during
126127
/// parsing.
127128
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
128-
std::unique_ptr<Module> parseAssembly(
129+
LLVM_ABI std::unique_ptr<Module> parseAssembly(
129130
MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context,
130131
SlotMapping *Slots = nullptr,
131132
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
@@ -140,7 +141,7 @@ std::unique_ptr<Module> parseAssembly(
140141
/// parsing.
141142
///
142143
/// parseAssemblyFileWithIndex is a wrapper around this function.
143-
ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
144+
LLVM_ABI ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
144145
SMDiagnostic &Err,
145146
LLVMContext &Context,
146147
SlotMapping *Slots = nullptr);
@@ -151,7 +152,7 @@ ParsedModuleAndIndex parseAssemblyWithIndex(MemoryBufferRef F,
151152
/// \param Err Error result info.
152153
///
153154
/// parseSummaryIndexAssemblyFile is a wrapper around this function.
154-
std::unique_ptr<ModuleSummaryIndex>
155+
LLVM_ABI std::unique_ptr<ModuleSummaryIndex>
155156
parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
156157

157158
/// This function is the low-level interface to the LLVM Assembly Parser.
@@ -167,7 +168,7 @@ parseSummaryIndexAssembly(MemoryBufferRef F, SMDiagnostic &Err);
167168
/// parsing.
168169
/// \return true on error.
169170
/// \param DataLayoutCallback Override datalayout in the llvm assembly.
170-
bool parseAssemblyInto(
171+
LLVM_ABI bool parseAssemblyInto(
171172
MemoryBufferRef F, Module *M, ModuleSummaryIndex *Index, SMDiagnostic &Err,
172173
SlotMapping *Slots = nullptr,
173174
DataLayoutCallbackTy DataLayoutCallback = [](StringRef, StringRef) {
@@ -182,15 +183,15 @@ bool parseAssemblyInto(
182183
/// \param Slots The optional slot mapping that will restore the parsing state
183184
/// of the module.
184185
/// \return null on error.
185-
Constant *parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M,
186+
LLVM_ABI Constant *parseConstantValue(StringRef Asm, SMDiagnostic &Err, const Module &M,
186187
const SlotMapping *Slots = nullptr);
187188

188189
/// Parse a type in the given string.
189190
///
190191
/// \param Slots The optional slot mapping that will restore the parsing state
191192
/// of the module.
192193
/// \return null on error.
193-
Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
194+
LLVM_ABI Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
194195
const SlotMapping *Slots = nullptr);
195196

196197
/// Parse a string \p Asm that starts with a type.
@@ -200,10 +201,10 @@ Type *parseType(StringRef Asm, SMDiagnostic &Err, const Module &M,
200201
/// \param Slots The optional slot mapping that will restore the parsing state
201202
/// of the module.
202203
/// \return null on error.
203-
Type *parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err,
204+
LLVM_ABI Type *parseTypeAtBeginning(StringRef Asm, unsigned &Read, SMDiagnostic &Err,
204205
const Module &M, const SlotMapping *Slots = nullptr);
205206

206-
DIExpression *parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read,
207+
LLVM_ABI DIExpression *parseDIExpressionBodyAtBeginning(StringRef Asm, unsigned &Read,
207208
SMDiagnostic &Err,
208209
const Module &M,
209210
const SlotMapping *Slots);

llvm/include/llvm/BinaryFormat/AMDGPUMetadataVerifier.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
1717
#define LLVM_BINARYFORMAT_AMDGPUMETADATAVERIFIER_H
1818

19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/ADT/STLFunctionalExtras.h"
2021
#include "llvm/ADT/StringRef.h"
2122
#include "llvm/BinaryFormat/MsgPackReader.h"
@@ -69,7 +70,7 @@ class MetadataVerifier {
6970
/// Verify given HSA metadata.
7071
///
7172
/// \returns True when successful, false when metadata is invalid.
72-
bool verify(msgpack::DocNode &HSAMetadataRoot);
73+
LLVM_ABI bool verify(msgpack::DocNode &HSAMetadataRoot);
7374
};
7475

7576
} // end namespace V3

llvm/include/llvm/BinaryFormat/COFF.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#ifndef LLVM_BINARYFORMAT_COFF_H
2323
#define LLVM_BINARYFORMAT_COFF_H
2424

25+
#include "llvm/Support/Compiler.h"
2526
#include "llvm/Support/DataTypes.h"
2627
#include <cassert>
2728

@@ -851,7 +852,7 @@ inline bool isReservedSectionNumber(int32_t SectionNumber) {
851852

852853
/// Encode section name based on string table offset.
853854
/// The size of Out must be at least COFF::NameSize.
854-
bool encodeSectionName(char *Out, uint64_t Offset);
855+
LLVM_ABI bool encodeSectionName(char *Out, uint64_t Offset);
855856

856857
} // End namespace COFF.
857858
} // End namespace llvm.

llvm/include/llvm/BinaryFormat/DXContainer.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#ifndef LLVM_BINARYFORMAT_DXCONTAINER_H
1414
#define LLVM_BINARYFORMAT_DXCONTAINER_H
1515

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/ADT/StringRef.h"
1718
#include "llvm/Support/Error.h"
1819
#include "llvm/Support/SwapByteOrder.h"
@@ -59,7 +60,7 @@ struct ShaderHash {
5960
uint32_t Flags; // dxbc::HashFlags
6061
uint8_t Digest[16];
6162

62-
bool isPopulated();
63+
LLVM_ABI bool isPopulated();
6364

6465
void swapBytes() { sys::swapByteOrder(Flags); }
6566
};
@@ -173,7 +174,7 @@ enum class RootParameterType : uint32_t {
173174
#include "DXContainerConstants.def"
174175
};
175176

176-
ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
177+
LLVM_ABI ArrayRef<EnumEntry<RootParameterType>> getRootParameterTypes();
177178

178179
#define DESCRIPTOR_RANGE(Val, Enum) Enum = Val,
179180
enum class DescriptorRangeType : uint32_t {
@@ -197,7 +198,7 @@ enum class ShaderVisibility : uint32_t {
197198
#include "DXContainerConstants.def"
198199
};
199200

200-
ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
201+
LLVM_ABI ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
201202

202203
#define SHADER_VISIBILITY(Val, Enum) \
203204
case Val: \
@@ -229,7 +230,7 @@ enum class SamplersBorderColor : uint32_t {
229230
#include "DXContainerConstants.def"
230231
};
231232

232-
PartType parsePartType(StringRef S);
233+
LLVM_ABI PartType parsePartType(StringRef S);
233234

234235
struct VertexPSVInfo {
235236
uint8_t OutputPositionPresent;
@@ -360,35 +361,35 @@ enum class SemanticKind : uint8_t {
360361
#include "DXContainerConstants.def"
361362
};
362363

363-
ArrayRef<EnumEntry<SemanticKind>> getSemanticKinds();
364+
LLVM_ABI ArrayRef<EnumEntry<SemanticKind>> getSemanticKinds();
364365

365366
#define COMPONENT_TYPE(Val, Enum) Enum = Val,
366367
enum class ComponentType : uint8_t {
367368
#include "DXContainerConstants.def"
368369
};
369370

370-
ArrayRef<EnumEntry<ComponentType>> getComponentTypes();
371+
LLVM_ABI ArrayRef<EnumEntry<ComponentType>> getComponentTypes();
371372

372373
#define INTERPOLATION_MODE(Val, Enum) Enum = Val,
373374
enum class InterpolationMode : uint8_t {
374375
#include "DXContainerConstants.def"
375376
};
376377

377-
ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();
378+
LLVM_ABI ArrayRef<EnumEntry<InterpolationMode>> getInterpolationModes();
378379

379380
#define RESOURCE_TYPE(Val, Enum) Enum = Val,
380381
enum class ResourceType : uint32_t {
381382
#include "DXContainerConstants.def"
382383
};
383384

384-
ArrayRef<EnumEntry<ResourceType>> getResourceTypes();
385+
LLVM_ABI ArrayRef<EnumEntry<ResourceType>> getResourceTypes();
385386

386387
#define RESOURCE_KIND(Val, Enum) Enum = Val,
387388
enum class ResourceKind : uint32_t {
388389
#include "DXContainerConstants.def"
389390
};
390391

391-
ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();
392+
LLVM_ABI ArrayRef<EnumEntry<ResourceKind>> getResourceKinds();
392393

393394
#define RESOURCE_FLAG(Index, Enum) bool Enum = false;
394395
struct ResourceFlags {
@@ -555,21 +556,21 @@ enum class SigMinPrecision : uint32_t {
555556
#include "DXContainerConstants.def"
556557
};
557558

558-
ArrayRef<EnumEntry<SigMinPrecision>> getSigMinPrecisions();
559+
LLVM_ABI ArrayRef<EnumEntry<SigMinPrecision>> getSigMinPrecisions();
559560

560561
#define D3D_SYSTEM_VALUE(Val, Enum) Enum = Val,
561562
enum class D3DSystemValue : uint32_t {
562563
#include "DXContainerConstants.def"
563564
};
564565

565-
ArrayRef<EnumEntry<D3DSystemValue>> getD3DSystemValues();
566+
LLVM_ABI ArrayRef<EnumEntry<D3DSystemValue>> getD3DSystemValues();
566567

567568
#define COMPONENT_TYPE(Val, Enum) Enum = Val,
568569
enum class SigComponentType : uint32_t {
569570
#include "DXContainerConstants.def"
570571
};
571572

572-
ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();
573+
LLVM_ABI ArrayRef<EnumEntry<SigComponentType>> getSigComponentTypes();
573574

574575
struct ProgramSignatureHeader {
575576
uint32_t ParamCount;

0 commit comments

Comments
 (0)