Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/Support/OnDiskHashTable.h
Line
Count
Source
1
//===--- OnDiskHashTable.h - On-Disk Hash Table Implementation --*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// Defines facilities for reading and writing on-disk hash tables.
11
///
12
//===----------------------------------------------------------------------===//
13
#ifndef LLVM_SUPPORT_ONDISKHASHTABLE_H
14
#define LLVM_SUPPORT_ONDISKHASHTABLE_H
15
16
#include "llvm/Support/Allocator.h"
17
#include "llvm/Support/DataTypes.h"
18
#include "llvm/Support/EndianStream.h"
19
#include "llvm/Support/Host.h"
20
#include "llvm/Support/MathExtras.h"
21
#include "llvm/Support/raw_ostream.h"
22
#include <cassert>
23
#include <cstdlib>
24
25
namespace llvm {
26
27
/// Generates an on disk hash table.
28
///
29
/// This needs an \c Info that handles storing values into the hash table's
30
/// payload and computes the hash for a given key. This should provide the
31
/// following interface:
32
///
33
/// \code
34
/// class ExampleInfo {
35
/// public:
36
///   typedef ExampleKey key_type;   // Must be copy constructible
37
///   typedef ExampleKey &key_type_ref;
38
///   typedef ExampleData data_type; // Must be copy constructible
39
///   typedef ExampleData &data_type_ref;
40
///   typedef uint32_t hash_value_type; // The type the hash function returns.
41
///   typedef uint32_t offset_type; // The type for offsets into the table.
42
///
43
///   /// Calculate the hash for Key
44
///   static hash_value_type ComputeHash(key_type_ref Key);
45
///   /// Return the lengths, in bytes, of the given Key/Data pair.
46
///   static std::pair<offset_type, offset_type>
47
///   EmitKeyDataLength(raw_ostream &Out, key_type_ref Key, data_type_ref Data);
48
///   /// Write Key to Out.  KeyLen is the length from EmitKeyDataLength.
49
///   static void EmitKey(raw_ostream &Out, key_type_ref Key,
50
///                       offset_type KeyLen);
51
///   /// Write Data to Out.  DataLen is the length from EmitKeyDataLength.
52
///   static void EmitData(raw_ostream &Out, key_type_ref Key,
53
///                        data_type_ref Data, offset_type DataLen);
54
///   /// Determine if two keys are equal. Optional, only needed by contains.
55
///   static bool EqualKey(key_type_ref Key1, key_type_ref Key2);
56
/// };
57
/// \endcode
58
template <typename Info> class OnDiskChainedHashTableGenerator {
59
  /// A single item in the hash table.
60
  class Item {
61
  public:
62
    typename Info::key_type Key;
63
    typename Info::data_type Data;
64
    Item *Next;
65
    const typename Info::hash_value_type Hash;
66
67
    Item(typename Info::key_type_ref Key, typename Info::data_type_ref Data,
68
         Info &InfoObj)
69
5.80M
        : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::Item::Item((anonymous namespace)::HeaderFileInfoTrait::key_type const&, (anonymous namespace)::HeaderFileInfoTrait::data_type const&, (anonymous namespace)::HeaderFileInfoTrait&)
Line
Count
Source
69
5.69k
        : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::Item::Item(clang::Selector, (anonymous namespace)::ASTMethodPoolTrait::data_type const&, (anonymous namespace)::ASTMethodPoolTrait&)
Line
Count
Source
69
550
        : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::Item::Item(clang::IdentifierInfo*, unsigned int, (anonymous namespace)::ASTIdentifierTableTrait&)
Line
Count
Source
69
5.65M
        : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::Item::Item(clang::serialization::DeclarationNameKey, std::__1::pair<unsigned int, unsigned int> const&, (anonymous namespace)::ASTDeclContextNameLookupTrait&)
Line
Count
Source
69
50.4k
        : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::Item::Item(llvm::StringRef, llvm::SmallVector<unsigned int, 2u> const&, (anonymous namespace)::IdentifierIndexWriterTrait&)
Line
Count
Source
69
89.8k
        : Key(Key), Data(Data), Next(nullptr), Hash(InfoObj.ComputeHash(Key)) {}
70
  };
71
72
  typedef typename Info::offset_type offset_type;
73
  offset_type NumBuckets;
74
  offset_type NumEntries;
75
  llvm::SpecificBumpPtrAllocator<Item> BA;
76
77
  /// A linked list of values in a particular hash bucket.
78
  struct Bucket {
79
    offset_type Off;
80
    unsigned Length;
81
    Item *Head;
82
  };
83
84
  Bucket *Buckets;
85
86
private:
87
  /// Insert an item into the appropriate hash bucket.
88
16.1M
  void insert(Bucket *Buckets, size_t Size, Item *E) {
89
16.1M
    Bucket &B = Buckets[E->Hash & (Size - 1)];
90
16.1M
    E->Next = B.Head;
91
16.1M
    ++B.Length;
92
16.1M
    B.Head = E;
93
16.1M
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::insert(llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::Bucket*, unsigned long, llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::Item*)
Line
Count
Source
88
11.0k
  void insert(Bucket *Buckets, size_t Size, Item *E) {
89
11.0k
    Bucket &B = Buckets[E->Hash & (Size - 1)];
90
11.0k
    E->Next = B.Head;
91
11.0k
    ++B.Length;
92
11.0k
    B.Head = E;
93
11.0k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::insert(llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::Bucket*, unsigned long, llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::Item*)
Line
Count
Source
88
1.10k
  void insert(Bucket *Buckets, size_t Size, Item *E) {
89
1.10k
    Bucket &B = Buckets[E->Hash & (Size - 1)];
90
1.10k
    E->Next = B.Head;
91
1.10k
    ++B.Length;
92
1.10k
    B.Head = E;
93
1.10k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::insert(llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::Bucket*, unsigned long, llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::Item*)
Line
Count
Source
88
15.8M
  void insert(Bucket *Buckets, size_t Size, Item *E) {
89
15.8M
    Bucket &B = Buckets[E->Hash & (Size - 1)];
90
15.8M
    E->Next = B.Head;
91
15.8M
    ++B.Length;
92
15.8M
    B.Head = E;
93
15.8M
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::insert(llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::Bucket*, unsigned long, llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::Item*)
Line
Count
Source
88
98.6k
  void insert(Bucket *Buckets, size_t Size, Item *E) {
89
98.6k
    Bucket &B = Buckets[E->Hash & (Size - 1)];
90
98.6k
    E->Next = B.Head;
91
98.6k
    ++B.Length;
92
98.6k
    B.Head = E;
93
98.6k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::insert(llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::Bucket*, unsigned long, llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::Item*)
Line
Count
Source
88
207k
  void insert(Bucket *Buckets, size_t Size, Item *E) {
89
207k
    Bucket &B = Buckets[E->Hash & (Size - 1)];
90
207k
    E->Next = B.Head;
91
207k
    ++B.Length;
92
207k
    B.Head = E;
93
207k
  }
94
95
  /// Resize the hash table, moving the old entries into the new buckets.
96
30.8k
  void resize(size_t NewSize) {
97
30.8k
    Bucket *NewBuckets = static_cast<Bucket *>(
98
30.8k
        safe_calloc(NewSize, sizeof(Bucket)));
99
30.8k
    // Populate NewBuckets with the old entries.
100
14.8M
    for (size_t I = 0; I < NumBuckets; 
++I14.8M
)
101
25.2M
      
for (Item *E = Buckets[I].Head; 14.8M
E;) {
102
10.3M
        Item *N = E->Next;
103
10.3M
        E->Next = nullptr;
104
10.3M
        insert(NewBuckets, NewSize, E);
105
10.3M
        E = N;
106
10.3M
      }
107
30.8k
108
30.8k
    free(Buckets);
109
30.8k
    NumBuckets = NewSize;
110
30.8k
    Buckets = NewBuckets;
111
30.8k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::resize(unsigned long)
Line
Count
Source
96
3.61k
  void resize(size_t NewSize) {
97
3.61k
    Bucket *NewBuckets = static_cast<Bucket *>(
98
3.61k
        safe_calloc(NewSize, sizeof(Bucket)));
99
3.61k
    // Populate NewBuckets with the old entries.
100
235k
    for (size_t I = 0; I < NumBuckets; 
++I231k
)
101
236k
      
for (Item *E = Buckets[I].Head; 231k
E;) {
102
5.32k
        Item *N = E->Next;
103
5.32k
        E->Next = nullptr;
104
5.32k
        insert(NewBuckets, NewSize, E);
105
5.32k
        E = N;
106
5.32k
      }
107
3.61k
108
3.61k
    free(Buckets);
109
3.61k
    NumBuckets = NewSize;
110
3.61k
    Buckets = NewBuckets;
111
3.61k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::resize(unsigned long)
Line
Count
Source
96
176
  void resize(size_t NewSize) {
97
176
    Bucket *NewBuckets = static_cast<Bucket *>(
98
176
        safe_calloc(NewSize, sizeof(Bucket)));
99
176
    // Populate NewBuckets with the old entries.
100
11.4k
    for (size_t I = 0; I < NumBuckets; 
++I11.2k
)
101
11.8k
      
for (Item *E = Buckets[I].Head; 11.2k
E;) {
102
550
        Item *N = E->Next;
103
550
        E->Next = nullptr;
104
550
        insert(NewBuckets, NewSize, E);
105
550
        E = N;
106
550
      }
107
176
108
176
    free(Buckets);
109
176
    NumBuckets = NewSize;
110
176
    Buckets = NewBuckets;
111
176
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::resize(unsigned long)
Line
Count
Source
96
15.3k
  void resize(size_t NewSize) {
97
15.3k
    Bucket *NewBuckets = static_cast<Bucket *>(
98
15.3k
        safe_calloc(NewSize, sizeof(Bucket)));
99
15.3k
    // Populate NewBuckets with the old entries.
100
13.7M
    for (size_t I = 0; I < NumBuckets; 
++I13.7M
)
101
23.9M
      
for (Item *E = Buckets[I].Head; 13.7M
E;) {
102
10.2M
        Item *N = E->Next;
103
10.2M
        E->Next = nullptr;
104
10.2M
        insert(NewBuckets, NewSize, E);
105
10.2M
        E = N;
106
10.2M
      }
107
15.3k
108
15.3k
    free(Buckets);
109
15.3k
    NumBuckets = NewSize;
110
15.3k
    Buckets = NewBuckets;
111
15.3k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::resize(unsigned long)
Line
Count
Source
96
11.0k
  void resize(size_t NewSize) {
97
11.0k
    Bucket *NewBuckets = static_cast<Bucket *>(
98
11.0k
        safe_calloc(NewSize, sizeof(Bucket)));
99
11.0k
    // Populate NewBuckets with the old entries.
100
717k
    for (size_t I = 0; I < NumBuckets; 
++I706k
)
101
755k
      
for (Item *E = Buckets[I].Head; 706k
E;) {
102
48.2k
        Item *N = E->Next;
103
48.2k
        E->Next = nullptr;
104
48.2k
        insert(NewBuckets, NewSize, E);
105
48.2k
        E = N;
106
48.2k
      }
107
11.0k
108
11.0k
    free(Buckets);
109
11.0k
    NumBuckets = NewSize;
110
11.0k
    Buckets = NewBuckets;
111
11.0k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::resize(unsigned long)
Line
Count
Source
96
690
  void resize(size_t NewSize) {
97
690
    Bucket *NewBuckets = static_cast<Bucket *>(
98
690
        safe_calloc(NewSize, sizeof(Bucket)));
99
690
    // Populate NewBuckets with the old entries.
100
181k
    for (size_t I = 0; I < NumBuckets; 
++I180k
)
101
298k
      
for (Item *E = Buckets[I].Head; 180k
E;) {
102
117k
        Item *N = E->Next;
103
117k
        E->Next = nullptr;
104
117k
        insert(NewBuckets, NewSize, E);
105
117k
        E = N;
106
117k
      }
107
690
108
690
    free(Buckets);
109
690
    NumBuckets = NewSize;
110
690
    Buckets = NewBuckets;
111
690
  }
112
113
public:
114
  /// Insert an entry into the table.
115
  void insert(typename Info::key_type_ref Key,
116
              typename Info::data_type_ref Data) {
117
    Info InfoObj;
118
    insert(Key, Data, InfoObj);
119
  }
120
121
  /// Insert an entry into the table.
122
  ///
123
  /// Uses the provided Info instead of a stack allocated one.
124
  void insert(typename Info::key_type_ref Key,
125
5.80M
              typename Info::data_type_ref Data, Info &InfoObj) {
126
5.80M
    ++NumEntries;
127
5.80M
    if (4 * NumEntries >= 3 * NumBuckets)
128
14.1k
      resize(NumBuckets * 2);
129
5.80M
    insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
130
5.80M
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::insert((anonymous namespace)::HeaderFileInfoTrait::key_type const&, (anonymous namespace)::HeaderFileInfoTrait::data_type const&, (anonymous namespace)::HeaderFileInfoTrait&)
Line
Count
Source
125
5.69k
              typename Info::data_type_ref Data, Info &InfoObj) {
126
5.69k
    ++NumEntries;
127
5.69k
    if (4 * NumEntries >= 3 * NumBuckets)
128
6
      resize(NumBuckets * 2);
129
5.69k
    insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
130
5.69k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::insert(clang::Selector, (anonymous namespace)::ASTMethodPoolTrait::data_type const&, (anonymous namespace)::ASTMethodPoolTrait&)
Line
Count
Source
125
550
              typename Info::data_type_ref Data, Info &InfoObj) {
126
550
    ++NumEntries;
127
550
    if (4 * NumEntries >= 3 * NumBuckets)
128
0
      resize(NumBuckets * 2);
129
550
    insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
130
550
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::insert(clang::IdentifierInfo*, unsigned int, (anonymous namespace)::ASTIdentifierTableTrait&)
Line
Count
Source
125
5.65M
              typename Info::data_type_ref Data, Info &InfoObj) {
126
5.65M
    ++NumEntries;
127
5.65M
    if (4 * NumEntries >= 3 * NumBuckets)
128
13.9k
      resize(NumBuckets * 2);
129
5.65M
    insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
130
5.65M
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::insert(clang::serialization::DeclarationNameKey, std::__1::pair<unsigned int, unsigned int> const&, (anonymous namespace)::ASTDeclContextNameLookupTrait&)
Line
Count
Source
125
50.4k
              typename Info::data_type_ref Data, Info &InfoObj) {
126
50.4k
    ++NumEntries;
127
50.4k
    if (4 * NumEntries >= 3 * NumBuckets)
128
34
      resize(NumBuckets * 2);
129
50.4k
    insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
130
50.4k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::insert(llvm::StringRef, llvm::SmallVector<unsigned int, 2u> const&, (anonymous namespace)::IdentifierIndexWriterTrait&)
Line
Count
Source
125
89.8k
              typename Info::data_type_ref Data, Info &InfoObj) {
126
89.8k
    ++NumEntries;
127
89.8k
    if (4 * NumEntries >= 3 * NumBuckets)
128
214
      resize(NumBuckets * 2);
129
89.8k
    insert(Buckets, NumBuckets, new (BA.Allocate()) Item(Key, Data, InfoObj));
130
89.8k
  }
131
132
  /// Determine whether an entry has been inserted.
133
128
  bool contains(typename Info::key_type_ref Key, Info &InfoObj) {
134
128
    unsigned Hash = InfoObj.ComputeHash(Key);
135
144
    for (Item *I = Buckets[Hash & (NumBuckets - 1)].Head; I; 
I = I->Next16
)
136
131
      if (I->Hash == Hash && 
InfoObj.EqualKey(I->Key, Key)115
)
137
115
        return true;
138
128
    
return false13
;
139
128
  }
140
141
  /// Emit the table to Out, which must not be at offset 0.
142
  offset_type Emit(raw_ostream &Out) {
143
    Info InfoObj;
144
    return Emit(Out, InfoObj);
145
  }
146
147
  /// Emit the table to Out, which must not be at offset 0.
148
  ///
149
  /// Uses the provided Info instead of a stack allocated one.
150
19.1k
  offset_type Emit(raw_ostream &Out, Info &InfoObj) {
151
19.1k
    using namespace llvm::support;
152
19.1k
    endian::Writer LE(Out, little);
153
19.1k
154
19.1k
    // Now we're done adding entries, resize the bucket list if it's
155
19.1k
    // significantly too large. (This only happens if the number of
156
19.1k
    // entries is small and we're within our initial allocation of
157
19.1k
    // 64 buckets.) We aim for an occupancy ratio in [3/8, 3/4).
158
19.1k
    //
159
19.1k
    // As a special case, if there are two or fewer entries, just
160
19.1k
    // form a single bucket. A linear scan is fine in that case, and
161
19.1k
    // this is very common in C++ class lookup tables. This also
162
19.1k
    // guarantees we produce at least one bucket for an empty table.
163
19.1k
    //
164
19.1k
    // FIXME: Try computing a perfect hash function at this point.
165
19.1k
    unsigned TargetNumBuckets =
166
19.1k
        NumEntries <= 2 ? 
18.12k
:
NextPowerOf2(NumEntries * 4 / 3)11.0k
;
167
19.1k
    if (TargetNumBuckets != NumBuckets)
168
16.6k
      resize(TargetNumBuckets);
169
19.1k
170
19.1k
    // Emit the payload of the table.
171
14.0M
    for (offset_type I = 0; I < NumBuckets; 
++I14.0M
) {
172
14.0M
      Bucket &B = Buckets[I];
173
14.0M
      if (!B.Head)
174
9.34M
        continue;
175
4.70M
176
4.70M
      // Store the offset for the data of this bucket.
177
4.70M
      B.Off = Out.tell();
178
4.70M
      assert(B.Off && "Cannot write a bucket at offset 0. Please add padding.");
179
4.70M
180
4.70M
      // Write out the number of items in the bucket.
181
4.70M
      LE.write<uint16_t>(B.Length);
182
4.70M
      assert(B.Length != 0 && "Bucket has a head but zero length?");
183
4.70M
184
4.70M
      // Write out the entries in the bucket.
185
10.5M
      for (Item *I = B.Head; I; 
I = I->Next5.80M
) {
186
5.80M
        LE.write<typename Info::hash_value_type>(I->Hash);
187
5.80M
        const std::pair<offset_type, offset_type> &Len =
188
5.80M
            InfoObj.EmitKeyDataLength(Out, I->Key, I->Data);
189
5.80M
#ifdef NDEBUG
190
5.80M
        InfoObj.EmitKey(Out, I->Key, Len.first);
191
5.80M
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
192
#else
193
        // In asserts mode, check that the users length matches the data they
194
        // wrote.
195
        uint64_t KeyStart = Out.tell();
196
        InfoObj.EmitKey(Out, I->Key, Len.first);
197
        uint64_t DataStart = Out.tell();
198
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
199
        uint64_t End = Out.tell();
200
        assert(offset_type(DataStart - KeyStart) == Len.first &&
201
               "key length does not match bytes written");
202
        assert(offset_type(End - DataStart) == Len.second &&
203
               "data length does not match bytes written");
204
#endif
205
      }
206
4.70M
    }
207
19.1k
208
19.1k
    // Pad with zeros so that we can start the hashtable at an aligned address.
209
19.1k
    offset_type TableOff = Out.tell();
210
19.1k
    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
211
19.1k
    TableOff += N;
212
45.5k
    while (N--)
213
26.4k
      LE.write<uint8_t>(0);
214
19.1k
215
19.1k
    // Emit the hashtable itself.
216
19.1k
    LE.write<offset_type>(NumBuckets);
217
19.1k
    LE.write<offset_type>(NumEntries);
218
14.0M
    for (offset_type I = 0; I < NumBuckets; 
++I14.0M
)
219
14.0M
      LE.write<offset_type>(Buckets[I].Off);
220
19.1k
221
19.1k
    return TableOff;
222
19.1k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::Emit(llvm::raw_ostream&, (anonymous namespace)::HeaderFileInfoTrait&)
Line
Count
Source
150
3.61k
  offset_type Emit(raw_ostream &Out, Info &InfoObj) {
151
3.61k
    using namespace llvm::support;
152
3.61k
    endian::Writer LE(Out, little);
153
3.61k
154
3.61k
    // Now we're done adding entries, resize the bucket list if it's
155
3.61k
    // significantly too large. (This only happens if the number of
156
3.61k
    // entries is small and we're within our initial allocation of
157
3.61k
    // 64 buckets.) We aim for an occupancy ratio in [3/8, 3/4).
158
3.61k
    //
159
3.61k
    // As a special case, if there are two or fewer entries, just
160
3.61k
    // form a single bucket. A linear scan is fine in that case, and
161
3.61k
    // this is very common in C++ class lookup tables. This also
162
3.61k
    // guarantees we produce at least one bucket for an empty table.
163
3.61k
    //
164
3.61k
    // FIXME: Try computing a perfect hash function at this point.
165
3.61k
    unsigned TargetNumBuckets =
166
3.61k
        NumEntries <= 2 ? 
13.35k
:
NextPowerOf2(NumEntries * 4 / 3)266
;
167
3.61k
    if (TargetNumBuckets != NumBuckets)
168
3.61k
      resize(TargetNumBuckets);
169
3.61k
170
3.61k
    // Emit the payload of the table.
171
10.2k
    for (offset_type I = 0; I < NumBuckets; 
++I6.67k
) {
172
6.67k
      Bucket &B = Buckets[I];
173
6.67k
      if (!B.Head)
174
1.87k
        continue;
175
4.79k
176
4.79k
      // Store the offset for the data of this bucket.
177
4.79k
      B.Off = Out.tell();
178
4.79k
      assert(B.Off && "Cannot write a bucket at offset 0. Please add padding.");
179
4.79k
180
4.79k
      // Write out the number of items in the bucket.
181
4.79k
      LE.write<uint16_t>(B.Length);
182
4.79k
      assert(B.Length != 0 && "Bucket has a head but zero length?");
183
4.79k
184
4.79k
      // Write out the entries in the bucket.
185
10.4k
      for (Item *I = B.Head; I; 
I = I->Next5.69k
) {
186
5.69k
        LE.write<typename Info::hash_value_type>(I->Hash);
187
5.69k
        const std::pair<offset_type, offset_type> &Len =
188
5.69k
            InfoObj.EmitKeyDataLength(Out, I->Key, I->Data);
189
5.69k
#ifdef NDEBUG
190
5.69k
        InfoObj.EmitKey(Out, I->Key, Len.first);
191
5.69k
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
192
#else
193
        // In asserts mode, check that the users length matches the data they
194
        // wrote.
195
        uint64_t KeyStart = Out.tell();
196
        InfoObj.EmitKey(Out, I->Key, Len.first);
197
        uint64_t DataStart = Out.tell();
198
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
199
        uint64_t End = Out.tell();
200
        assert(offset_type(DataStart - KeyStart) == Len.first &&
201
               "key length does not match bytes written");
202
        assert(offset_type(End - DataStart) == Len.second &&
203
               "data length does not match bytes written");
204
#endif
205
      }
206
4.79k
    }
207
3.61k
208
3.61k
    // Pad with zeros so that we can start the hashtable at an aligned address.
209
3.61k
    offset_type TableOff = Out.tell();
210
3.61k
    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
211
3.61k
    TableOff += N;
212
8.46k
    while (N--)
213
4.85k
      LE.write<uint8_t>(0);
214
3.61k
215
3.61k
    // Emit the hashtable itself.
216
3.61k
    LE.write<offset_type>(NumBuckets);
217
3.61k
    LE.write<offset_type>(NumEntries);
218
10.2k
    for (offset_type I = 0; I < NumBuckets; 
++I6.67k
)
219
6.67k
      LE.write<offset_type>(Buckets[I].Off);
220
3.61k
221
3.61k
    return TableOff;
222
3.61k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::Emit(llvm::raw_ostream&, (anonymous namespace)::ASTMethodPoolTrait&)
Line
Count
Source
150
176
  offset_type Emit(raw_ostream &Out, Info &InfoObj) {
151
176
    using namespace llvm::support;
152
176
    endian::Writer LE(Out, little);
153
176
154
176
    // Now we're done adding entries, resize the bucket list if it's
155
176
    // significantly too large. (This only happens if the number of
156
176
    // entries is small and we're within our initial allocation of
157
176
    // 64 buckets.) We aim for an occupancy ratio in [3/8, 3/4).
158
176
    //
159
176
    // As a special case, if there are two or fewer entries, just
160
176
    // form a single bucket. A linear scan is fine in that case, and
161
176
    // this is very common in C++ class lookup tables. This also
162
176
    // guarantees we produce at least one bucket for an empty table.
163
176
    //
164
176
    // FIXME: Try computing a perfect hash function at this point.
165
176
    unsigned TargetNumBuckets =
166
176
        NumEntries <= 2 ? 
1121
:
NextPowerOf2(NumEntries * 4 / 3)55
;
167
176
    if (TargetNumBuckets != NumBuckets)
168
176
      resize(TargetNumBuckets);
169
176
170
176
    // Emit the payload of the table.
171
1.05k
    for (offset_type I = 0; I < NumBuckets; 
++I881
) {
172
881
      Bucket &B = Buckets[I];
173
881
      if (!B.Head)
174
454
        continue;
175
427
176
427
      // Store the offset for the data of this bucket.
177
427
      B.Off = Out.tell();
178
427
      assert(B.Off && "Cannot write a bucket at offset 0. Please add padding.");
179
427
180
427
      // Write out the number of items in the bucket.
181
427
      LE.write<uint16_t>(B.Length);
182
427
      assert(B.Length != 0 && "Bucket has a head but zero length?");
183
427
184
427
      // Write out the entries in the bucket.
185
977
      for (Item *I = B.Head; I; 
I = I->Next550
) {
186
550
        LE.write<typename Info::hash_value_type>(I->Hash);
187
550
        const std::pair<offset_type, offset_type> &Len =
188
550
            InfoObj.EmitKeyDataLength(Out, I->Key, I->Data);
189
550
#ifdef NDEBUG
190
550
        InfoObj.EmitKey(Out, I->Key, Len.first);
191
550
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
192
#else
193
        // In asserts mode, check that the users length matches the data they
194
        // wrote.
195
        uint64_t KeyStart = Out.tell();
196
        InfoObj.EmitKey(Out, I->Key, Len.first);
197
        uint64_t DataStart = Out.tell();
198
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
199
        uint64_t End = Out.tell();
200
        assert(offset_type(DataStart - KeyStart) == Len.first &&
201
               "key length does not match bytes written");
202
        assert(offset_type(End - DataStart) == Len.second &&
203
               "data length does not match bytes written");
204
#endif
205
      }
206
427
    }
207
176
208
176
    // Pad with zeros so that we can start the hashtable at an aligned address.
209
176
    offset_type TableOff = Out.tell();
210
176
    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
211
176
    TableOff += N;
212
354
    while (N--)
213
178
      LE.write<uint8_t>(0);
214
176
215
176
    // Emit the hashtable itself.
216
176
    LE.write<offset_type>(NumBuckets);
217
176
    LE.write<offset_type>(NumEntries);
218
1.05k
    for (offset_type I = 0; I < NumBuckets; 
++I881
)
219
881
      LE.write<offset_type>(Buckets[I].Off);
220
176
221
176
    return TableOff;
222
176
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::Emit(llvm::raw_ostream&, (anonymous namespace)::ASTIdentifierTableTrait&)
Line
Count
Source
150
3.61k
  offset_type Emit(raw_ostream &Out, Info &InfoObj) {
151
3.61k
    using namespace llvm::support;
152
3.61k
    endian::Writer LE(Out, little);
153
3.61k
154
3.61k
    // Now we're done adding entries, resize the bucket list if it's
155
3.61k
    // significantly too large. (This only happens if the number of
156
3.61k
    // entries is small and we're within our initial allocation of
157
3.61k
    // 64 buckets.) We aim for an occupancy ratio in [3/8, 3/4).
158
3.61k
    //
159
3.61k
    // As a special case, if there are two or fewer entries, just
160
3.61k
    // form a single bucket. A linear scan is fine in that case, and
161
3.61k
    // this is very common in C++ class lookup tables. This also
162
3.61k
    // guarantees we produce at least one bucket for an empty table.
163
3.61k
    //
164
3.61k
    // FIXME: Try computing a perfect hash function at this point.
165
3.61k
    unsigned TargetNumBuckets =
166
3.61k
        NumEntries <= 2 ? 
1311
:
NextPowerOf2(NumEntries * 4 / 3)3.30k
;
167
3.61k
    if (TargetNumBuckets != NumBuckets)
168
1.35k
      resize(TargetNumBuckets);
169
3.61k
170
3.61k
    // Emit the payload of the table.
171
13.7M
    for (offset_type I = 0; I < NumBuckets; 
++I13.7M
) {
172
13.7M
      Bucket &B = Buckets[I];
173
13.7M
      if (!B.Head)
174
9.18M
        continue;
175
4.59M
176
4.59M
      // Store the offset for the data of this bucket.
177
4.59M
      B.Off = Out.tell();
178
4.59M
      assert(B.Off && "Cannot write a bucket at offset 0. Please add padding.");
179
4.59M
180
4.59M
      // Write out the number of items in the bucket.
181
4.59M
      LE.write<uint16_t>(B.Length);
182
4.59M
      assert(B.Length != 0 && "Bucket has a head but zero length?");
183
4.59M
184
4.59M
      // Write out the entries in the bucket.
185
10.2M
      for (Item *I = B.Head; I; 
I = I->Next5.65M
) {
186
5.65M
        LE.write<typename Info::hash_value_type>(I->Hash);
187
5.65M
        const std::pair<offset_type, offset_type> &Len =
188
5.65M
            InfoObj.EmitKeyDataLength(Out, I->Key, I->Data);
189
5.65M
#ifdef NDEBUG
190
5.65M
        InfoObj.EmitKey(Out, I->Key, Len.first);
191
5.65M
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
192
#else
193
        // In asserts mode, check that the users length matches the data they
194
        // wrote.
195
        uint64_t KeyStart = Out.tell();
196
        InfoObj.EmitKey(Out, I->Key, Len.first);
197
        uint64_t DataStart = Out.tell();
198
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
199
        uint64_t End = Out.tell();
200
        assert(offset_type(DataStart - KeyStart) == Len.first &&
201
               "key length does not match bytes written");
202
        assert(offset_type(End - DataStart) == Len.second &&
203
               "data length does not match bytes written");
204
#endif
205
      }
206
4.59M
    }
207
3.61k
208
3.61k
    // Pad with zeros so that we can start the hashtable at an aligned address.
209
3.61k
    offset_type TableOff = Out.tell();
210
3.61k
    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
211
3.61k
    TableOff += N;
212
9.51k
    while (N--)
213
5.89k
      LE.write<uint8_t>(0);
214
3.61k
215
3.61k
    // Emit the hashtable itself.
216
3.61k
    LE.write<offset_type>(NumBuckets);
217
3.61k
    LE.write<offset_type>(NumEntries);
218
13.7M
    for (offset_type I = 0; I < NumBuckets; 
++I13.7M
)
219
13.7M
      LE.write<offset_type>(Buckets[I].Off);
220
3.61k
221
3.61k
    return TableOff;
222
3.61k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::Emit(llvm::raw_ostream&, (anonymous namespace)::ASTDeclContextNameLookupTrait&)
Line
Count
Source
150
11.0k
  offset_type Emit(raw_ostream &Out, Info &InfoObj) {
151
11.0k
    using namespace llvm::support;
152
11.0k
    endian::Writer LE(Out, little);
153
11.0k
154
11.0k
    // Now we're done adding entries, resize the bucket list if it's
155
11.0k
    // significantly too large. (This only happens if the number of
156
11.0k
    // entries is small and we're within our initial allocation of
157
11.0k
    // 64 buckets.) We aim for an occupancy ratio in [3/8, 3/4).
158
11.0k
    //
159
11.0k
    // As a special case, if there are two or fewer entries, just
160
11.0k
    // form a single bucket. A linear scan is fine in that case, and
161
11.0k
    // this is very common in C++ class lookup tables. This also
162
11.0k
    // guarantees we produce at least one bucket for an empty table.
163
11.0k
    //
164
11.0k
    // FIXME: Try computing a perfect hash function at this point.
165
11.0k
    unsigned TargetNumBuckets =
166
11.0k
        NumEntries <= 2 ? 
14.32k
:
NextPowerOf2(NumEntries * 4 / 3)6.76k
;
167
11.0k
    if (TargetNumBuckets != NumBuckets)
168
10.9k
      resize(TargetNumBuckets);
169
11.0k
170
11.0k
    // Emit the payload of the table.
171
106k
    for (offset_type I = 0; I < NumBuckets; 
++I95.0k
) {
172
95.0k
      Bucket &B = Buckets[I];
173
95.0k
      if (!B.Head)
174
56.7k
        continue;
175
38.2k
176
38.2k
      // Store the offset for the data of this bucket.
177
38.2k
      B.Off = Out.tell();
178
38.2k
      assert(B.Off && "Cannot write a bucket at offset 0. Please add padding.");
179
38.2k
180
38.2k
      // Write out the number of items in the bucket.
181
38.2k
      LE.write<uint16_t>(B.Length);
182
38.2k
      assert(B.Length != 0 && "Bucket has a head but zero length?");
183
38.2k
184
38.2k
      // Write out the entries in the bucket.
185
88.6k
      for (Item *I = B.Head; I; 
I = I->Next50.4k
) {
186
50.4k
        LE.write<typename Info::hash_value_type>(I->Hash);
187
50.4k
        const std::pair<offset_type, offset_type> &Len =
188
50.4k
            InfoObj.EmitKeyDataLength(Out, I->Key, I->Data);
189
50.4k
#ifdef NDEBUG
190
50.4k
        InfoObj.EmitKey(Out, I->Key, Len.first);
191
50.4k
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
192
#else
193
        // In asserts mode, check that the users length matches the data they
194
        // wrote.
195
        uint64_t KeyStart = Out.tell();
196
        InfoObj.EmitKey(Out, I->Key, Len.first);
197
        uint64_t DataStart = Out.tell();
198
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
199
        uint64_t End = Out.tell();
200
        assert(offset_type(DataStart - KeyStart) == Len.first &&
201
               "key length does not match bytes written");
202
        assert(offset_type(End - DataStart) == Len.second &&
203
               "data length does not match bytes written");
204
#endif
205
      }
206
38.2k
    }
207
11.0k
208
11.0k
    // Pad with zeros so that we can start the hashtable at an aligned address.
209
11.0k
    offset_type TableOff = Out.tell();
210
11.0k
    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
211
11.0k
    TableOff += N;
212
25.8k
    while (N--)
213
14.7k
      LE.write<uint8_t>(0);
214
11.0k
215
11.0k
    // Emit the hashtable itself.
216
11.0k
    LE.write<offset_type>(NumBuckets);
217
11.0k
    LE.write<offset_type>(NumEntries);
218
106k
    for (offset_type I = 0; I < NumBuckets; 
++I95.0k
)
219
95.0k
      LE.write<offset_type>(Buckets[I].Off);
220
11.0k
221
11.0k
    return TableOff;
222
11.0k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::Emit(llvm::raw_ostream&, (anonymous namespace)::IdentifierIndexWriterTrait&)
Line
Count
Source
150
621
  offset_type Emit(raw_ostream &Out, Info &InfoObj) {
151
621
    using namespace llvm::support;
152
621
    endian::Writer LE(Out, little);
153
621
154
621
    // Now we're done adding entries, resize the bucket list if it's
155
621
    // significantly too large. (This only happens if the number of
156
621
    // entries is small and we're within our initial allocation of
157
621
    // 64 buckets.) We aim for an occupancy ratio in [3/8, 3/4).
158
621
    //
159
621
    // As a special case, if there are two or fewer entries, just
160
621
    // form a single bucket. A linear scan is fine in that case, and
161
621
    // this is very common in C++ class lookup tables. This also
162
621
    // guarantees we produce at least one bucket for an empty table.
163
621
    //
164
621
    // FIXME: Try computing a perfect hash function at this point.
165
621
    unsigned TargetNumBuckets =
166
621
        NumEntries <= 2 ? 
113
:
NextPowerOf2(NumEntries * 4 / 3)608
;
167
621
    if (TargetNumBuckets != NumBuckets)
168
476
      resize(TargetNumBuckets);
169
621
170
621
    // Emit the payload of the table.
171
169k
    for (offset_type I = 0; I < NumBuckets; 
++I169k
) {
172
169k
      Bucket &B = Buckets[I];
173
169k
      if (!B.Head)
174
100k
        continue;
175
68.5k
176
68.5k
      // Store the offset for the data of this bucket.
177
68.5k
      B.Off = Out.tell();
178
68.5k
      assert(B.Off && "Cannot write a bucket at offset 0. Please add padding.");
179
68.5k
180
68.5k
      // Write out the number of items in the bucket.
181
68.5k
      LE.write<uint16_t>(B.Length);
182
68.5k
      assert(B.Length != 0 && "Bucket has a head but zero length?");
183
68.5k
184
68.5k
      // Write out the entries in the bucket.
185
158k
      for (Item *I = B.Head; I; 
I = I->Next89.8k
) {
186
89.8k
        LE.write<typename Info::hash_value_type>(I->Hash);
187
89.8k
        const std::pair<offset_type, offset_type> &Len =
188
89.8k
            InfoObj.EmitKeyDataLength(Out, I->Key, I->Data);
189
89.8k
#ifdef NDEBUG
190
89.8k
        InfoObj.EmitKey(Out, I->Key, Len.first);
191
89.8k
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
192
#else
193
        // In asserts mode, check that the users length matches the data they
194
        // wrote.
195
        uint64_t KeyStart = Out.tell();
196
        InfoObj.EmitKey(Out, I->Key, Len.first);
197
        uint64_t DataStart = Out.tell();
198
        InfoObj.EmitData(Out, I->Key, I->Data, Len.second);
199
        uint64_t End = Out.tell();
200
        assert(offset_type(DataStart - KeyStart) == Len.first &&
201
               "key length does not match bytes written");
202
        assert(offset_type(End - DataStart) == Len.second &&
203
               "data length does not match bytes written");
204
#endif
205
      }
206
68.5k
    }
207
621
208
621
    // Pad with zeros so that we can start the hashtable at an aligned address.
209
621
    offset_type TableOff = Out.tell();
210
621
    uint64_t N = llvm::OffsetToAlignment(TableOff, alignof(offset_type));
211
621
    TableOff += N;
212
1.40k
    while (N--)
213
785
      LE.write<uint8_t>(0);
214
621
215
621
    // Emit the hashtable itself.
216
621
    LE.write<offset_type>(NumBuckets);
217
621
    LE.write<offset_type>(NumEntries);
218
169k
    for (offset_type I = 0; I < NumBuckets; 
++I169k
)
219
169k
      LE.write<offset_type>(Buckets[I].Off);
220
621
221
621
    return TableOff;
222
621
  }
223
224
19.1k
  OnDiskChainedHashTableGenerator() {
225
19.1k
    NumEntries = 0;
226
19.1k
    NumBuckets = 64;
227
19.1k
    // Note that we do not need to run the constructors of the individual
228
19.1k
    // Bucket objects since 'calloc' returns bytes that are all 0.
229
19.1k
    Buckets = static_cast<Bucket *>(safe_calloc(NumBuckets, sizeof(Bucket)));
230
19.1k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::OnDiskChainedHashTableGenerator()
Line
Count
Source
224
3.61k
  OnDiskChainedHashTableGenerator() {
225
3.61k
    NumEntries = 0;
226
3.61k
    NumBuckets = 64;
227
3.61k
    // Note that we do not need to run the constructors of the individual
228
3.61k
    // Bucket objects since 'calloc' returns bytes that are all 0.
229
3.61k
    Buckets = static_cast<Bucket *>(safe_calloc(NumBuckets, sizeof(Bucket)));
230
3.61k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::OnDiskChainedHashTableGenerator()
Line
Count
Source
224
176
  OnDiskChainedHashTableGenerator() {
225
176
    NumEntries = 0;
226
176
    NumBuckets = 64;
227
176
    // Note that we do not need to run the constructors of the individual
228
176
    // Bucket objects since 'calloc' returns bytes that are all 0.
229
176
    Buckets = static_cast<Bucket *>(safe_calloc(NumBuckets, sizeof(Bucket)));
230
176
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::OnDiskChainedHashTableGenerator()
Line
Count
Source
224
3.61k
  OnDiskChainedHashTableGenerator() {
225
3.61k
    NumEntries = 0;
226
3.61k
    NumBuckets = 64;
227
3.61k
    // Note that we do not need to run the constructors of the individual
228
3.61k
    // Bucket objects since 'calloc' returns bytes that are all 0.
229
3.61k
    Buckets = static_cast<Bucket *>(safe_calloc(NumBuckets, sizeof(Bucket)));
230
3.61k
  }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::OnDiskChainedHashTableGenerator()
Line
Count
Source
224
11.0k
  OnDiskChainedHashTableGenerator() {
225
11.0k
    NumEntries = 0;
226
11.0k
    NumBuckets = 64;
227
11.0k
    // Note that we do not need to run the constructors of the individual
228
11.0k
    // Bucket objects since 'calloc' returns bytes that are all 0.
229
11.0k
    Buckets = static_cast<Bucket *>(safe_calloc(NumBuckets, sizeof(Bucket)));
230
11.0k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::OnDiskChainedHashTableGenerator()
Line
Count
Source
224
621
  OnDiskChainedHashTableGenerator() {
225
621
    NumEntries = 0;
226
621
    NumBuckets = 64;
227
621
    // Note that we do not need to run the constructors of the individual
228
621
    // Bucket objects since 'calloc' returns bytes that are all 0.
229
621
    Buckets = static_cast<Bucket *>(safe_calloc(NumBuckets, sizeof(Bucket)));
230
621
  }
231
232
19.1k
  ~OnDiskChainedHashTableGenerator() { std::free(Buckets); }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTDeclContextNameLookupTrait>::~OnDiskChainedHashTableGenerator()
Line
Count
Source
232
11.0k
  ~OnDiskChainedHashTableGenerator() { std::free(Buckets); }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::HeaderFileInfoTrait>::~OnDiskChainedHashTableGenerator()
Line
Count
Source
232
3.61k
  ~OnDiskChainedHashTableGenerator() { std::free(Buckets); }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTMethodPoolTrait>::~OnDiskChainedHashTableGenerator()
Line
Count
Source
232
176
  ~OnDiskChainedHashTableGenerator() { std::free(Buckets); }
ASTWriter.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::ASTIdentifierTableTrait>::~OnDiskChainedHashTableGenerator()
Line
Count
Source
232
3.61k
  ~OnDiskChainedHashTableGenerator() { std::free(Buckets); }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTableGenerator<(anonymous namespace)::IdentifierIndexWriterTrait>::~OnDiskChainedHashTableGenerator()
Line
Count
Source
232
621
  ~OnDiskChainedHashTableGenerator() { std::free(Buckets); }
233
};
234
235
/// Provides lookup on an on disk hash table.
236
///
237
/// This needs an \c Info that handles reading values from the hash table's
238
/// payload and computes the hash for a given key. This should provide the
239
/// following interface:
240
///
241
/// \code
242
/// class ExampleLookupInfo {
243
/// public:
244
///   typedef ExampleData data_type;
245
///   typedef ExampleInternalKey internal_key_type; // The stored key type.
246
///   typedef ExampleKey external_key_type; // The type to pass to find().
247
///   typedef uint32_t hash_value_type; // The type the hash function returns.
248
///   typedef uint32_t offset_type; // The type for offsets into the table.
249
///
250
///   /// Compare two keys for equality.
251
///   static bool EqualKey(internal_key_type &Key1, internal_key_type &Key2);
252
///   /// Calculate the hash for the given key.
253
///   static hash_value_type ComputeHash(internal_key_type &IKey);
254
///   /// Translate from the semantic type of a key in the hash table to the
255
///   /// type that is actually stored and used for hashing and comparisons.
256
///   /// The internal and external types are often the same, in which case this
257
///   /// can simply return the passed in value.
258
///   static const internal_key_type &GetInternalKey(external_key_type &EKey);
259
///   /// Read the key and data length from Buffer, leaving it pointing at the
260
///   /// following byte.
261
///   static std::pair<offset_type, offset_type>
262
///   ReadKeyDataLength(const unsigned char *&Buffer);
263
///   /// Read the key from Buffer, given the KeyLen as reported from
264
///   /// ReadKeyDataLength.
265
///   const internal_key_type &ReadKey(const unsigned char *Buffer,
266
///                                    offset_type KeyLen);
267
///   /// Read the data for Key from Buffer, given the DataLen as reported from
268
///   /// ReadKeyDataLength.
269
///   data_type ReadData(StringRef Key, const unsigned char *Buffer,
270
///                      offset_type DataLen);
271
/// };
272
/// \endcode
273
template <typename Info> class OnDiskChainedHashTable {
274
  const typename Info::offset_type NumBuckets;
275
  const typename Info::offset_type NumEntries;
276
  const unsigned char *const Buckets;
277
  const unsigned char *const Base;
278
  Info InfoObj;
279
280
public:
281
  typedef Info InfoType;
282
  typedef typename Info::internal_key_type internal_key_type;
283
  typedef typename Info::external_key_type external_key_type;
284
  typedef typename Info::data_type data_type;
285
  typedef typename Info::hash_value_type hash_value_type;
286
  typedef typename Info::offset_type offset_type;
287
288
  OnDiskChainedHashTable(offset_type NumBuckets, offset_type NumEntries,
289
                         const unsigned char *Buckets,
290
                         const unsigned char *Base,
291
                         const Info &InfoObj = Info())
292
      : NumBuckets(NumBuckets), NumEntries(NumEntries), Buckets(Buckets),
293
27.5k
        Base(Base), InfoObj(InfoObj) {
294
27.5k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
27.5k
           "'buckets' must have a 4-byte alignment");
296
27.5k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::OnDiskChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, clang::serialization::reader::ASTIdentifierLookupTrait const&)
Line
Count
Source
293
6.13k
        Base(Base), InfoObj(InfoObj) {
294
6.13k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
6.13k
           "'buckets' must have a 4-byte alignment");
296
6.13k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::OnDiskChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, clang::serialization::reader::ASTSelectorLookupTrait const&)
Line
Count
Source
293
300
        Base(Base), InfoObj(InfoObj) {
294
300
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
300
           "'buckets' must have a 4-byte alignment");
296
300
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::OnDiskChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, clang::serialization::reader::HeaderFileInfoTrait const&)
Line
Count
Source
293
6.13k
        Base(Base), InfoObj(InfoObj) {
294
6.13k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
6.13k
           "'buckets' must have a 4-byte alignment");
296
6.13k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::OnDiskChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, clang::serialization::reader::ASTDeclContextNameLookupTrait const&)
Line
Count
Source
293
12.9k
        Base(Base), InfoObj(InfoObj) {
294
12.9k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
12.9k
           "'buckets' must have a 4-byte alignment");
296
12.9k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::OnDiskChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, (anonymous namespace)::InterestingASTIdentifierLookupTrait const&)
Line
Count
Source
293
1.28k
        Base(Base), InfoObj(InfoObj) {
294
1.28k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
1.28k
           "'buckets' must have a 4-byte alignment");
296
1.28k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::OnDiskChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, (anonymous namespace)::IdentifierIndexReaderTrait const&)
Line
Count
Source
293
185
        Base(Base), InfoObj(InfoObj) {
294
185
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
185
           "'buckets' must have a 4-byte alignment");
296
185
  }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::OnDiskChainedHashTable(unsigned long long, unsigned long long, unsigned char const*, unsigned char const*, llvm::InstrProfLookupTrait const&)
Line
Count
Source
293
525
        Base(Base), InfoObj(InfoObj) {
294
525
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
295
525
           "'buckets' must have a 4-byte alignment");
296
525
  }
297
298
  /// Read the number of buckets and the number of entries from a hash table
299
  /// produced by OnDiskHashTableGenerator::Emit, and advance the Buckets
300
  /// pointer past them.
301
  static std::pair<offset_type, offset_type>
302
27.5k
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
27.5k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
27.5k
           "buckets should be 4-byte aligned.");
305
27.5k
    using namespace llvm::support;
306
27.5k
    offset_type NumBuckets =
307
27.5k
        endian::readNext<offset_type, little, aligned>(Buckets);
308
27.5k
    offset_type NumEntries =
309
27.5k
        endian::readNext<offset_type, little, aligned>(Buckets);
310
27.5k
    return std::make_pair(NumBuckets, NumEntries);
311
27.5k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
6.13k
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
6.13k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
6.13k
           "buckets should be 4-byte aligned.");
305
6.13k
    using namespace llvm::support;
306
6.13k
    offset_type NumBuckets =
307
6.13k
        endian::readNext<offset_type, little, aligned>(Buckets);
308
6.13k
    offset_type NumEntries =
309
6.13k
        endian::readNext<offset_type, little, aligned>(Buckets);
310
6.13k
    return std::make_pair(NumBuckets, NumEntries);
311
6.13k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
300
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
300
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
300
           "buckets should be 4-byte aligned.");
305
300
    using namespace llvm::support;
306
300
    offset_type NumBuckets =
307
300
        endian::readNext<offset_type, little, aligned>(Buckets);
308
300
    offset_type NumEntries =
309
300
        endian::readNext<offset_type, little, aligned>(Buckets);
310
300
    return std::make_pair(NumBuckets, NumEntries);
311
300
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
6.13k
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
6.13k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
6.13k
           "buckets should be 4-byte aligned.");
305
6.13k
    using namespace llvm::support;
306
6.13k
    offset_type NumBuckets =
307
6.13k
        endian::readNext<offset_type, little, aligned>(Buckets);
308
6.13k
    offset_type NumEntries =
309
6.13k
        endian::readNext<offset_type, little, aligned>(Buckets);
310
6.13k
    return std::make_pair(NumBuckets, NumEntries);
311
6.13k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
12.9k
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
12.9k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
12.9k
           "buckets should be 4-byte aligned.");
305
12.9k
    using namespace llvm::support;
306
12.9k
    offset_type NumBuckets =
307
12.9k
        endian::readNext<offset_type, little, aligned>(Buckets);
308
12.9k
    offset_type NumEntries =
309
12.9k
        endian::readNext<offset_type, little, aligned>(Buckets);
310
12.9k
    return std::make_pair(NumBuckets, NumEntries);
311
12.9k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
1.28k
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
1.28k
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
1.28k
           "buckets should be 4-byte aligned.");
305
1.28k
    using namespace llvm::support;
306
1.28k
    offset_type NumBuckets =
307
1.28k
        endian::readNext<offset_type, little, aligned>(Buckets);
308
1.28k
    offset_type NumEntries =
309
1.28k
        endian::readNext<offset_type, little, aligned>(Buckets);
310
1.28k
    return std::make_pair(NumBuckets, NumEntries);
311
1.28k
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
185
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
185
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
185
           "buckets should be 4-byte aligned.");
305
185
    using namespace llvm::support;
306
185
    offset_type NumBuckets =
307
185
        endian::readNext<offset_type, little, aligned>(Buckets);
308
185
    offset_type NumEntries =
309
185
        endian::readNext<offset_type, little, aligned>(Buckets);
310
185
    return std::make_pair(NumBuckets, NumEntries);
311
185
  }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::readNumBucketsAndEntries(unsigned char const*&)
Line
Count
Source
302
525
  readNumBucketsAndEntries(const unsigned char *&Buckets) {
303
525
    assert((reinterpret_cast<uintptr_t>(Buckets) & 0x3) == 0 &&
304
525
           "buckets should be 4-byte aligned.");
305
525
    using namespace llvm::support;
306
525
    offset_type NumBuckets =
307
525
        endian::readNext<offset_type, little, aligned>(Buckets);
308
525
    offset_type NumEntries =
309
525
        endian::readNext<offset_type, little, aligned>(Buckets);
310
525
    return std::make_pair(NumBuckets, NumEntries);
311
525
  }
312
313
  offset_type getNumBuckets() const { return NumBuckets; }
314
2.59k
  offset_type getNumEntries() const { return NumEntries; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::getNumEntries() const
Line
Count
Source
314
293
  offset_type getNumEntries() const { return NumEntries; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::getNumEntries() const
Line
Count
Source
314
470
  offset_type getNumEntries() const { return NumEntries; }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::getNumEntries() const
Line
Count
Source
314
1.28k
  offset_type getNumEntries() const { return NumEntries; }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::getNumEntries() const
Line
Count
Source
314
14
  offset_type getNumEntries() const { return NumEntries; }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::getNumEntries() const
Line
Count
Source
314
533
  offset_type getNumEntries() const { return NumEntries; }
315
  const unsigned char *getBase() const { return Base; }
316
  const unsigned char *getBuckets() const { return Buckets; }
317
318
  bool isEmpty() const { return NumEntries == 0; }
319
320
  class iterator {
321
    internal_key_type Key;
322
    const unsigned char *const Data;
323
    const offset_type Len;
324
    Info *InfoObj;
325
326
  public:
327
3.16M
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator::iterator()
Line
Count
Source
327
2.41M
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::iterator::iterator()
Line
Count
Source
327
108k
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator::iterator()
Line
Count
Source
327
51.9k
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::iterator::iterator()
Line
Count
Source
327
357
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator::iterator()
Line
Count
Source
327
592k
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::iterator::iterator()
Line
Count
Source
327
964
    iterator() : Key(), Data(nullptr), Len(0), InfoObj(nullptr) {}
328
    iterator(const internal_key_type K, const unsigned char *D, offset_type L,
329
             Info *InfoObj)
330
477k
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator::iterator(llvm::StringRef, unsigned char const*, unsigned int, clang::serialization::reader::ASTIdentifierLookupTrait*)
Line
Count
Source
330
442k
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::iterator::iterator(clang::serialization::reader::HeaderFileInfoTrait::internal_key_type, unsigned char const*, unsigned int, clang::serialization::reader::HeaderFileInfoTrait*)
Line
Count
Source
330
4.76k
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator::iterator(clang::serialization::DeclarationNameKey, unsigned char const*, unsigned int, clang::serialization::reader::ASTDeclContextNameLookupTrait*)
Line
Count
Source
330
22.8k
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::iterator::iterator(clang::Selector, unsigned char const*, unsigned int, clang::serialization::reader::ASTSelectorLookupTrait*)
Line
Count
Source
330
81
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator::iterator(llvm::StringRef, unsigned char const*, unsigned int, (anonymous namespace)::IdentifierIndexReaderTrait*)
Line
Count
Source
330
7.09k
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::iterator::iterator(llvm::StringRef, unsigned char const*, unsigned long long, llvm::InstrProfLookupTrait*)
Line
Count
Source
330
766
        : Key(K), Data(D), Len(L), InfoObj(InfoObj) {}
331
332
454k
    data_type operator*() const { return InfoObj->ReadData(Key, Data, Len); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator::operator*() const
Line
Count
Source
332
442k
    data_type operator*() const { return InfoObj->ReadData(Key, Data, Len); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::iterator::operator*() const
Line
Count
Source
332
4.76k
    data_type operator*() const { return InfoObj->ReadData(Key, Data, Len); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::iterator::operator*() const
Line
Count
Source
332
81
    data_type operator*() const { return InfoObj->ReadData(Key, Data, Len); }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator::operator*() const
Line
Count
Source
332
7.09k
    data_type operator*() const { return InfoObj->ReadData(Key, Data, Len); }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::iterator::operator*() const
Line
Count
Source
332
766
    data_type operator*() const { return InfoObj->ReadData(Key, Data, Len); }
333
334
22.8k
    const unsigned char *getDataPtr() const { return Data; }
335
22.8k
    offset_type getDataLen() const { return Len; }
336
337
1.78M
    bool operator==(const iterator &X) const { return X.Data == Data; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator::operator==(llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator const&) const
Line
Count
Source
337
1.42M
    bool operator==(const iterator &X) const { return X.Data == Data; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::iterator::operator==(llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::iterator const&) const
Line
Count
Source
337
56.7k
    bool operator==(const iterator &X) const { return X.Data == Data; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::iterator::operator==(llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::iterator const&) const
Line
Count
Source
337
219
    bool operator==(const iterator &X) const { return X.Data == Data; }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator::operator==(llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator const&) const
Line
Count
Source
337
299k
    bool operator==(const iterator &X) const { return X.Data == Data; }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::iterator::operator==(llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::iterator const&) const
Line
Count
Source
337
865
    bool operator==(const iterator &X) const { return X.Data == Data; }
338
37.3k
    bool operator!=(const iterator &X) const { return X.Data != Data; }
339
  };
340
341
  /// Look up the stored data for a particular key.
342
357k
  iterator find(const external_key_type &EKey, Info *InfoPtr = nullptr) {
343
357k
    const internal_key_type &IKey = InfoObj.GetInternalKey(EKey);
344
357k
    hash_value_type KeyHash = InfoObj.ComputeHash(IKey);
345
357k
    return find_hashed(IKey, KeyHash, InfoPtr);
346
357k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::find(clang::FileEntry const* const&, clang::serialization::reader::HeaderFileInfoTrait*)
Line
Count
Source
342
56.7k
  iterator find(const external_key_type &EKey, Info *InfoPtr = nullptr) {
343
56.7k
    const internal_key_type &IKey = InfoObj.GetInternalKey(EKey);
344
56.7k
    hash_value_type KeyHash = InfoObj.ComputeHash(IKey);
345
56.7k
    return find_hashed(IKey, KeyHash, InfoPtr);
346
56.7k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::find(clang::Selector const&, clang::serialization::reader::ASTSelectorLookupTrait*)
Line
Count
Source
342
219
  iterator find(const external_key_type &EKey, Info *InfoPtr = nullptr) {
343
219
    const internal_key_type &IKey = InfoObj.GetInternalKey(EKey);
344
219
    hash_value_type KeyHash = InfoObj.ComputeHash(IKey);
345
219
    return find_hashed(IKey, KeyHash, InfoPtr);
346
219
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::find(llvm::StringRef const&, (anonymous namespace)::IdentifierIndexReaderTrait*)
Line
Count
Source
342
299k
  iterator find(const external_key_type &EKey, Info *InfoPtr = nullptr) {
343
299k
    const internal_key_type &IKey = InfoObj.GetInternalKey(EKey);
344
299k
    hash_value_type KeyHash = InfoObj.ComputeHash(IKey);
345
299k
    return find_hashed(IKey, KeyHash, InfoPtr);
346
299k
  }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::find(llvm::StringRef const&, llvm::InstrProfLookupTrait*)
Line
Count
Source
342
865
  iterator find(const external_key_type &EKey, Info *InfoPtr = nullptr) {
343
865
    const internal_key_type &IKey = InfoObj.GetInternalKey(EKey);
344
865
    hash_value_type KeyHash = InfoObj.ComputeHash(IKey);
345
865
    return find_hashed(IKey, KeyHash, InfoPtr);
346
865
  }
347
348
  /// Look up the stored data for a particular key with a known hash.
349
  iterator find_hashed(const internal_key_type &IKey, hash_value_type KeyHash,
350
1.82M
                       Info *InfoPtr = nullptr) {
351
1.82M
    using namespace llvm::support;
352
1.82M
353
1.82M
    if (!InfoPtr)
354
394k
      InfoPtr = &InfoObj;
355
1.82M
356
1.82M
    // Each bucket is just an offset into the hash table file.
357
1.82M
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
1.82M
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
1.82M
360
1.82M
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
1.82M
    if (Offset == 0)
362
688k
      return iterator(); // Empty bucket.
363
1.13M
    const unsigned char *Items = Base + Offset;
364
1.13M
365
1.13M
    // 'Items' starts with a 16-bit unsigned integer representing the
366
1.13M
    // number of items in this bucket.
367
1.13M
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
1.13M
369
2.03M
    for (unsigned i = 0; i < Len; 
++i898k
) {
370
1.37M
      // Read the hash.
371
1.37M
      hash_value_type ItemHash =
372
1.37M
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
1.37M
374
1.37M
      // Determine the length of the key and the data.
375
1.37M
      const std::pair<offset_type, offset_type> &L =
376
1.37M
          Info::ReadKeyDataLength(Items);
377
1.37M
      offset_type ItemLen = L.first + L.second;
378
1.37M
379
1.37M
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
1.37M
      if (ItemHash != KeyHash) {
381
888k
        Items += ItemLen;
382
888k
        continue;
383
888k
      }
384
487k
385
487k
      // Read the key.
386
487k
      const internal_key_type &X =
387
487k
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
487k
389
487k
      // If the key doesn't match just skip reading the value.
390
487k
      if (!InfoPtr->EqualKey(X, IKey)) {
391
9.59k
        Items += ItemLen;
392
9.59k
        continue;
393
9.59k
      }
394
477k
395
477k
      // The key matches!
396
477k
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
477k
    }
398
1.13M
399
1.13M
    
return iterator()656k
;
400
1.13M
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::find_hashed(llvm::StringRef const&, unsigned int, clang::serialization::reader::ASTIdentifierLookupTrait*)
Line
Count
Source
350
1.42M
                       Info *InfoPtr = nullptr) {
351
1.42M
    using namespace llvm::support;
352
1.42M
353
1.42M
    if (!InfoPtr)
354
0
      InfoPtr = &InfoObj;
355
1.42M
356
1.42M
    // Each bucket is just an offset into the hash table file.
357
1.42M
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
1.42M
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
1.42M
360
1.42M
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
1.42M
    if (Offset == 0)
362
529k
      return iterator(); // Empty bucket.
363
898k
    const unsigned char *Items = Base + Offset;
364
898k
365
898k
    // 'Items' starts with a 16-bit unsigned integer representing the
366
898k
    // number of items in this bucket.
367
898k
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
898k
369
1.52M
    for (unsigned i = 0; i < Len; 
++i630k
) {
370
1.07M
      // Read the hash.
371
1.07M
      hash_value_type ItemHash =
372
1.07M
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
1.07M
374
1.07M
      // Determine the length of the key and the data.
375
1.07M
      const std::pair<offset_type, offset_type> &L =
376
1.07M
          Info::ReadKeyDataLength(Items);
377
1.07M
      offset_type ItemLen = L.first + L.second;
378
1.07M
379
1.07M
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
1.07M
      if (ItemHash != KeyHash) {
381
630k
        Items += ItemLen;
382
630k
        continue;
383
630k
      }
384
442k
385
442k
      // Read the key.
386
442k
      const internal_key_type &X =
387
442k
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
442k
389
442k
      // If the key doesn't match just skip reading the value.
390
442k
      if (!InfoPtr->EqualKey(X, IKey)) {
391
10
        Items += ItemLen;
392
10
        continue;
393
10
      }
394
442k
395
442k
      // The key matches!
396
442k
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
442k
    }
398
898k
399
898k
    
return iterator()455k
;
400
898k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::find_hashed(clang::serialization::reader::HeaderFileInfoTrait::internal_key_type const&, unsigned int, clang::serialization::reader::HeaderFileInfoTrait*)
Line
Count
Source
350
56.7k
                       Info *InfoPtr = nullptr) {
351
56.7k
    using namespace llvm::support;
352
56.7k
353
56.7k
    if (!InfoPtr)
354
56.7k
      InfoPtr = &InfoObj;
355
56.7k
356
56.7k
    // Each bucket is just an offset into the hash table file.
357
56.7k
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
56.7k
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
56.7k
360
56.7k
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
56.7k
    if (Offset == 0)
362
5.47k
      return iterator(); // Empty bucket.
363
51.2k
    const unsigned char *Items = Base + Offset;
364
51.2k
365
51.2k
    // 'Items' starts with a 16-bit unsigned integer representing the
366
51.2k
    // number of items in this bucket.
367
51.2k
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
51.2k
369
126k
    for (unsigned i = 0; i < Len; 
++i75.6k
) {
370
80.3k
      // Read the hash.
371
80.3k
      hash_value_type ItemHash =
372
80.3k
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
80.3k
374
80.3k
      // Determine the length of the key and the data.
375
80.3k
      const std::pair<offset_type, offset_type> &L =
376
80.3k
          Info::ReadKeyDataLength(Items);
377
80.3k
      offset_type ItemLen = L.first + L.second;
378
80.3k
379
80.3k
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
80.3k
      if (ItemHash != KeyHash) {
381
66.0k
        Items += ItemLen;
382
66.0k
        continue;
383
66.0k
      }
384
14.3k
385
14.3k
      // Read the key.
386
14.3k
      const internal_key_type &X =
387
14.3k
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
14.3k
389
14.3k
      // If the key doesn't match just skip reading the value.
390
14.3k
      if (!InfoPtr->EqualKey(X, IKey)) {
391
9.58k
        Items += ItemLen;
392
9.58k
        continue;
393
9.58k
      }
394
4.76k
395
4.76k
      // The key matches!
396
4.76k
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
4.76k
    }
398
51.2k
399
51.2k
    
return iterator()46.4k
;
400
51.2k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::find_hashed(clang::serialization::DeclarationNameKey const&, unsigned int, clang::serialization::reader::ASTDeclContextNameLookupTrait*)
Line
Count
Source
350
37.3k
                       Info *InfoPtr = nullptr) {
351
37.3k
    using namespace llvm::support;
352
37.3k
353
37.3k
    if (!InfoPtr)
354
37.3k
      InfoPtr = &InfoObj;
355
37.3k
356
37.3k
    // Each bucket is just an offset into the hash table file.
357
37.3k
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
37.3k
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
37.3k
360
37.3k
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
37.3k
    if (Offset == 0)
362
7.74k
      return iterator(); // Empty bucket.
363
29.6k
    const unsigned char *Items = Base + Offset;
364
29.6k
365
29.6k
    // 'Items' starts with a 16-bit unsigned integer representing the
366
29.6k
    // number of items in this bucket.
367
29.6k
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
29.6k
369
45.1k
    for (unsigned i = 0; i < Len; 
++i15.4k
) {
370
38.2k
      // Read the hash.
371
38.2k
      hash_value_type ItemHash =
372
38.2k
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
38.2k
374
38.2k
      // Determine the length of the key and the data.
375
38.2k
      const std::pair<offset_type, offset_type> &L =
376
38.2k
          Info::ReadKeyDataLength(Items);
377
38.2k
      offset_type ItemLen = L.first + L.second;
378
38.2k
379
38.2k
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
38.2k
      if (ItemHash != KeyHash) {
381
15.4k
        Items += ItemLen;
382
15.4k
        continue;
383
15.4k
      }
384
22.8k
385
22.8k
      // Read the key.
386
22.8k
      const internal_key_type &X =
387
22.8k
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
22.8k
389
22.8k
      // If the key doesn't match just skip reading the value.
390
22.8k
      if (!InfoPtr->EqualKey(X, IKey)) {
391
0
        Items += ItemLen;
392
0
        continue;
393
0
      }
394
22.8k
395
22.8k
      // The key matches!
396
22.8k
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
22.8k
    }
398
29.6k
399
29.6k
    
return iterator()6.84k
;
400
29.6k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::find_hashed(clang::Selector const&, unsigned int, clang::serialization::reader::ASTSelectorLookupTrait*)
Line
Count
Source
350
219
                       Info *InfoPtr = nullptr) {
351
219
    using namespace llvm::support;
352
219
353
219
    if (!InfoPtr)
354
219
      InfoPtr = &InfoObj;
355
219
356
219
    // Each bucket is just an offset into the hash table file.
357
219
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
219
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
219
360
219
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
219
    if (Offset == 0)
362
75
      return iterator(); // Empty bucket.
363
144
    const unsigned char *Items = Base + Offset;
364
144
365
144
    // 'Items' starts with a 16-bit unsigned integer representing the
366
144
    // number of items in this bucket.
367
144
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
144
369
236
    for (unsigned i = 0; i < Len; 
++i92
) {
370
173
      // Read the hash.
371
173
      hash_value_type ItemHash =
372
173
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
173
374
173
      // Determine the length of the key and the data.
375
173
      const std::pair<offset_type, offset_type> &L =
376
173
          Info::ReadKeyDataLength(Items);
377
173
      offset_type ItemLen = L.first + L.second;
378
173
379
173
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
173
      if (ItemHash != KeyHash) {
381
92
        Items += ItemLen;
382
92
        continue;
383
92
      }
384
81
385
81
      // Read the key.
386
81
      const internal_key_type &X =
387
81
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
81
389
81
      // If the key doesn't match just skip reading the value.
390
81
      if (!InfoPtr->EqualKey(X, IKey)) {
391
0
        Items += ItemLen;
392
0
        continue;
393
0
      }
394
81
395
81
      // The key matches!
396
81
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
81
    }
398
144
399
144
    
return iterator()63
;
400
144
  }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::find_hashed(llvm::StringRef const&, unsigned int, (anonymous namespace)::IdentifierIndexReaderTrait*)
Line
Count
Source
350
299k
                       Info *InfoPtr = nullptr) {
351
299k
    using namespace llvm::support;
352
299k
353
299k
    if (!InfoPtr)
354
299k
      InfoPtr = &InfoObj;
355
299k
356
299k
    // Each bucket is just an offset into the hash table file.
357
299k
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
299k
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
299k
360
299k
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
299k
    if (Offset == 0)
362
145k
      return iterator(); // Empty bucket.
363
154k
    const unsigned char *Items = Base + Offset;
364
154k
365
154k
    // 'Items' starts with a 16-bit unsigned integer representing the
366
154k
    // number of items in this bucket.
367
154k
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
154k
369
330k
    for (unsigned i = 0; i < Len; 
++i176k
) {
370
183k
      // Read the hash.
371
183k
      hash_value_type ItemHash =
372
183k
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
183k
374
183k
      // Determine the length of the key and the data.
375
183k
      const std::pair<offset_type, offset_type> &L =
376
183k
          Info::ReadKeyDataLength(Items);
377
183k
      offset_type ItemLen = L.first + L.second;
378
183k
379
183k
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
183k
      if (ItemHash != KeyHash) {
381
176k
        Items += ItemLen;
382
176k
        continue;
383
176k
      }
384
7.09k
385
7.09k
      // Read the key.
386
7.09k
      const internal_key_type &X =
387
7.09k
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
7.09k
389
7.09k
      // If the key doesn't match just skip reading the value.
390
7.09k
      if (!InfoPtr->EqualKey(X, IKey)) {
391
1
        Items += ItemLen;
392
1
        continue;
393
1
      }
394
7.09k
395
7.09k
      // The key matches!
396
7.09k
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
7.09k
    }
398
154k
399
154k
    
return iterator()147k
;
400
154k
  }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::find_hashed(llvm::StringRef const&, unsigned long long, llvm::InstrProfLookupTrait*)
Line
Count
Source
350
865
                       Info *InfoPtr = nullptr) {
351
865
    using namespace llvm::support;
352
865
353
865
    if (!InfoPtr)
354
865
      InfoPtr = &InfoObj;
355
865
356
865
    // Each bucket is just an offset into the hash table file.
357
865
    offset_type Idx = KeyHash & (NumBuckets - 1);
358
865
    const unsigned char *Bucket = Buckets + sizeof(offset_type) * Idx;
359
865
360
865
    offset_type Offset = endian::readNext<offset_type, little, aligned>(Bucket);
361
865
    if (Offset == 0)
362
30
      return iterator(); // Empty bucket.
363
835
    const unsigned char *Items = Base + Offset;
364
835
365
835
    // 'Items' starts with a 16-bit unsigned integer representing the
366
835
    // number of items in this bucket.
367
835
    unsigned Len = endian::readNext<uint16_t, little, unaligned>(Items);
368
835
369
1.07k
    for (unsigned i = 0; i < Len; 
++i242
) {
370
1.00k
      // Read the hash.
371
1.00k
      hash_value_type ItemHash =
372
1.00k
          endian::readNext<hash_value_type, little, unaligned>(Items);
373
1.00k
374
1.00k
      // Determine the length of the key and the data.
375
1.00k
      const std::pair<offset_type, offset_type> &L =
376
1.00k
          Info::ReadKeyDataLength(Items);
377
1.00k
      offset_type ItemLen = L.first + L.second;
378
1.00k
379
1.00k
      // Compare the hashes.  If they are not the same, skip the entry entirely.
380
1.00k
      if (ItemHash != KeyHash) {
381
242
        Items += ItemLen;
382
242
        continue;
383
242
      }
384
766
385
766
      // Read the key.
386
766
      const internal_key_type &X =
387
766
          InfoPtr->ReadKey((const unsigned char *const)Items, L.first);
388
766
389
766
      // If the key doesn't match just skip reading the value.
390
766
      if (!InfoPtr->EqualKey(X, IKey)) {
391
0
        Items += ItemLen;
392
0
        continue;
393
0
      }
394
766
395
766
      // The key matches!
396
766
      return iterator(X, Items + L.first, L.second, InfoPtr);
397
766
    }
398
835
399
835
    
return iterator()69
;
400
835
  }
401
402
1.82M
  iterator end() const { return iterator(); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::end() const
Line
Count
Source
402
1.42M
  iterator end() const { return iterator(); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::end() const
Line
Count
Source
402
56.7k
  iterator end() const { return iterator(); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::end() const
Line
Count
Source
402
37.3k
  iterator end() const { return iterator(); }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::end() const
Line
Count
Source
402
219
  iterator end() const { return iterator(); }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::end() const
Line
Count
Source
402
299k
  iterator end() const { return iterator(); }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::end() const
Line
Count
Source
402
865
  iterator end() const { return iterator(); }
403
404
1.45M
  Info &getInfoObj() { return InfoObj; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::getInfoObj()
Line
Count
Source
404
1.42M
  Info &getInfoObj() { return InfoObj; }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::getInfoObj()
Line
Count
Source
404
23.3k
  Info &getInfoObj() { return InfoObj; }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::getInfoObj()
Line
Count
Source
404
1.28k
  Info &getInfoObj() { return InfoObj; }
GlobalModuleIndex.cpp:llvm::OnDiskChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::getInfoObj()
Line
Count
Source
404
14
  Info &getInfoObj() { return InfoObj; }
llvm::OnDiskChainedHashTable<llvm::InstrProfLookupTrait>::getInfoObj()
Line
Count
Source
404
535
  Info &getInfoObj() { return InfoObj; }
405
406
  /// Create the hash table.
407
  ///
408
  /// \param Buckets is the beginning of the hash table itself, which follows
409
  /// the payload of entire structure. This is the value returned by
410
  /// OnDiskHashTableGenerator::Emit.
411
  ///
412
  /// \param Base is the point from which all offsets into the structure are
413
  /// based. This is offset 0 in the stream that was used when Emitting the
414
  /// table.
415
  static OnDiskChainedHashTable *Create(const unsigned char *Buckets,
416
                                        const unsigned char *const Base,
417
6.43k
                                        const Info &InfoObj = Info()) {
418
6.43k
    assert(Buckets > Base);
419
6.43k
    auto NumBucketsAndEntries = readNumBucketsAndEntries(Buckets);
420
6.43k
    return new OnDiskChainedHashTable<Info>(NumBucketsAndEntries.first,
421
6.43k
                                            NumBucketsAndEntries.second,
422
6.43k
                                            Buckets, Base, InfoObj);
423
6.43k
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::ASTSelectorLookupTrait>::Create(unsigned char const*, unsigned char const*, clang::serialization::reader::ASTSelectorLookupTrait const&)
Line
Count
Source
417
300
                                        const Info &InfoObj = Info()) {
418
300
    assert(Buckets > Base);
419
300
    auto NumBucketsAndEntries = readNumBucketsAndEntries(Buckets);
420
300
    return new OnDiskChainedHashTable<Info>(NumBucketsAndEntries.first,
421
300
                                            NumBucketsAndEntries.second,
422
300
                                            Buckets, Base, InfoObj);
423
300
  }
llvm::OnDiskChainedHashTable<clang::serialization::reader::HeaderFileInfoTrait>::Create(unsigned char const*, unsigned char const*, clang::serialization::reader::HeaderFileInfoTrait const&)
Line
Count
Source
417
6.13k
                                        const Info &InfoObj = Info()) {
418
6.13k
    assert(Buckets > Base);
419
6.13k
    auto NumBucketsAndEntries = readNumBucketsAndEntries(Buckets);
420
6.13k
    return new OnDiskChainedHashTable<Info>(NumBucketsAndEntries.first,
421
6.13k
                                            NumBucketsAndEntries.second,
422
6.13k
                                            Buckets, Base, InfoObj);
423
6.13k
  }
424
};
425
426
/// Provides lookup and iteration over an on disk hash table.
427
///
428
/// \copydetails llvm::OnDiskChainedHashTable
429
template <typename Info>
430
class OnDiskIterableChainedHashTable : public OnDiskChainedHashTable<Info> {
431
  const unsigned char *Payload;
432
433
public:
434
  typedef OnDiskChainedHashTable<Info>          base_type;
435
  typedef typename base_type::internal_key_type internal_key_type;
436
  typedef typename base_type::external_key_type external_key_type;
437
  typedef typename base_type::data_type         data_type;
438
  typedef typename base_type::hash_value_type   hash_value_type;
439
  typedef typename base_type::offset_type       offset_type;
440
441
private:
442
  /// Iterates over all of the keys in the table.
443
  class iterator_base {
444
    const unsigned char *Ptr;
445
    offset_type NumItemsInBucketLeft;
446
    offset_type NumEntriesLeft;
447
448
  public:
449
    typedef external_key_type value_type;
450
451
    iterator_base(const unsigned char *const Ptr, offset_type NumEntries)
452
2.59k
        : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator_base::iterator_base(unsigned char const*, unsigned int)
Line
Count
Source
452
293
        : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator_base::iterator_base(unsigned char const*, unsigned int)
Line
Count
Source
452
470
        : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::iterator_base::iterator_base(unsigned char const*, unsigned int)
Line
Count
Source
452
1.28k
        : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator_base::iterator_base(unsigned char const*, unsigned int)
Line
Count
Source
452
14
        : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries) {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base::iterator_base(unsigned char const*, unsigned long long)
Line
Count
Source
452
533
        : Ptr(Ptr), NumItemsInBucketLeft(0), NumEntriesLeft(NumEntries) {}
453
    iterator_base()
454
3.61k
        : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator_base::iterator_base()
Line
Count
Source
454
293
        : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator_base::iterator_base()
Line
Count
Source
454
1.13k
        : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::iterator_base::iterator_base()
Line
Count
Source
454
1.28k
        : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator_base::iterator_base()
Line
Count
Source
454
42
        : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0) {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base::iterator_base()
Line
Count
Source
454
867
        : Ptr(nullptr), NumItemsInBucketLeft(0), NumEntriesLeft(0) {}
455
456
200k
    friend bool operator==(const iterator_base &X, const iterator_base &Y) {
457
200k
      return X.NumEntriesLeft == Y.NumEntriesLeft;
458
200k
    }
llvm::operator==(llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator_base const&, llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator_base const&)
Line
Count
Source
456
196k
    friend bool operator==(const iterator_base &X, const iterator_base &Y) {
457
196k
      return X.NumEntriesLeft == Y.NumEntriesLeft;
458
196k
    }
GlobalModuleIndex.cpp:llvm::operator==(llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator_base const&, llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator_base const&)
Line
Count
Source
456
3.78k
    friend bool operator==(const iterator_base &X, const iterator_base &Y) {
457
3.78k
      return X.NumEntriesLeft == Y.NumEntriesLeft;
458
3.78k
    }
llvm::operator==(llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base const&, llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base const&)
Line
Count
Source
456
334
    friend bool operator==(const iterator_base &X, const iterator_base &Y) {
457
334
      return X.NumEntriesLeft == Y.NumEntriesLeft;
458
334
    }
459
111k
    friend bool operator!=(const iterator_base &X, const iterator_base &Y) {
460
111k
      return X.NumEntriesLeft != Y.NumEntriesLeft;
461
111k
    }
llvm::operator!=(llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator_base const&, llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator_base const&)
Line
Count
Source
459
2.90k
    friend bool operator!=(const iterator_base &X, const iterator_base &Y) {
460
2.90k
      return X.NumEntriesLeft != Y.NumEntriesLeft;
461
2.90k
    }
GlobalModuleIndex.cpp:llvm::operator!=(llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::iterator_base const&, llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::iterator_base const&)
Line
Count
Source
459
108k
    friend bool operator!=(const iterator_base &X, const iterator_base &Y) {
460
108k
      return X.NumEntriesLeft != Y.NumEntriesLeft;
461
108k
    }
llvm::operator!=(llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base const&, llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base const&)
Line
Count
Source
459
23
    friend bool operator!=(const iterator_base &X, const iterator_base &Y) {
460
23
      return X.NumEntriesLeft != Y.NumEntriesLeft;
461
23
    }
462
463
    /// Move to the next item.
464
309k
    void advance() {
465
309k
      using namespace llvm::support;
466
309k
      if (!NumItemsInBucketLeft) {
467
247k
        // 'Items' starts with a 16-bit unsigned integer representing the
468
247k
        // number of items in this bucket.
469
247k
        NumItemsInBucketLeft =
470
247k
            endian::readNext<uint16_t, little, unaligned>(Ptr);
471
247k
      }
472
309k
      Ptr += sizeof(hash_value_type); // Skip the hash.
473
309k
      // Determine the length of the key and the data.
474
309k
      const std::pair<offset_type, offset_type> &L =
475
309k
          Info::ReadKeyDataLength(Ptr);
476
309k
      Ptr += L.first + L.second;
477
309k
      assert(NumItemsInBucketLeft);
478
309k
      --NumItemsInBucketLeft;
479
309k
      assert(NumEntriesLeft);
480
309k
      --NumEntriesLeft;
481
309k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator_base::advance()
Line
Count
Source
464
2.61k
    void advance() {
465
2.61k
      using namespace llvm::support;
466
2.61k
      if (!NumItemsInBucketLeft) {
467
1.96k
        // 'Items' starts with a 16-bit unsigned integer representing the
468
1.96k
        // number of items in this bucket.
469
1.96k
        NumItemsInBucketLeft =
470
1.96k
            endian::readNext<uint16_t, little, unaligned>(Ptr);
471
1.96k
      }
472
2.61k
      Ptr += sizeof(hash_value_type); // Skip the hash.
473
2.61k
      // Determine the length of the key and the data.
474
2.61k
      const std::pair<offset_type, offset_type> &L =
475
2.61k
          Info::ReadKeyDataLength(Ptr);
476
2.61k
      Ptr += L.first + L.second;
477
2.61k
      assert(NumItemsInBucketLeft);
478
2.61k
      --NumItemsInBucketLeft;
479
2.61k
      assert(NumEntriesLeft);
480
2.61k
      --NumEntriesLeft;
481
2.61k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator_base::advance()
Line
Count
Source
464
195k
    void advance() {
465
195k
      using namespace llvm::support;
466
195k
      if (!NumItemsInBucketLeft) {
467
161k
        // 'Items' starts with a 16-bit unsigned integer representing the
468
161k
        // number of items in this bucket.
469
161k
        NumItemsInBucketLeft =
470
161k
            endian::readNext<uint16_t, little, unaligned>(Ptr);
471
161k
      }
472
195k
      Ptr += sizeof(hash_value_type); // Skip the hash.
473
195k
      // Determine the length of the key and the data.
474
195k
      const std::pair<offset_type, offset_type> &L =
475
195k
          Info::ReadKeyDataLength(Ptr);
476
195k
      Ptr += L.first + L.second;
477
195k
      assert(NumItemsInBucketLeft);
478
195k
      --NumItemsInBucketLeft;
479
195k
      assert(NumEntriesLeft);
480
195k
      --NumEntriesLeft;
481
195k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::iterator_base::advance()
Line
Count
Source
464
107k
    void advance() {
465
107k
      using namespace llvm::support;
466
107k
      if (!NumItemsInBucketLeft) {
467
81.4k
        // 'Items' starts with a 16-bit unsigned integer representing the
468
81.4k
        // number of items in this bucket.
469
81.4k
        NumItemsInBucketLeft =
470
81.4k
            endian::readNext<uint16_t, little, unaligned>(Ptr);
471
81.4k
      }
472
107k
      Ptr += sizeof(hash_value_type); // Skip the hash.
473
107k
      // Determine the length of the key and the data.
474
107k
      const std::pair<offset_type, offset_type> &L =
475
107k
          Info::ReadKeyDataLength(Ptr);
476
107k
      Ptr += L.first + L.second;
477
107k
      assert(NumItemsInBucketLeft);
478
107k
      --NumItemsInBucketLeft;
479
107k
      assert(NumEntriesLeft);
480
107k
      --NumEntriesLeft;
481
107k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator_base::advance()
Line
Count
Source
464
3.76k
    void advance() {
465
3.76k
      using namespace llvm::support;
466
3.76k
      if (!NumItemsInBucketLeft) {
467
2.76k
        // 'Items' starts with a 16-bit unsigned integer representing the
468
2.76k
        // number of items in this bucket.
469
2.76k
        NumItemsInBucketLeft =
470
2.76k
            endian::readNext<uint16_t, little, unaligned>(Ptr);
471
2.76k
      }
472
3.76k
      Ptr += sizeof(hash_value_type); // Skip the hash.
473
3.76k
      // Determine the length of the key and the data.
474
3.76k
      const std::pair<offset_type, offset_type> &L =
475
3.76k
          Info::ReadKeyDataLength(Ptr);
476
3.76k
      Ptr += L.first + L.second;
477
3.76k
      assert(NumItemsInBucketLeft);
478
3.76k
      --NumItemsInBucketLeft;
479
3.76k
      assert(NumEntriesLeft);
480
3.76k
      --NumEntriesLeft;
481
3.76k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base::advance()
Line
Count
Source
464
247
    void advance() {
465
247
      using namespace llvm::support;
466
247
      if (!NumItemsInBucketLeft) {
467
213
        // 'Items' starts with a 16-bit unsigned integer representing the
468
213
        // number of items in this bucket.
469
213
        NumItemsInBucketLeft =
470
213
            endian::readNext<uint16_t, little, unaligned>(Ptr);
471
213
      }
472
247
      Ptr += sizeof(hash_value_type); // Skip the hash.
473
247
      // Determine the length of the key and the data.
474
247
      const std::pair<offset_type, offset_type> &L =
475
247
          Info::ReadKeyDataLength(Ptr);
476
247
      Ptr += L.first + L.second;
477
247
      assert(NumItemsInBucketLeft);
478
247
      --NumItemsInBucketLeft;
479
247
      assert(NumEntriesLeft);
480
247
      --NumEntriesLeft;
481
247
    }
482
483
    /// Get the start of the item as written by the trait (after the hash and
484
    /// immediately before the key and value length).
485
309k
    const unsigned char *getItem() const {
486
309k
      return Ptr + (NumItemsInBucketLeft ? 
061.4k
:
2247k
) + sizeof(hash_value_type);
487
309k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::iterator_base::getItem() const
Line
Count
Source
485
2.61k
    const unsigned char *getItem() const {
486
2.61k
      return Ptr + (NumItemsInBucketLeft ? 
0642
:
21.96k
) + sizeof(hash_value_type);
487
2.61k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::iterator_base::getItem() const
Line
Count
Source
485
195k
    const unsigned char *getItem() const {
486
195k
      return Ptr + (NumItemsInBucketLeft ? 
034.0k
:
2161k
) + sizeof(hash_value_type);
487
195k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::iterator_base::getItem() const
Line
Count
Source
485
107k
    const unsigned char *getItem() const {
486
107k
      return Ptr + (NumItemsInBucketLeft ? 
025.6k
:
281.4k
) + sizeof(hash_value_type);
487
107k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::iterator_base::getItem() const
Line
Count
Source
485
3.76k
    const unsigned char *getItem() const {
486
3.76k
      return Ptr + (NumItemsInBucketLeft ? 
0998
:
22.76k
) + sizeof(hash_value_type);
487
3.76k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::iterator_base::getItem() const
Line
Count
Source
485
265
    const unsigned char *getItem() const {
486
265
      return Ptr + (NumItemsInBucketLeft ? 
034
:
2231
) + sizeof(hash_value_type);
487
265
    }
488
  };
489
490
public:
491
  OnDiskIterableChainedHashTable(offset_type NumBuckets, offset_type NumEntries,
492
                                 const unsigned char *Buckets,
493
                                 const unsigned char *Payload,
494
                                 const unsigned char *Base,
495
                                 const Info &InfoObj = Info())
496
      : base_type(NumBuckets, NumEntries, Buckets, Base, InfoObj),
497
21.0k
        Payload(Payload) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::OnDiskIterableChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, unsigned char const*, clang::serialization::reader::ASTIdentifierLookupTrait const&)
Line
Count
Source
497
6.13k
        Payload(Payload) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::OnDiskIterableChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, unsigned char const*, clang::serialization::reader::ASTDeclContextNameLookupTrait const&)
Line
Count
Source
497
12.9k
        Payload(Payload) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::OnDiskIterableChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, unsigned char const*, (anonymous namespace)::InterestingASTIdentifierLookupTrait const&)
Line
Count
Source
497
1.28k
        Payload(Payload) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::OnDiskIterableChainedHashTable(unsigned int, unsigned int, unsigned char const*, unsigned char const*, unsigned char const*, (anonymous namespace)::IdentifierIndexReaderTrait const&)
Line
Count
Source
497
185
        Payload(Payload) {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::OnDiskIterableChainedHashTable(unsigned long long, unsigned long long, unsigned char const*, unsigned char const*, unsigned char const*, llvm::InstrProfLookupTrait const&)
Line
Count
Source
497
525
        Payload(Payload) {}
498
499
  /// Iterates over all of the keys in the table.
500
  class key_iterator : public iterator_base {
501
    Info *InfoObj;
502
503
  public:
504
    typedef external_key_type value_type;
505
506
    key_iterator(const unsigned char *const Ptr, offset_type NumEntries,
507
                 Info *InfoObj)
508
492
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_iterator::key_iterator(unsigned char const*, unsigned int, clang::serialization::reader::ASTIdentifierLookupTrait*)
Line
Count
Source
508
470
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_iterator::key_iterator(unsigned char const*, unsigned int, (anonymous namespace)::IdentifierIndexReaderTrait*)
Line
Count
Source
508
14
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_iterator::key_iterator(unsigned char const*, unsigned long long, llvm::InstrProfLookupTrait*)
Line
Count
Source
508
8
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
509
1.18k
    key_iterator() : iterator_base(), InfoObj() {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_iterator::key_iterator()
Line
Count
Source
509
1.13k
    key_iterator() : iterator_base(), InfoObj() {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_iterator::key_iterator()
Line
Count
Source
509
42
    key_iterator() : iterator_base(), InfoObj() {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_iterator::key_iterator()
Line
Count
Source
509
8
    key_iterator() : iterator_base(), InfoObj() {}
510
511
199k
    key_iterator &operator++() {
512
199k
      this->advance();
513
199k
      return *this;
514
199k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_iterator::operator++()
Line
Count
Source
511
195k
    key_iterator &operator++() {
512
195k
      this->advance();
513
195k
      return *this;
514
195k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_iterator::operator++()
Line
Count
Source
511
3.76k
    key_iterator &operator++() {
512
3.76k
      this->advance();
513
3.76k
      return *this;
514
3.76k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_iterator::operator++()
Line
Count
Source
511
15
    key_iterator &operator++() {
512
15
      this->advance();
513
15
      return *this;
514
15
    }
515
    key_iterator operator++(int) { // Postincrement
516
      key_iterator tmp = *this;
517
      ++*this;
518
      return tmp;
519
    }
520
521
199k
    internal_key_type getInternalKey() const {
522
199k
      auto *LocalPtr = this->getItem();
523
199k
524
199k
      // Determine the length of the key and the data.
525
199k
      auto L = Info::ReadKeyDataLength(LocalPtr);
526
199k
527
199k
      // Read the key.
528
199k
      return InfoObj->ReadKey(LocalPtr, L.first);
529
199k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_iterator::getInternalKey() const
Line
Count
Source
521
195k
    internal_key_type getInternalKey() const {
522
195k
      auto *LocalPtr = this->getItem();
523
195k
524
195k
      // Determine the length of the key and the data.
525
195k
      auto L = Info::ReadKeyDataLength(LocalPtr);
526
195k
527
195k
      // Read the key.
528
195k
      return InfoObj->ReadKey(LocalPtr, L.first);
529
195k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_iterator::getInternalKey() const
Line
Count
Source
521
3.76k
    internal_key_type getInternalKey() const {
522
3.76k
      auto *LocalPtr = this->getItem();
523
3.76k
524
3.76k
      // Determine the length of the key and the data.
525
3.76k
      auto L = Info::ReadKeyDataLength(LocalPtr);
526
3.76k
527
3.76k
      // Read the key.
528
3.76k
      return InfoObj->ReadKey(LocalPtr, L.first);
529
3.76k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_iterator::getInternalKey() const
Line
Count
Source
521
15
    internal_key_type getInternalKey() const {
522
15
      auto *LocalPtr = this->getItem();
523
15
524
15
      // Determine the length of the key and the data.
525
15
      auto L = Info::ReadKeyDataLength(LocalPtr);
526
15
527
15
      // Read the key.
528
15
      return InfoObj->ReadKey(LocalPtr, L.first);
529
15
    }
530
531
199k
    value_type operator*() const {
532
199k
      return InfoObj->GetExternalKey(getInternalKey());
533
199k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_iterator::operator*() const
Line
Count
Source
531
195k
    value_type operator*() const {
532
195k
      return InfoObj->GetExternalKey(getInternalKey());
533
195k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_iterator::operator*() const
Line
Count
Source
531
3.76k
    value_type operator*() const {
532
3.76k
      return InfoObj->GetExternalKey(getInternalKey());
533
3.76k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_iterator::operator*() const
Line
Count
Source
531
15
    value_type operator*() const {
532
15
      return InfoObj->GetExternalKey(getInternalKey());
533
15
    }
534
  };
535
536
492
  key_iterator key_begin() {
537
492
    return key_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
538
492
  }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_begin()
Line
Count
Source
536
470
  key_iterator key_begin() {
537
470
    return key_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
538
470
  }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_begin()
Line
Count
Source
536
14
  key_iterator key_begin() {
537
14
    return key_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
538
14
  }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_begin()
Line
Count
Source
536
8
  key_iterator key_begin() {
537
8
    return key_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
538
8
  }
539
492
  key_iterator key_end() { return key_iterator(); }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::key_end()
Line
Count
Source
539
470
  key_iterator key_end() { return key_iterator(); }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::key_end()
Line
Count
Source
539
14
  key_iterator key_end() { return key_iterator(); }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::key_end()
Line
Count
Source
539
8
  key_iterator key_end() { return key_iterator(); }
540
541
8
  iterator_range<key_iterator> keys() {
542
8
    return make_range(key_begin(), key_end());
543
8
  }
544
545
  /// Iterates over all the entries in the table, returning the data.
546
  class data_iterator : public iterator_base {
547
    Info *InfoObj;
548
549
  public:
550
    typedef data_type value_type;
551
552
    data_iterator(const unsigned char *const Ptr, offset_type NumEntries,
553
                  Info *InfoObj)
554
2.10k
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::data_iterator::data_iterator(unsigned char const*, unsigned int, clang::serialization::reader::ASTDeclContextNameLookupTrait*)
Line
Count
Source
554
293
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::data_iterator::data_iterator(unsigned char const*, unsigned int, (anonymous namespace)::InterestingASTIdentifierLookupTrait*)
Line
Count
Source
554
1.28k
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::data_iterator::data_iterator(unsigned char const*, unsigned long long, llvm::InstrProfLookupTrait*)
Line
Count
Source
554
525
        : iterator_base(Ptr, NumEntries), InfoObj(InfoObj) {}
555
2.43k
    data_iterator() : iterator_base(), InfoObj() {}
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::data_iterator::data_iterator()
Line
Count
Source
555
293
    data_iterator() : iterator_base(), InfoObj() {}
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::data_iterator::data_iterator()
Line
Count
Source
555
1.28k
    data_iterator() : iterator_base(), InfoObj() {}
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::data_iterator::data_iterator()
Line
Count
Source
555
859
    data_iterator() : iterator_base(), InfoObj() {}
556
557
109k
    data_iterator &operator++() { // Preincrement
558
109k
      this->advance();
559
109k
      return *this;
560
109k
    }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::data_iterator::operator++()
Line
Count
Source
557
2.61k
    data_iterator &operator++() { // Preincrement
558
2.61k
      this->advance();
559
2.61k
      return *this;
560
2.61k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::data_iterator::operator++()
Line
Count
Source
557
107k
    data_iterator &operator++() { // Preincrement
558
107k
      this->advance();
559
107k
      return *this;
560
107k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::data_iterator::operator++()
Line
Count
Source
557
232
    data_iterator &operator++() { // Preincrement
558
232
      this->advance();
559
232
      return *this;
560
232
    }
561
232
    data_iterator operator++(int) { // Postincrement
562
232
      data_iterator tmp = *this;
563
232
      ++*this;
564
232
      return tmp;
565
232
    }
566
567
107k
    value_type operator*() const {
568
107k
      auto *LocalPtr = this->getItem();
569
107k
570
107k
      // Determine the length of the key and the data.
571
107k
      auto L = Info::ReadKeyDataLength(LocalPtr);
572
107k
573
107k
      // Read the key.
574
107k
      const internal_key_type &Key = InfoObj->ReadKey(LocalPtr, L.first);
575
107k
      return InfoObj->ReadData(Key, LocalPtr + L.first, L.second);
576
107k
    }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::data_iterator::operator*() const
Line
Count
Source
567
107k
    value_type operator*() const {
568
107k
      auto *LocalPtr = this->getItem();
569
107k
570
107k
      // Determine the length of the key and the data.
571
107k
      auto L = Info::ReadKeyDataLength(LocalPtr);
572
107k
573
107k
      // Read the key.
574
107k
      const internal_key_type &Key = InfoObj->ReadKey(LocalPtr, L.first);
575
107k
      return InfoObj->ReadData(Key, LocalPtr + L.first, L.second);
576
107k
    }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::data_iterator::operator*() const
Line
Count
Source
567
250
    value_type operator*() const {
568
250
      auto *LocalPtr = this->getItem();
569
250
570
250
      // Determine the length of the key and the data.
571
250
      auto L = Info::ReadKeyDataLength(LocalPtr);
572
250
573
250
      // Read the key.
574
250
      const internal_key_type &Key = InfoObj->ReadKey(LocalPtr, L.first);
575
250
      return InfoObj->ReadData(Key, LocalPtr + L.first, L.second);
576
250
    }
577
  };
578
579
2.10k
  data_iterator data_begin() {
580
2.10k
    return data_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
581
2.10k
  }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::data_begin()
Line
Count
Source
579
293
  data_iterator data_begin() {
580
293
    return data_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
581
293
  }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::data_begin()
Line
Count
Source
579
1.28k
  data_iterator data_begin() {
580
1.28k
    return data_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
581
1.28k
  }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::data_begin()
Line
Count
Source
579
525
  data_iterator data_begin() {
580
525
    return data_iterator(Payload, this->getNumEntries(), &this->getInfoObj());
581
525
  }
582
1.90k
  data_iterator data_end() { return data_iterator(); }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTDeclContextNameLookupTrait>::data_end()
Line
Count
Source
582
293
  data_iterator data_end() { return data_iterator(); }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::data_end()
Line
Count
Source
582
1.28k
  data_iterator data_end() { return data_iterator(); }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::data_end()
Line
Count
Source
582
334
  data_iterator data_end() { return data_iterator(); }
583
584
  iterator_range<data_iterator> data() {
585
    return make_range(data_begin(), data_end());
586
  }
587
588
  /// Create the hash table.
589
  ///
590
  /// \param Buckets is the beginning of the hash table itself, which follows
591
  /// the payload of entire structure. This is the value returned by
592
  /// OnDiskHashTableGenerator::Emit.
593
  ///
594
  /// \param Payload is the beginning of the data contained in the table.  This
595
  /// is Base plus any padding or header data that was stored, ie, the offset
596
  /// that the stream was at when calling Emit.
597
  ///
598
  /// \param Base is the point from which all offsets into the structure are
599
  /// based. This is offset 0 in the stream that was used when Emitting the
600
  /// table.
601
  static OnDiskIterableChainedHashTable *
602
  Create(const unsigned char *Buckets, const unsigned char *const Payload,
603
8.12k
         const unsigned char *const Base, const Info &InfoObj = Info()) {
604
8.12k
    assert(Buckets > Base);
605
8.12k
    auto NumBucketsAndEntries =
606
8.12k
        OnDiskIterableChainedHashTable<Info>::readNumBucketsAndEntries(Buckets);
607
8.12k
    return new OnDiskIterableChainedHashTable<Info>(
608
8.12k
        NumBucketsAndEntries.first, NumBucketsAndEntries.second,
609
8.12k
        Buckets, Payload, Base, InfoObj);
610
8.12k
  }
llvm::OnDiskIterableChainedHashTable<clang::serialization::reader::ASTIdentifierLookupTrait>::Create(unsigned char const*, unsigned char const*, unsigned char const*, clang::serialization::reader::ASTIdentifierLookupTrait const&)
Line
Count
Source
603
6.13k
         const unsigned char *const Base, const Info &InfoObj = Info()) {
604
6.13k
    assert(Buckets > Base);
605
6.13k
    auto NumBucketsAndEntries =
606
6.13k
        OnDiskIterableChainedHashTable<Info>::readNumBucketsAndEntries(Buckets);
607
6.13k
    return new OnDiskIterableChainedHashTable<Info>(
608
6.13k
        NumBucketsAndEntries.first, NumBucketsAndEntries.second,
609
6.13k
        Buckets, Payload, Base, InfoObj);
610
6.13k
  }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::InterestingASTIdentifierLookupTrait>::Create(unsigned char const*, unsigned char const*, unsigned char const*, (anonymous namespace)::InterestingASTIdentifierLookupTrait const&)
Line
Count
Source
603
1.28k
         const unsigned char *const Base, const Info &InfoObj = Info()) {
604
1.28k
    assert(Buckets > Base);
605
1.28k
    auto NumBucketsAndEntries =
606
1.28k
        OnDiskIterableChainedHashTable<Info>::readNumBucketsAndEntries(Buckets);
607
1.28k
    return new OnDiskIterableChainedHashTable<Info>(
608
1.28k
        NumBucketsAndEntries.first, NumBucketsAndEntries.second,
609
1.28k
        Buckets, Payload, Base, InfoObj);
610
1.28k
  }
GlobalModuleIndex.cpp:llvm::OnDiskIterableChainedHashTable<(anonymous namespace)::IdentifierIndexReaderTrait>::Create(unsigned char const*, unsigned char const*, unsigned char const*, (anonymous namespace)::IdentifierIndexReaderTrait const&)
Line
Count
Source
603
185
         const unsigned char *const Base, const Info &InfoObj = Info()) {
604
185
    assert(Buckets > Base);
605
185
    auto NumBucketsAndEntries =
606
185
        OnDiskIterableChainedHashTable<Info>::readNumBucketsAndEntries(Buckets);
607
185
    return new OnDiskIterableChainedHashTable<Info>(
608
185
        NumBucketsAndEntries.first, NumBucketsAndEntries.second,
609
185
        Buckets, Payload, Base, InfoObj);
610
185
  }
llvm::OnDiskIterableChainedHashTable<llvm::InstrProfLookupTrait>::Create(unsigned char const*, unsigned char const*, unsigned char const*, llvm::InstrProfLookupTrait const&)
Line
Count
Source
603
525
         const unsigned char *const Base, const Info &InfoObj = Info()) {
604
525
    assert(Buckets > Base);
605
525
    auto NumBucketsAndEntries =
606
525
        OnDiskIterableChainedHashTable<Info>::readNumBucketsAndEntries(Buckets);
607
525
    return new OnDiskIterableChainedHashTable<Info>(
608
525
        NumBucketsAndEntries.first, NumBucketsAndEntries.second,
609
525
        Buckets, Payload, Base, InfoObj);
610
525
  }
611
};
612
613
} // end namespace llvm
614
615
#endif