Skip to content

Commit c8fc8aa

Browse files
committed
[llvm] IDS auto codemod for CGData and CodeGen libraries
1 parent 98595cf commit c8fc8aa

File tree

98 files changed

+2030
-1937
lines changed

Some content is hidden

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

98 files changed

+2030
-1937
lines changed

llvm/include/llvm/CGData/CodeGenData.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#ifndef LLVM_CGDATA_CODEGENDATA_H
1515
#define LLVM_CGDATA_CODEGENDATA_H
1616

17+
#include "llvm/Support/Compiler.h"
1718
#include "llvm/ADT/BitmaskEnum.h"
1819
#include "llvm/ADT/StableHashing.h"
1920
#include "llvm/Bitcode/BitcodeReader.h"
@@ -34,7 +35,7 @@ enum CGDataSectKind {
3435
#include "llvm/CGData/CodeGenData.inc"
3536
};
3637

37-
std::string getCodeGenDataSectionName(CGDataSectKind CGSK,
38+
LLVM_ABI std::string getCodeGenDataSectionName(CGDataSectKind CGSK,
3839
Triple::ObjectFormatType OF,
3940
bool AddSegmentInfo = true);
4041

@@ -47,7 +48,7 @@ enum class CGDataKind {
4748
LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/StableFunctionMergingMap)
4849
};
4950

50-
const std::error_category &cgdata_category();
51+
LLVM_ABI const std::error_category &cgdata_category();
5152

