llvm.org GIT mirror llvm / 55c1e1b
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 Justin Bogner 6 years ago
3 changed file(s) with 13 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
226226 return std::make_pair(KeyLen, DataLen);
227227 }
228228
229 StringRef ReadKey(const unsigned char *D, unsigned N) {
229 StringRef ReadKey(const unsigned char *D, offset_type N) {
230230 return StringRef((const char *)D, N);
231231 }
232232
233 InstrProfRecord ReadData(StringRef K, const unsigned char *D, unsigned N) {
233 InstrProfRecord ReadData(StringRef K, const unsigned char *D, offset_type N) {
234234 if (N < 2 * sizeof(uint64_t) || N % sizeof(uint64_t)) {
235235 // The data is corrupt, don't try to read it.
236236 CountBuffer.clear();
4747 /// static std::pair
4848 /// EmitKeyDataLength(raw_ostream &Out, key_type_ref Key, data_type_ref Data);
4949 /// /// Write Key to Out. KeyLen is the length from EmitKeyDataLength.
50 /// static void EmitKey(raw_ostream &Out, key_type_ref Key, unsigned KeyLen);
50 /// static void EmitKey(raw_ostream &Out, key_type_ref Key,
51 /// offset_type KeyLen);
5152 /// /// Write Data to Out. DataLen is the length from EmitKeyDataLength.
5253 /// static void EmitData(raw_ostream &Out, key_type_ref Key,
53 /// data_type_ref Data, unsigned DataLen);
54 /// data_type_ref Data, offset_type DataLen);
5455 /// };
5556 /// \endcode
5657 template class OnDiskChainedHashTableGenerator {
226227 /// /// Read the key from Buffer, given the KeyLen as reported from
227228 /// /// ReadKeyDataLength.
228229 /// const internal_key_type &ReadKey(const unsigned char *Buffer,
229 /// unsigned KeyLen);
230 /// offset_type KeyLen);
230231 /// /// Read the data for Key from Buffer, given the DataLen as reported from
231232 /// /// ReadKeyDataLength.
232233 /// data_type ReadData(StringRef Key, const unsigned char *Buffer,
233 /// unsigned DataLen);
234 /// offset_type DataLen);
234235 /// };
235236 /// \endcode
236237 template class OnDiskChainedHashTable {
267268 class iterator {
268269 internal_key_type Key;
269270 const unsigned char *const Data;
270 const unsigned Len;
271 const offset_type Len;
271272 Info *InfoObj;
272273
273274 public:
274275 iterator() : Data(0), Len(0) {}
275 iterator(const internal_key_type K, const unsigned char *D, unsigned L,
276 iterator(const internal_key_type K, const unsigned char *D, offset_type L,
276277 Info *InfoObj)
277278 : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
278279
4141 using namespace llvm::support;
4242 endian::Writer LE(Out);
4343
44 unsigned N = K.size();
44 offset_type N = K.size();
4545 LE.write(N);
4646
47 unsigned M = (1 + V.Counts.size()) * sizeof(uint64_t);
47 offset_type M = (1 + V.Counts.size()) * sizeof(uint64_t);
4848 LE.write(M);
4949
5050 return std::make_pair(N, M);
5151 }
5252
53 static void EmitKey(raw_ostream &Out, key_type_ref K, unsigned N){
53 static void EmitKey(raw_ostream &Out, key_type_ref K, offset_type N){
5454 Out.write(K.data(), N);
5555 }
5656
5757 static void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V,
58 unsigned) {
58 offset_type) {
5959 using namespace llvm::support;
6060 endian::Writer LE(Out);
6161 LE.write(V.Hash);