mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-28 06:24:57 +00:00
OnDiskHashTable: Audit types and use offset_type consistently
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206675 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -227,11 +227,11 @@ public:
|
|||||||
return std::make_pair(KeyLen, DataLen);
|
return std::make_pair(KeyLen, DataLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef ReadKey(const unsigned char *D, unsigned N) {
|
StringRef ReadKey(const unsigned char *D, offset_type N) {
|
||||||
return StringRef((const char *)D, N);
|
return StringRef((const char *)D, N);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstrProfRecord ReadData(StringRef K, const unsigned char *D, unsigned N) {
|
InstrProfRecord ReadData(StringRef K, const unsigned char *D, offset_type N) {
|
||||||
if (N < 2 * sizeof(uint64_t) || N % sizeof(uint64_t)) {
|
if (N < 2 * sizeof(uint64_t) || N % sizeof(uint64_t)) {
|
||||||
// The data is corrupt, don't try to read it.
|
// The data is corrupt, don't try to read it.
|
||||||
CountBuffer.clear();
|
CountBuffer.clear();
|
||||||
|
@ -48,10 +48,11 @@ namespace llvm {
|
|||||||
/// static std::pair<offset_type, offset_type>
|
/// static std::pair<offset_type, offset_type>
|
||||||
/// EmitKeyDataLength(raw_ostream &Out, key_type_ref Key, data_type_ref Data);
|
/// EmitKeyDataLength(raw_ostream &Out, key_type_ref Key, data_type_ref Data);
|
||||||
/// /// Write Key to Out. KeyLen is the length from EmitKeyDataLength.
|
/// /// Write Key to Out. KeyLen is the length from EmitKeyDataLength.
|
||||||
/// static void EmitKey(raw_ostream &Out, key_type_ref Key, unsigned KeyLen);
|
/// static void EmitKey(raw_ostream &Out, key_type_ref Key,
|
||||||
|
/// offset_type KeyLen);
|
||||||
/// /// Write Data to Out. DataLen is the length from EmitKeyDataLength.
|
/// /// Write Data to Out. DataLen is the length from EmitKeyDataLength.
|
||||||
/// static void EmitData(raw_ostream &Out, key_type_ref Key,
|
/// static void EmitData(raw_ostream &Out, key_type_ref Key,
|
||||||
/// data_type_ref Data, unsigned DataLen);
|
/// data_type_ref Data, offset_type DataLen);
|
||||||
/// };
|
/// };
|
||||||
/// \endcode
|
/// \endcode
|
||||||
template <typename Info> class OnDiskChainedHashTableGenerator {
|
template <typename Info> class OnDiskChainedHashTableGenerator {
|
||||||
@ -227,11 +228,11 @@ public:
|
|||||||
/// /// Read the key from Buffer, given the KeyLen as reported from
|
/// /// Read the key from Buffer, given the KeyLen as reported from
|
||||||
/// /// ReadKeyDataLength.
|
/// /// ReadKeyDataLength.
|
||||||
/// const internal_key_type &ReadKey(const unsigned char *Buffer,
|
/// const internal_key_type &ReadKey(const unsigned char *Buffer,
|
||||||
/// unsigned KeyLen);
|
/// offset_type KeyLen);
|
||||||
/// /// Read the data for Key from Buffer, given the DataLen as reported from
|
/// /// Read the data for Key from Buffer, given the DataLen as reported from
|
||||||
/// /// ReadKeyDataLength.
|
/// /// ReadKeyDataLength.
|
||||||
/// data_type ReadData(StringRef Key, const unsigned char *Buffer,
|
/// data_type ReadData(StringRef Key, const unsigned char *Buffer,
|
||||||
/// unsigned DataLen);
|
/// offset_type DataLen);
|
||||||
/// };
|
/// };
|
||||||
/// \endcode
|
/// \endcode
|
||||||
template <typename Info> class OnDiskChainedHashTable {
|
template <typename Info> class OnDiskChainedHashTable {
|
||||||
@ -268,12 +269,12 @@ public:
|
|||||||
class iterator {
|
class iterator {
|
||||||
internal_key_type Key;
|
internal_key_type Key;
|
||||||
const unsigned char *const Data;
|
const unsigned char *const Data;
|
||||||
const unsigned Len;
|
const offset_type Len;
|
||||||
Info *InfoObj;
|
Info *InfoObj;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
iterator() : Data(0), Len(0) {}
|
iterator() : Data(0), Len(0) {}
|
||||||
iterator(const internal_key_type K, const unsigned char *D, unsigned L,
|
iterator(const internal_key_type K, const unsigned char *D, offset_type L,
|
||||||
Info *InfoObj)
|
Info *InfoObj)
|
||||||
: Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
|
: Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
|
||||||
|
|
||||||
|
@ -42,21 +42,21 @@ public:
|
|||||||
using namespace llvm::support;
|
using namespace llvm::support;
|
||||||
endian::Writer<little> LE(Out);
|
endian::Writer<little> LE(Out);
|
||||||
|
|
||||||
unsigned N = K.size();
|
offset_type N = K.size();
|
||||||
LE.write<offset_type>(N);
|
LE.write<offset_type>(N);
|
||||||
|
|
||||||
unsigned M = (1 + V.Counts.size()) * sizeof(uint64_t);
|
offset_type M = (1 + V.Counts.size()) * sizeof(uint64_t);
|
||||||
LE.write<offset_type>(M);
|
LE.write<offset_type>(M);
|
||||||
|
|
||||||
return std::make_pair(N, M);
|
return std::make_pair(N, M);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EmitKey(raw_ostream &Out, key_type_ref K, unsigned N){
|
static void EmitKey(raw_ostream &Out, key_type_ref K, offset_type N){
|
||||||
Out.write(K.data(), N);
|
Out.write(K.data(), N);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V,
|
static void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V,
|
||||||
unsigned) {
|
offset_type) {
|
||||||
using namespace llvm::support;
|
using namespace llvm::support;
|
||||||
endian::Writer<little> LE(Out);
|
endian::Writer<little> LE(Out);
|
||||||
LE.write<uint64_t>(V.Hash);
|
LE.write<uint64_t>(V.Hash);
|
||||||
|
Reference in New Issue
Block a user