5253
enum class cgdata_error {
5354
success = 0,
@@ -63,7 +64,7 @@ inline std::error_code make_error_code(cgdata_error E) {
6364
return std::error_code(static_cast<int>(E), cgdata_category());
6465
}
6566

66-
class CGDataError : public ErrorInfo<CGDataError> {
67+
class LLVM_ABI CGDataError : public ErrorInfo<CGDataError> {
6768
public:
6869
CGDataError(cgdata_error Err, const Twine &ErrStr = Twine())
6970
: Err(Err), Msg(ErrStr.str()) {
@@ -130,7 +131,7 @@ class CodeGenData {
130131
public:
131132
~CodeGenData() = default;
132133

133-
static CodeGenData &getInstance();
134+
LLVM_ABI static CodeGenData &getInstance();
134135

135136
/// Returns true if we have a valid outlined hash tree.
136137
bool hasOutlinedHashTree() {
@@ -245,7 +246,7 @@ struct StreamCacheData {
245246
/// \p Task represents the partition number in the parallel code generation
246247
/// process. \p AddStream is the callback used to add the serialized module to
247248
/// the stream.
248-
void saveModuleForTwoRounds(const Module &TheModule, unsigned Task,
249+
LLVM_ABI void saveModuleForTwoRounds(const Module &TheModule, unsigned Task,
249250
AddStreamFn AddStream);
250251

251252
/// Load the optimized bitcode module for the second codegen round.
@@ -254,18 +255,18 @@ void saveModuleForTwoRounds(const Module &TheModule, unsigned Task,
254255
/// process. \p Context provides the environment settings for module operations.
255256
/// \p IRFiles contains optimized bitcode module files needed for loading.
256257
/// \return A unique_ptr to the loaded Module, or nullptr if loading fails.
257-
std::unique_ptr<Module> loadModuleForTwoRounds(BitcodeModule &OrigModule,
258+
LLVM_ABI std::unique_ptr<Module> loadModuleForTwoRounds(BitcodeModule &OrigModule,
258259
unsigned Task,
259260
LLVMContext &Context,
260261
ArrayRef<StringRef> IRFiles);
261262

262263
/// Merge the codegen data from the scratch objects \p ObjectFiles from the
263264
/// first codegen round.
264265
/// \return the combined hash of the merged codegen data.
265-
Expected<stable_hash> mergeCodeGenData(ArrayRef<StringRef> ObjectFiles);
266+
LLVM_ABI Expected<stable_hash> mergeCodeGenData(ArrayRef<StringRef> ObjectFiles);
266267

267-
void warn(Error E, StringRef Whence = "");
268-
void warn(Twine Message, StringRef Whence = "", StringRef Hint = "");
268+
LLVM_ABI void warn(Error E, StringRef Whence = "");
269+
LLVM_ABI void warn(Twine Message, StringRef Whence = "", StringRef Hint = "");
269270

270271
} // end namespace cgdata
271272

@@ -297,7 +298,7 @@ struct Header {
297298
// the new field is read correctly.
298299

299300
// Reads a header struct from the buffer.
300-
static Expected<Header> readFromBuffer(const unsigned char *Curr);
301+
LLVM_ABI static Expected<Header> readFromBuffer(const unsigned char *Curr);
301302
};
302303

303304
} // end namespace IndexedCGData

llvm/include/llvm/CGData/CodeGenDataReader.h

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

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/CGData/CodeGenData.h"
1718
#include "llvm/CGData/OutlinedHashTreeRecord.h"
1819
#include "llvm/CGData/StableFunctionMapRecord.h"
@@ -49,20 +50,20 @@ class CodeGenDataReader {
4950

5051
/// Factory method to create an appropriately typed reader for the given
5152
/// codegen data file path and file system.
52-
static Expected<std::unique_ptr<CodeGenDataReader>>
53+
LLVM_ABI static Expected<std::unique_ptr<CodeGenDataReader>>
5354
create(const Twine &Path, vfs::FileSystem &FS);
5455

5556
/// Factory method to create an appropriately typed reader for the given
5657
/// memory buffer.
57-
static Expected<std::unique_ptr<CodeGenDataReader>>
58+
LLVM_ABI static Expected<std::unique_ptr<CodeGenDataReader>>
5859
create(std::unique_ptr<MemoryBuffer> Buffer);
5960

6061
/// Extract the cgdata embedded in sections from the given object file and
6162
/// merge them into the GlobalOutlineRecord. This is a static helper that
6263
/// is used by `llvm-cgdata --merge` or ThinLTO's two-codegen rounds.
6364
/// Optionally, \p CombinedHash can be used to compuate the combined hash of
6465
/// the merged data.
65-
static Error
66+
LLVM_ABI static Error
6667
mergeFromObjectFile(const object::ObjectFile *Obj,
6768
OutlinedHashTreeRecord &GlobalOutlineRecord,
6869
StableFunctionMapRecord &GlobalFunctionMapRecord,
@@ -98,7 +99,7 @@ class CodeGenDataReader {
9899
Error success() { return error(cgdata_error::success); }
99100
};
100101

101-
class IndexedCodeGenDataReader : public CodeGenDataReader {
102+
class LLVM_ABI IndexedCodeGenDataReader : public CodeGenDataReader {
102103
/// The codegen data file contents.
103104
std::unique_ptr<MemoryBuffer> DataBuffer;
104105
/// The header
@@ -139,7 +140,7 @@ class IndexedCodeGenDataReader : public CodeGenDataReader {
139140
/// codegen data is recorded. `#` is used to indicate a comment.
140141
/// The subsequent data is a YAML format per each codegen data in order.
141142
/// Currently, it only has a function outlined hash tree.
142-
class TextCodeGenDataReader : public CodeGenDataReader {
143+
class LLVM_ABI TextCodeGenDataReader : public CodeGenDataReader {
143144
/// The codegen data file contents.
144145
std::unique_ptr<MemoryBuffer> DataBuffer;
145146
/// Iterator over the profile data.

llvm/include/llvm/CGData/CodeGenDataWriter.h

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

16+
#include "llvm/Support/Compiler.h"
1617
#include "llvm/CGData/CodeGenData.h"
1718
#include "llvm/CGData/OutlinedHashTreeRecord.h"
1819
#include "llvm/CGData/StableFunctionMapRecord.h"
@@ -45,7 +46,7 @@ class CGDataOStream {
4546
// \c patch can only be called when all data is written and flushed.
4647
// For raw_string_ostream, the patch is done on the target string
4748
// directly and it won't be reflected in the stream's internal buffer.
48-
void patch(ArrayRef<CGDataPatchItem> P);
49+
LLVM_ABI void patch(ArrayRef<CGDataPatchItem> P);
4950

5051
// If \c OS is an instance of \c raw_fd_ostream, this field will be
5152
// true. Otherwise, \c OS will be an raw_string_ostream.
@@ -69,16 +70,16 @@ class CodeGenDataWriter {
6970
~CodeGenDataWriter() = default;
7071

7172
/// Add the outlined hash tree record. The input hash tree is released.
72-
void addRecord(OutlinedHashTreeRecord &Record);
73+
LLVM_ABI void addRecord(OutlinedHashTreeRecord &Record);
7374

7475
/// Add the stable function map record. The input function map is released.
75-
void addRecord(StableFunctionMapRecord &Record);
76+
LLVM_ABI void addRecord(StableFunctionMapRecord &Record);
7677

7778
/// Write the codegen data to \c OS
78-
Error write(raw_fd_ostream &OS);
79+
LLVM_ABI Error write(raw_fd_ostream &OS);
7980

8081
/// Write the codegen data in text format to \c OS
81-
Error writeText(raw_fd_ostream &OS);
82+
LLVM_ABI Error writeText(raw_fd_ostream &OS);
8283

8384
/// Return the attributes of the current CGData.
8485
CGDataKind getCGDataKind() const { return DataKind; }

llvm/include/llvm/CGData/OutlinedHashTree.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef LLVM_CGDATA_OUTLINEDHASHTREE_H
1616
#define LLVM_CGDATA_OUTLINEDHASHTREE_H
1717

18+
#include "llvm/Support/Compiler.h"
1819
#include "llvm/ADT/DenseMap.h"
1920
#include "llvm/ADT/StableHashing.h"
2021
#include "llvm/ObjectYAML/YAML.h"
@@ -54,7 +55,7 @@ class OutlinedHashTree {
5455
/// the source and the stable_hash of the sink for an edge. These generic
5556
/// callbacks can be used to traverse a OutlinedHashTree for the purpose of
5657
/// print debugging or serializing it.
57-
void walkGraph(NodeCallbackFn CallbackNode,
58+
LLVM_ABI void walkGraph(NodeCallbackFn CallbackNode,
5859
EdgeCallbackFn CallbackEdge = nullptr,
5960
bool SortedWalk = false) const;
6061

@@ -71,24 +72,24 @@ class OutlinedHashTree {
7172
/// \p GetTerminalCountOnly is true, it only counts the terminal nodes
7273
/// (meaning it returns the the number of hash sequences in the
7374
/// OutlinedHashTree).
74-
size_t size(bool GetTerminalCountOnly = false) const;
75+
LLVM_ABI size_t size(bool GetTerminalCountOnly = false) const;
7576

7677
/// \returns the depth of a OutlinedHashTree by traversing it.
77-
size_t depth() const;
78+
LLVM_ABI size_t depth() const;
7879

7980
/// \returns the root hash node of a OutlinedHashTree.
8081
const HashNode *getRoot() const { return &Root; }
8182
HashNode *getRoot() { return &Root; }
8283

8384
/// Inserts a \p Sequence into the this tree. The last node in the sequence
8485
/// will increase Terminals.
85-
void insert(const HashSequencePair &SequencePair);
86+
LLVM_ABI void insert(const HashSequencePair &SequencePair);
8687

8788
/// Merge a \p OtherTree into this Tree.
88-
void merge(const OutlinedHashTree *OtherTree);
89+
LLVM_ABI void merge(const OutlinedHashTree *OtherTree);
8990

9091
/// \returns the matching count if \p Sequence exists in the OutlinedHashTree.
91-
std::optional<unsigned> find(const HashSequence &Sequence) const;
92+
LLVM_ABI std::optional<unsigned> find(const HashSequence &Sequence) const;
9293

9394
private:
9495
HashNode Root;

llvm/include/llvm/CGData/OutlinedHashTreeRecord.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef LLVM_CGDATA_OUTLINEDHASHTREERECORD_H
1717
#define LLVM_CGDATA_OUTLINEDHASHTREERECORD_H
1818

19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/CGData/OutlinedHashTree.h"
2021

2122
namespace llvm {
@@ -40,13 +41,13 @@ struct OutlinedHashTreeRecord {
4041
: HashTree(std::move(HashTree)) {};
4142

4243
/// Serialize the outlined hash tree to a raw_ostream.
43-
void serialize(raw_ostream &OS) const;
44+
LLVM_ABI void serialize(raw_ostream &OS) const;
4445
/// Deserialize the outlined hash tree from a raw_ostream.
45-
void deserialize(const unsigned char *&Ptr);
46+
LLVM_ABI void deserialize(const unsigned char *&Ptr);
4647
/// Serialize the outlined hash tree to a YAML stream.
47-
void serializeYAML(yaml::Output &YOS) const;
48+
LLVM_ABI void serializeYAML(yaml::Output &YOS) const;
4849
/// Deserialize the outlined hash tree from a YAML stream.
49-
void deserializeYAML(yaml::Input &YIS);
50+
LLVM_ABI void deserializeYAML(yaml::Input &YIS);
5051

5152
/// Merge the other outlined hash tree into this one.
5253
void merge(const OutlinedHashTreeRecord &Other) {

llvm/include/llvm/CGData/StableFunctionMap.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef LLVM_CGDATA_STABLEFUNCTIONMAP_H
1717
#define LLVM_CGDATA_STABLEFUNCTIONMAP_H
1818

19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/ADT/DenseMap.h"
2021
#include "llvm/ADT/StringMap.h"
2122
#include "llvm/IR/StructuralHash.h"
@@ -82,18 +83,18 @@ struct StableFunctionMap {
8283

8384
/// Get an existing ID associated with the given name or create a new ID if it
8485
/// doesn't exist.
85-
unsigned getIdOrCreateForName(StringRef Name);
86+
LLVM_ABI unsigned getIdOrCreateForName(StringRef Name);
8687

8788
/// Get the name associated with a given ID
88-
std::optional<std::string> getNameForId(unsigned Id) const;
89+
LLVM_ABI std::optional<std::string> getNameForId(unsigned Id) const;
8990

9091
/// Insert a `StableFunction` object into the function map. This method
9192
/// handles the uniquing of string names and create a `StableFunctionEntry`
9293
/// for insertion.
93-
void insert(const StableFunction &Func);
94+
LLVM_ABI void insert(const StableFunction &Func);
9495

9596
/// Merge a \p OtherMap into this function map.
96-
void merge(const StableFunctionMap &OtherMap);
97+
LLVM_ABI void merge(const StableFunctionMap &OtherMap);
9798

9899
/// \returns true if there is no stable function entry.
99100
bool empty() const { return size() == 0; }
@@ -107,10 +108,10 @@ struct StableFunctionMap {
107108

108109
/// \returns the size of StableFunctionMap.
109110
/// \p Type is the type of size to return.
110-
size_t size(SizeType Type = UniqueHashCount) const;
111+
LLVM_ABI size_t size(SizeType Type = UniqueHashCount) const;
111112

112113
/// Finalize the stable function map by trimming content.
113-
void finalize(bool SkipTrim = false);
114+
LLVM_ABI void finalize(bool SkipTrim = false);
114115

115116
private:
116117
/// Insert a `StableFunctionEntry` into the function map directly. This

llvm/include/llvm/CGData/StableFunctionMapRecord.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef LLVM_CGDATA_STABLEFUNCTIONMAPRECORD_H
1717
#define LLVM_CGDATA_STABLEFUNCTIONMAPRECORD_H
1818

19+
#include "llvm/Support/Compiler.h"
1920
#include "llvm/CGData/StableFunctionMap.h"
2021
#include "llvm/ObjectYAML/YAML.h"
2122
#include "llvm/Support/raw_ostream.h"
@@ -34,19 +35,19 @@ struct StableFunctionMapRecord {
3435

3536
/// A static helper function to serialize the stable function map without
3637
/// owning the stable function map.
37-
static void serialize(raw_ostream &OS, const StableFunctionMap *FunctionMap);
38+
LLVM_ABI static void serialize(raw_ostream &OS, const StableFunctionMap *FunctionMap);
3839

3940
/// Serialize the stable function map to a raw_ostream.
40-
void serialize(raw_ostream &OS) const;
41+
LLVM_ABI void serialize(raw_ostream &OS) const;
4142

4243
/// Deserialize the stable function map from a raw_ostream.
43-
void deserialize(const unsigned char *&Ptr);
44+
LLVM_ABI void deserialize(const unsigned char *&Ptr);
4445

4546
/// Serialize the stable function map to a YAML stream.
46-
void serializeYAML(yaml::Output &YOS) const;
47+
LLVM_ABI void serializeYAML(yaml::Output &YOS) const;
4748

4849
/// Deserialize the stable function map from a YAML stream.
49-
void deserializeYAML(yaml::Input &YIS);
50+
LLVM_ABI void deserializeYAML(yaml::Input &YIS);
5051

5152
/// Finalize the stable function map by trimming content.
5253
void finalize(bool SkipTrim = false) { FunctionMap->finalize(SkipTrim); }

0 commit comments

Comments
 (0)