mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-22 23:24:59 +00:00
Revert "InstrProf: When reading, copy the data instead of taking a reference. NFC"
Seems like MSVC doesn't like this: InstrProf.h(49) : error C2614: 'llvm::InstrProfRecord' : illegal member initialization: 'Hash' is not a base or member This reverts r240206. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240208 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -29,6 +29,16 @@ namespace llvm {
|
||||
|
||||
class InstrProfReader;
|
||||
|
||||
/// Profiling information for a single function.
|
||||
struct InstrProfRecord {
|
||||
InstrProfRecord() {}
|
||||
InstrProfRecord(StringRef Name, uint64_t Hash, ArrayRef<uint64_t> Counts)
|
||||
: Name(Name), Hash(Hash), Counts(Counts) {}
|
||||
StringRef Name;
|
||||
uint64_t Hash;
|
||||
ArrayRef<uint64_t> Counts;
|
||||
};
|
||||
|
||||
/// A file format agnostic iterator over profiling data.
|
||||
class InstrProfIterator : public std::iterator<std::input_iterator_tag,
|
||||
InstrProfRecord> {
|
||||
@@ -104,6 +114,8 @@ private:
|
||||
std::unique_ptr<MemoryBuffer> DataBuffer;
|
||||
/// Iterator over the profile data.
|
||||
line_iterator Line;
|
||||
/// The current set of counter values.
|
||||
std::vector<uint64_t> Counts;
|
||||
|
||||
TextInstrProfReader(const TextInstrProfReader &) = delete;
|
||||
TextInstrProfReader &operator=(const TextInstrProfReader &) = delete;
|
||||
@@ -129,6 +141,8 @@ class RawInstrProfReader : public InstrProfReader {
|
||||
private:
|
||||
/// The profile data file contents.
|
||||
std::unique_ptr<MemoryBuffer> DataBuffer;
|
||||
/// The current set of counter values.
|
||||
std::vector<uint64_t> Counts;
|
||||
struct ProfileData {
|
||||
const uint32_t NameSize;
|
||||
const uint32_t NumCounters;
|
||||
@@ -192,16 +206,17 @@ enum class HashT : uint32_t;
|
||||
/// Trait for lookups into the on-disk hash table for the binary instrprof
|
||||
/// format.
|
||||
class InstrProfLookupTrait {
|
||||
std::vector<InstrProfRecord> DataBuffer;
|
||||
std::vector<uint64_t> DataBuffer;
|
||||
IndexedInstrProf::HashT HashType;
|
||||
unsigned FormatVersion;
|
||||
|
||||
public:
|
||||
InstrProfLookupTrait(IndexedInstrProf::HashT HashType, unsigned FormatVersion)
|
||||
: HashType(HashType), FormatVersion(FormatVersion) {}
|
||||
|
||||
typedef ArrayRef<InstrProfRecord> data_type;
|
||||
InstrProfLookupTrait(IndexedInstrProf::HashT HashType) : HashType(HashType) {}
|
||||
|
||||
struct data_type {
|
||||
data_type(StringRef Name, ArrayRef<uint64_t> Data)
|
||||
: Name(Name), Data(Data) {}
|
||||
StringRef Name;
|
||||
ArrayRef<uint64_t> Data;
|
||||
};
|
||||
typedef StringRef internal_key_type;
|
||||
typedef StringRef external_key_type;
|
||||
typedef uint64_t hash_value_type;
|
||||
@@ -224,9 +239,22 @@ public:
|
||||
return StringRef((const char *)D, N);
|
||||
}
|
||||
|
||||
data_type ReadData(StringRef K, const unsigned char *D, offset_type N);
|
||||
};
|
||||
data_type ReadData(StringRef K, const unsigned char *D, offset_type N) {
|
||||
DataBuffer.clear();
|
||||
if (N % sizeof(uint64_t))
|
||||
// The data is corrupt, don't try to read it.
|
||||
return data_type("", DataBuffer);
|
||||
|
||||
using namespace support;
|
||||
// We just treat the data as opaque here. It's simpler to handle in
|
||||
// IndexedInstrProfReader.
|
||||
unsigned NumEntries = N / sizeof(uint64_t);
|
||||
DataBuffer.reserve(NumEntries);
|
||||
for (unsigned I = 0; I < NumEntries; ++I)
|
||||
DataBuffer.push_back(endian::readNext<uint64_t, little, unaligned>(D));
|
||||
return data_type(K, DataBuffer);
|
||||
}
|
||||
};
|
||||
typedef OnDiskIterableChainedHashTable<InstrProfLookupTrait>
|
||||
InstrProfReaderIndex;
|
||||
|
||||
@@ -239,6 +267,8 @@ private:
|
||||
std::unique_ptr<InstrProfReaderIndex> Index;
|
||||
/// Iterator over the profile data.
|
||||
InstrProfReaderIndex::data_iterator RecordIterator;
|
||||
/// Offset into our current data set.
|
||||
size_t CurrentOffset;
|
||||
/// The file format version of the profile data.
|
||||
uint64_t FormatVersion;
|
||||
/// The maximal execution count among all functions.
|
||||
@@ -248,7 +278,7 @@ private:
|
||||
IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete;
|
||||
public:
|
||||
IndexedInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
|
||||
: DataBuffer(std::move(DataBuffer)), Index(nullptr) {}
|
||||
: DataBuffer(std::move(DataBuffer)), Index(nullptr), CurrentOffset(0) {}
|
||||
|
||||
/// Return true if the given buffer is in an indexed instrprof format.
|
||||
static bool hasFormat(const MemoryBuffer &DataBuffer);
|
||||
|
Reference in New Issue
Block a user