1515
1616#include " llvm/CGData/CodeGenData.h"
1717#include " llvm/CGData/OutlinedHashTreeRecord.h"
18+ #include " llvm/CGData/StableFunctionMapRecord.h"
1819#include " llvm/Support/LineIterator.h"
1920#include " llvm/Support/VirtualFileSystem.h"
2021
@@ -36,10 +37,15 @@ class CodeGenDataReader {
3637 virtual CGDataKind getDataKind () const = 0;
3738 // / Return true if the data has an outlined hash tree.
3839 virtual bool hasOutlinedHashTree () const = 0;
40+ // / Return true if the data has a stable function map.
41+ virtual bool hasStableFunctionMap () const = 0;
3942 // / Return the outlined hash tree that is released from the reader.
4043 std::unique_ptr<OutlinedHashTree> releaseOutlinedHashTree () {
4144 return std::move (HashTreeRecord.HashTree );
4245 }
46+ std::unique_ptr<StableFunctionMap> releaseStableFunctionMap () {
47+ return std::move (FunctionMapRecord.FunctionMap );
48+ }
4349
4450 // / Factory method to create an appropriately typed reader for the given
4551 // / codegen data file path and file system.
@@ -56,15 +62,21 @@ class CodeGenDataReader {
5662 // / is used by `llvm-cgdata --merge` or ThinLTO's two-codegen rounds.
5763 // / Optionally, \p CombinedHash can be used to compuate the combined hash of
5864 // / the merged data.
59- static Error mergeFromObjectFile (const object::ObjectFile *Obj,
60- OutlinedHashTreeRecord &GlobalOutlineRecord,
61- stable_hash *CombinedHash = nullptr );
65+ static Error
66+ mergeFromObjectFile (const object::ObjectFile *Obj,
67+ OutlinedHashTreeRecord &GlobalOutlineRecord,
68+ StableFunctionMapRecord &GlobalFunctionMapRecord,
69+ stable_hash *CombinedHash = nullptr );
6270
6371protected:
6472 // / The outlined hash tree that has been read. When it's released by
6573 // / releaseOutlinedHashTree(), it's no longer valid.
6674 OutlinedHashTreeRecord HashTreeRecord;
6775
76+ // / The stable function map that has been read. When it's released by
77+ // releaseStableFunctionMap(), it's no longer valid.
78+ StableFunctionMapRecord FunctionMapRecord;
79+
6880 // / Set the current error and return same.
6981 Error error (cgdata_error Err, const std::string &ErrMsg = " " ) {
7082 LastError = Err;
@@ -115,6 +127,11 @@ class IndexedCodeGenDataReader : public CodeGenDataReader {
115127 return Header.DataKind &
116128 static_cast <uint32_t >(CGDataKind::FunctionOutlinedHashTree);
117129 }
130+ // / Return true if the header indicates the data has a stable function map.
131+ bool hasStableFunctionMap () const override {
132+ return Header.DataKind &
133+ static_cast <uint32_t >(CGDataKind::StableFunctionMergingMap);
134+ }
118135};
119136
120137// / This format is a simple text format that's suitable for test data.
@@ -150,6 +167,12 @@ class TextCodeGenDataReader : public CodeGenDataReader {
150167 return static_cast <uint32_t >(DataKind) &
151168 static_cast <uint32_t >(CGDataKind::FunctionOutlinedHashTree);
152169 }
170+ // / Return true if the header indicates the data has a stable function map.
171+ // / This does not mean that the data is still available.
172+ bool hasStableFunctionMap () const override {
173+ return static_cast <uint32_t >(DataKind) &
174+ static_cast <uint32_t >(CGDataKind::StableFunctionMergingMap);
175+ }
153176};
154177
155178} // end namespace llvm
0 commit comments