Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 55c1e1b

Browse files
committed
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
1 parent e382065 commit 55c1e1b

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

include/llvm/ProfileData/InstrProfReader.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,11 @@ class InstrProfLookupTrait {
227227
return std::make_pair(KeyLen, DataLen);
228228
}
229229

230-
StringRef ReadKey(const unsigned char *D, unsigned N) {
230+
StringRef ReadKey(const unsigned char *D, offset_type N) {
231231
return StringRef((const char *)D, N);
232232
}
233233

234-
InstrProfRecord ReadData(StringRef K, const unsigned char *D, unsigned N) {
234+
InstrProfRecord ReadData(StringRef K, const unsigned char *D, offset_type N) {
235235
if (N < 2 * sizeof(uint64_t) || N % sizeof(uint64_t)) {
236236
// The data is corrupt, don't try to read it.
237237
CountBuffer.clear();

include/llvm/Support/OnDiskHashTable.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ namespace llvm {
4848
/// static std::pair<offset_type, offset_type>
4949
/// EmitKeyDataLength(raw_ostream &Out, key_type_ref Key, data_type_ref Data);
5050
/// /// Write Key to Out. KeyLen is the length from EmitKeyDataLength.
51-
/// static void EmitKey(raw_ostream &Out, key_type_ref Key, unsigned KeyLen);
51+
/// static void EmitKey(raw_ostream &Out, key_type_ref Key,
52+
/// offset_type KeyLen);
5253
/// /// Write Data to Out. DataLen is the length from EmitKeyDataLength.
5354
/// static void EmitData(raw_ostream &Out, key_type_ref Key,
54-
/// data_type_ref Data, unsigned DataLen);
55+
/// data_type_ref Data, offset_type DataLen);
5556
/// };
5657
/// \endcode
5758
template <typename Info> class OnDiskChainedHashTableGenerator {
@@ -227,11 +228,11 @@ template <typename Info> class OnDiskChainedHashTableGenerator {
227228
/// /// Read the key from Buffer, given the KeyLen as reported from
228229
/// /// ReadKeyDataLength.
229230
/// const internal_key_type &ReadKey(const unsigned char *Buffer,
230-
/// unsigned KeyLen);
231+
/// offset_type KeyLen);
231232
/// /// Read the data for Key from Buffer, given the DataLen as reported from
232233
/// /// ReadKeyDataLength.
233234
/// data_type ReadData(StringRef Key, const unsigned char *Buffer,
234-
/// unsigned DataLen);
235+
/// offset_type DataLen);
235236
/// };
236237
/// \endcode
237238
template <typename Info> class OnDiskChainedHashTable {
@@ -268,12 +269,12 @@ template <typename Info> class OnDiskChainedHashTable {
268269
class iterator {
269270
internal_key_type Key;
270271
const unsigned char *const Data;
271-
const unsigned Len;
272+
const offset_type Len;
272273
Info *InfoObj;
273274

274275
public:
275276
iterator() : Data(0), Len(0) {}
276-
iterator(const internal_key_type K, const unsigned char *D, unsigned L,
277+
iterator(const internal_key_type K, const unsigned char *D, offset_type L,
277278
Info *InfoObj)
278279
: Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
279280

lib/ProfileData/InstrProfWriter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ class InstrProfRecordTrait {
4242
using namespace llvm::support;
4343
endian::Writer<little> LE(Out);
4444

45-
unsigned N = K.size();
45+
offset_type N = K.size();
4646
LE.write<offset_type>(N);
4747

48-
unsigned M = (1 + V.Counts.size()) * sizeof(uint64_t);
48+
offset_type M = (1 + V.Counts.size()) * sizeof(uint64_t);
4949
LE.write<offset_type>(M);
5050

5151
return std::make_pair(N, M);
5252
}
5353

54-
static void EmitKey(raw_ostream &Out, key_type_ref K, unsigned N){
54+
static void EmitKey(raw_ostream &Out, key_type_ref K, offset_type N){
5555
Out.write(K.data(), N);
5656
}
5757

5858
static void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V,
59-
unsigned) {
59+
offset_type) {
6060
using namespace llvm::support;
6161
endian::Writer<little> LE(Out);
6262
LE.write<uint64_t>(V.Hash);

0 commit comments

Comments
 (0)