Coverage Report

Created: 2018-07-12 09:57

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/ADT/IntervalMap.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/ADT/IntervalMap.h - A sorted interval map -----------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file implements a coalescing interval map for small objects.
11
//
12
// KeyT objects are mapped to ValT objects. Intervals of keys that map to the
13
// same value are represented in a compressed form.
14
//
15
// Iterators provide ordered access to the compressed intervals rather than the
16
// individual keys, and insert and erase operations use key intervals as well.
17
//
18
// Like SmallVector, IntervalMap will store the first N intervals in the map
19
// object itself without any allocations. When space is exhausted it switches to
20
// a B+-tree representation with very small overhead for small key and value
21
// objects.
22
//
23
// A Traits class specifies how keys are compared. It also allows IntervalMap to
24
// work with both closed and half-open intervals.
25
//
26
// Keys and values are not stored next to each other in a std::pair, so we don't
27
// provide such a value_type. Dereferencing iterators only returns the mapped
28
// value. The interval bounds are accessible through the start() and stop()
29
// iterator methods.
30
//
31
// IntervalMap is optimized for small key and value objects, 4 or 8 bytes each
32
// is the optimal size. For large objects use std::map instead.
33
//
34
//===----------------------------------------------------------------------===//
35
//
36
// Synopsis:
37
//
38
// template <typename KeyT, typename ValT, unsigned N, typename Traits>
39
// class IntervalMap {
40
// public:
41
//   typedef KeyT key_type;
42
//   typedef ValT mapped_type;
43
//   typedef RecyclingAllocator<...> Allocator;
44
//   class iterator;
45
//   class const_iterator;
46
//
47
//   explicit IntervalMap(Allocator&);
48
//   ~IntervalMap():
49
//
50
//   bool empty() const;
51
//   KeyT start() const;
52
//   KeyT stop() const;
53
//   ValT lookup(KeyT x, Value NotFound = Value()) const;
54
//
55
//   const_iterator begin() const;
56
//   const_iterator end() const;
57
//   iterator begin();
58
//   iterator end();
59
//   const_iterator find(KeyT x) const;
60
//   iterator find(KeyT x);
61
//
62
//   void insert(KeyT a, KeyT b, ValT y);
63
//   void clear();
64
// };
65
//
66
// template <typename KeyT, typename ValT, unsigned N, typename Traits>
67
// class IntervalMap::const_iterator :
68
//   public std::iterator<std::bidirectional_iterator_tag, ValT> {
69
// public:
70
//   bool operator==(const const_iterator &) const;
71
//   bool operator!=(const const_iterator &) const;
72
//   bool valid() const;
73
//
74
//   const KeyT &start() const;
75
//   const KeyT &stop() const;
76
//   const ValT &value() const;
77
//   const ValT &operator*() const;
78
//   const ValT *operator->() const;
79
//
80
//   const_iterator &operator++();
81
//   const_iterator &operator++(int);
82
//   const_iterator &operator--();
83
//   const_iterator &operator--(int);
84
//   void goToBegin();
85
//   void goToEnd();
86
//   void find(KeyT x);
87
//   void advanceTo(KeyT x);
88
// };
89
//
90
// template <typename KeyT, typename ValT, unsigned N, typename Traits>
91
// class IntervalMap::iterator : public const_iterator {
92
// public:
93
//   void insert(KeyT a, KeyT b, Value y);
94
//   void erase();
95
// };
96
//
97
//===----------------------------------------------------------------------===//
98
99
#ifndef LLVM_ADT_INTERVALMAP_H
100
#define LLVM_ADT_INTERVALMAP_H
101
102
#include "llvm/ADT/PointerIntPair.h"
103
#include "llvm/ADT/SmallVector.h"
104
#include "llvm/Support/AlignOf.h"
105
#include "llvm/Support/Allocator.h"
106
#include "llvm/Support/RecyclingAllocator.h"
107
#include <algorithm>
108
#include <cassert>
109
#include <cstdint>
110
#include <iterator>
111
#include <new>
112
#include <utility>
113
114
namespace llvm {
115
116
//===----------------------------------------------------------------------===//
117
//---                              Key traits                              ---//
118
//===----------------------------------------------------------------------===//
119
//
120
// The IntervalMap works with closed or half-open intervals.
121
// Adjacent intervals that map to the same value are coalesced.
122
//
123
// The IntervalMapInfo traits class is used to determine if a key is contained
124
// in an interval, and if two intervals are adjacent so they can be coalesced.
125
// The provided implementation works for closed integer intervals, other keys
126
// probably need a specialized version.
127
//
128
// The point x is contained in [a;b] when !startLess(x, a) && !stopLess(b, x).
129
//
130
// It is assumed that (a;b] half-open intervals are not used, only [a;b) is
131
// allowed. This is so that stopLess(a, b) can be used to determine if two
132
// intervals overlap.
133
//
134
//===----------------------------------------------------------------------===//
135
136
template <typename T>
137
struct IntervalMapInfo {
138
  /// startLess - Return true if x is not in [a;b].
139
  /// This is x < a both for closed intervals and for [a;b) half-open intervals.
140
  static inline bool startLess(const T &x, const T &a) {
141
    return x < a;
142
  }
143
144
  /// stopLess - Return true if x is not in [a;b].
145
  /// This is b < x for a closed interval, b <= x for [a;b) half-open intervals.
146
  static inline bool stopLess(const T &b, const T &x) {
147
    return b < x;
148
  }
149
150
  /// adjacent - Return true when the intervals [x;a] and [b;y] can coalesce.
151
  /// This is a+1 == b for closed intervals, a == b for half-open intervals.
152
  static inline bool adjacent(const T &a, const T &b) {
153
    return a+1 == b;
154
  }
155
156
  /// nonEmpty - Return true if [a;b] is non-empty.
157
  /// This is a <= b for a closed interval, a < b for [a;b) half-open intervals.
158
  static inline bool nonEmpty(const T &a, const T &b) {
159
    return a <= b;
160
  }
161
};
162
163
template <typename T>
164
struct IntervalMapHalfOpenInfo {
165
  /// startLess - Return true if x is not in [a;b).
166
2.72M
  static inline bool startLess(const T &x, const T &a) {
167
2.72M
    return x < a;
168
2.72M
  }
169
170
  /// stopLess - Return true if x is not in [a;b).
171
440M
  static inline bool stopLess(const T &b, const T &x) {
172
440M
    return b <= x;
173
440M
  }
174
175
  /// adjacent - Return true when the intervals [x;a) and [b;y) can coalesce.
176
12.0M
  static inline bool adjacent(const T &a, const T &b) {
177
12.0M
    return a == b;
178
12.0M
  }
179
180
  /// nonEmpty - Return true if [a;b) is non-empty.
181
  static inline bool nonEmpty(const T &a, const T &b) {
182
    return a < b;
183
  }
184
};
185
186
/// IntervalMapImpl - Namespace used for IntervalMap implementation details.
187
/// It should be considered private to the implementation.
188
namespace IntervalMapImpl {
189
190
using IdxPair = std::pair<unsigned,unsigned>;
191
192
//===----------------------------------------------------------------------===//
193
//---                    IntervalMapImpl::NodeBase                         ---//
194
//===----------------------------------------------------------------------===//
195
//
196
// Both leaf and branch nodes store vectors of pairs.
197
// Leaves store ((KeyT, KeyT), ValT) pairs, branches use (NodeRef, KeyT).
198
//
199
// Keys and values are stored in separate arrays to avoid padding caused by
200
// different object alignments. This also helps improve locality of reference
201
// when searching the keys.
202
//
203
// The nodes don't know how many elements they contain - that information is
204
// stored elsewhere. Omitting the size field prevents padding and allows a node
205
// to fill the allocated cache lines completely.
206
//
207
// These are typical key and value sizes, the node branching factor (N), and
208
// wasted space when nodes are sized to fit in three cache lines (192 bytes):
209
//
210
//   T1  T2   N Waste  Used by
211
//    4   4  24   0    Branch<4> (32-bit pointers)
212
//    8   4  16   0    Leaf<4,4>, Branch<4>
213
//    8   8  12   0    Leaf<4,8>, Branch<8>
214
//   16   4   9  12    Leaf<8,4>
215
//   16   8   8   0    Leaf<8,8>
216
//
217
//===----------------------------------------------------------------------===//
218
219
template <typename T1, typename T2, unsigned N>
220
class NodeBase {
221
public:
222
  enum { Capacity = N };
223
224
  T1 first[N];
225
  T2 second[N];
226
227
  /// copy - Copy elements from another node.
228
  /// @param Other Node elements are copied from.
229
  /// @param i     Beginning of the source range in other.
230
  /// @param j     Beginning of the destination range in this.
231
  /// @param Count Number of elements to copy.
232
  template <unsigned M>
233
  void copy(const NodeBase<T1, T2, M> &Other, unsigned i,
234
5.02M
            unsigned j, unsigned Count) {
235
5.02M
    assert(i + Count <= M && "Invalid source range");
236
5.02M
    assert(j + Count <= N && "Invalid dest range");
237
18.7M
    for (unsigned e = i + Count; i != e; 
++i, ++j13.7M
) {
238
13.7M
      first[j]  = Other.first[i];
239
13.7M
      second[j] = Other.second[i];
240
13.7M
    }
241
5.02M
  }
Unexecuted instantiation: void llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u>::copy<4u>(llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u> const&, unsigned int, unsigned int, unsigned int)
void llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::copy<12u>(llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
48.3k
            unsigned j, unsigned Count) {
235
48.3k
    assert(i + Count <= M && "Invalid source range");
236
48.3k
    assert(j + Count <= N && "Invalid dest range");
237
297k
    for (unsigned e = i + Count; i != e; 
++i, ++j249k
) {
238
249k
      first[j]  = Other.first[i];
239
249k
      second[j] = Other.second[i];
240
249k
    }
241
48.3k
  }
void llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::copy<9u>(llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
3
            unsigned j, unsigned Count) {
235
3
    assert(i + Count <= M && "Invalid source range");
236
3
    assert(j + Count <= N && "Invalid dest range");
237
6
    for (unsigned e = i + Count; i != e; 
++i, ++j3
) {
238
3
      first[j]  = Other.first[i];
239
3
      second[j] = Other.second[i];
240
3
    }
241
3
  }
Unexecuted instantiation: void llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::copy<4u>(llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u> const&, unsigned int, unsigned int, unsigned int)
void llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u>::copy<4u>(llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
7
            unsigned j, unsigned Count) {
235
7
    assert(i + Count <= M && "Invalid source range");
236
7
    assert(j + Count <= N && "Invalid dest range");
237
15
    for (unsigned e = i + Count; i != e; 
++i, ++j8
) {
238
8
      first[j]  = Other.first[i];
239
8
      second[j] = Other.second[i];
240
8
    }
241
7
  }
void llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::copy<4u>(llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
5
            unsigned j, unsigned Count) {
235
5
    assert(i + Count <= M && "Invalid source range");
236
5
    assert(j + Count <= N && "Invalid dest range");
237
25
    for (unsigned e = i + Count; i != e; 
++i, ++j20
) {
238
20
      first[j]  = Other.first[i];
239
20
      second[j] = Other.second[i];
240
20
    }
241
5
  }
void llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u>::copy<11u>(llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
31.2k
            unsigned j, unsigned Count) {
235
31.2k
    assert(i + Count <= M && "Invalid source range");
236
31.2k
    assert(j + Count <= N && "Invalid dest range");
237
61.8k
    for (unsigned e = i + Count; i != e; 
++i, ++j30.6k
) {
238
30.6k
      first[j]  = Other.first[i];
239
30.6k
      second[j] = Other.second[i];
240
30.6k
    }
241
31.2k
  }
void llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::copy<8u>(llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
4.55M
            unsigned j, unsigned Count) {
235
4.55M
    assert(i + Count <= M && "Invalid source range");
236
4.55M
    assert(j + Count <= N && "Invalid dest range");
237
17.0M
    for (unsigned e = i + Count; i != e; 
++i, ++j12.4M
) {
238
12.4M
      first[j]  = Other.first[i];
239
12.4M
      second[j] = Other.second[i];
240
12.4M
    }
241
4.55M
  }
void llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::copy<11u>(llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
6.41k
            unsigned j, unsigned Count) {
235
6.41k
    assert(i + Count <= M && "Invalid source range");
236
6.41k
    assert(j + Count <= N && "Invalid dest range");
237
76.9k
    for (unsigned e = i + Count; i != e; 
++i, ++j70.5k
) {
238
70.5k
      first[j]  = Other.first[i];
239
70.5k
      second[j] = Other.second[i];
240
70.5k
    }
241
6.41k
  }
void llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::copy<9u>(llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u> const&, unsigned int, unsigned int, unsigned int)
Line
Count
Source
234
382k
            unsigned j, unsigned Count) {
235
382k
    assert(i + Count <= M && "Invalid source range");
236
382k
    assert(j + Count <= N && "Invalid dest range");
237
1.26M
    for (unsigned e = i + Count; i != e; 
++i, ++j882k
) {
238
882k
      first[j]  = Other.first[i];
239
882k
      second[j] = Other.second[i];
240
882k
    }
241
382k
  }
242
243
  /// moveLeft - Move elements to the left.
244
  /// @param i     Beginning of the source range.
245
  /// @param j     Beginning of the destination range.
246
  /// @param Count Number of elements to copy.
247
2.74M
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
2.74M
    assert(j <= i && "Use moveRight shift elements right");
249
2.74M
    copy(*this, i, j, Count);
250
2.74M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u>::moveLeft(unsigned int, unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::moveLeft(unsigned int, unsigned int, unsigned int)
Line
Count
Source
247
18.4k
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
18.4k
    assert(j <= i && "Use moveRight shift elements right");
249
18.4k
    copy(*this, i, j, Count);
250
18.4k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::moveLeft(unsigned int, unsigned int, unsigned int)
Line
Count
Source
247
3
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
3
    assert(j <= i && "Use moveRight shift elements right");
249
3
    copy(*this, i, j, Count);
250
3
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u>::moveLeft(unsigned int, unsigned int, unsigned int)
Line
Count
Source
247
7
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
7
    assert(j <= i && "Use moveRight shift elements right");
249
7
    copy(*this, i, j, Count);
250
7
  }
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u>::moveLeft(unsigned int, unsigned int, unsigned int)
Line
Count
Source
247
31.2k
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
31.2k
    assert(j <= i && "Use moveRight shift elements right");
249
31.2k
    copy(*this, i, j, Count);
250
31.2k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::moveLeft(unsigned int, unsigned int, unsigned int)
Line
Count
Source
247
2.37M
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
2.37M
    assert(j <= i && "Use moveRight shift elements right");
249
2.37M
    copy(*this, i, j, Count);
250
2.37M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::moveLeft(unsigned int, unsigned int, unsigned int)
Line
Count
Source
247
321k
  void moveLeft(unsigned i, unsigned j, unsigned Count) {
248
321k
    assert(j <= i && "Use moveRight shift elements right");
249
321k
    copy(*this, i, j, Count);
250
321k
  }
251
252
  /// moveRight - Move elements to the right.
253
  /// @param i     Beginning of the source range.
254
  /// @param j     Beginning of the destination range.
255
  /// @param Count Number of elements to copy.
256
8.26M
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
8.26M
    assert(i <= j && "Use moveLeft shift elements left");
258
8.26M
    assert(j + Count <= N && "Invalid range");
259
26.2M
    while (Count--) {
260
18.0M
      first[j + Count]  = first[i + Count];
261
18.0M
      second[j + Count] = second[i + Count];
262
18.0M
    }
263
8.26M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::moveRight(unsigned int, unsigned int, unsigned int)
Line
Count
Source
256
2
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
2
    assert(i <= j && "Use moveLeft shift elements left");
258
2
    assert(j + Count <= N && "Invalid range");
259
6
    while (Count--) {
260
4
      first[j + Count]  = first[i + Count];
261
4
      second[j + Count] = second[i + Count];
262
4
    }
263
2
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u>::moveRight(unsigned int, unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::moveRight(unsigned int, unsigned int, unsigned int)
Line
Count
Source
256
97.0k
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
97.0k
    assert(i <= j && "Use moveLeft shift elements left");
258
97.0k
    assert(j + Count <= N && "Invalid range");
259
377k
    while (Count--) {
260
280k
      first[j + Count]  = first[i + Count];
261
280k
      second[j + Count] = second[i + Count];
262
280k
    }
263
97.0k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u>::moveRight(unsigned int, unsigned int, unsigned int)
Line
Count
Source
256
9
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
9
    assert(i <= j && "Use moveLeft shift elements left");
258
9
    assert(j + Count <= N && "Invalid range");
259
22
    while (Count--) {
260
13
      first[j + Count]  = first[i + Count];
261
13
      second[j + Count] = second[i + Count];
262
13
    }
263
9
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::moveRight(unsigned int, unsigned int, unsigned int)
Line
Count
Source
256
7.49M
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
7.49M
    assert(i <= j && "Use moveLeft shift elements left");
258
7.49M
    assert(j + Count <= N && "Invalid range");
259
23.7M
    while (Count--) {
260
16.2M
      first[j + Count]  = first[i + Count];
261
16.2M
      second[j + Count] = second[i + Count];
262
16.2M
    }
263
7.49M
  }
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u>::moveRight(unsigned int, unsigned int, unsigned int)
Line
Count
Source
256
292k
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
292k
    assert(i <= j && "Use moveLeft shift elements left");
258
292k
    assert(j + Count <= N && "Invalid range");
259
700k
    while (Count--) {
260
407k
      first[j + Count]  = first[i + Count];
261
407k
      second[j + Count] = second[i + Count];
262
407k
    }
263
292k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::moveRight(unsigned int, unsigned int, unsigned int)
Line
Count
Source
256
381k
  void moveRight(unsigned i, unsigned j, unsigned Count) {
257
381k
    assert(i <= j && "Use moveLeft shift elements left");
258
381k
    assert(j + Count <= N && "Invalid range");
259
1.41M
    while (Count--) {
260
1.02M
      first[j + Count]  = first[i + Count];
261
1.02M
      second[j + Count] = second[i + Count];
262
1.02M
    }
263
381k
  }
264
265
  /// erase - Erase elements [i;j).
266
  /// @param i    Beginning of the range to erase.
267
  /// @param j    End of the range. (Exclusive).
268
  /// @param Size Number of elements in node.
269
2.74M
  void erase(unsigned i, unsigned j, unsigned Size) {
270
2.74M
    moveLeft(j, i, Size - j);
271
2.74M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u>::erase(unsigned int, unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::erase(unsigned int, unsigned int, unsigned int)
Line
Count
Source
269
18.4k
  void erase(unsigned i, unsigned j, unsigned Size) {
270
18.4k
    moveLeft(j, i, Size - j);
271
18.4k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::erase(unsigned int, unsigned int, unsigned int)
Line
Count
Source
269
3
  void erase(unsigned i, unsigned j, unsigned Size) {
270
3
    moveLeft(j, i, Size - j);
271
3
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u>::erase(unsigned int, unsigned int, unsigned int)
Line
Count
Source
269
7
  void erase(unsigned i, unsigned j, unsigned Size) {
270
7
    moveLeft(j, i, Size - j);
271
7
  }
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u>::erase(unsigned int, unsigned int, unsigned int)
Line
Count
Source
269
31.2k
  void erase(unsigned i, unsigned j, unsigned Size) {
270
31.2k
    moveLeft(j, i, Size - j);
271
31.2k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::erase(unsigned int, unsigned int, unsigned int)
Line
Count
Source
269
2.37M
  void erase(unsigned i, unsigned j, unsigned Size) {
270
2.37M
    moveLeft(j, i, Size - j);
271
2.37M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::erase(unsigned int, unsigned int, unsigned int)
Line
Count
Source
269
321k
  void erase(unsigned i, unsigned j, unsigned Size) {
270
321k
    moveLeft(j, i, Size - j);
271
321k
  }
272
273
  /// erase - Erase element at i.
274
  /// @param i    Index of element to erase.
275
  /// @param Size Number of elements in node.
276
1.85M
  void erase(unsigned i, unsigned Size) {
277
1.85M
    erase(i, i+1, Size);
278
1.85M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u>::erase(unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::erase(unsigned int, unsigned int)
Line
Count
Source
276
2.25k
  void erase(unsigned i, unsigned Size) {
277
2.25k
    erase(i, i+1, Size);
278
2.25k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::erase(unsigned int, unsigned int)
Line
Count
Source
276
3
  void erase(unsigned i, unsigned Size) {
277
3
    erase(i, i+1, Size);
278
3
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u>::erase(unsigned int, unsigned int)
Line
Count
Source
276
7
  void erase(unsigned i, unsigned Size) {
277
7
    erase(i, i+1, Size);
278
7
  }
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u>::erase(unsigned int, unsigned int)
Line
Count
Source
276
31.2k
  void erase(unsigned i, unsigned Size) {
277
31.2k
    erase(i, i+1, Size);
278
31.2k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::erase(unsigned int, unsigned int)
Line
Count
Source
276
1.52M
  void erase(unsigned i, unsigned Size) {
277
1.52M
    erase(i, i+1, Size);
278
1.52M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::erase(unsigned int, unsigned int)
Line
Count
Source
276
300k
  void erase(unsigned i, unsigned Size) {
277
300k
    erase(i, i+1, Size);
278
300k
  }
279
280
  /// shift - Shift elements [i;size) 1 position to the right.
281
  /// @param i    Beginning of the range to move.
282
  /// @param Size Number of elements in node.
283
7.51M
  void shift(unsigned i, unsigned Size) {
284
7.51M
    moveRight(i, i + 1, Size - i);
285
7.51M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::shift(unsigned int, unsigned int)
Line
Count
Source
283
2
  void shift(unsigned i, unsigned Size) {
284
2
    moveRight(i, i + 1, Size - i);
285
2
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 4u>::shift(unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::shift(unsigned int, unsigned int)
Line
Count
Source
283
83.2k
  void shift(unsigned i, unsigned Size) {
284
83.2k
    moveRight(i, i + 1, Size - i);
285
83.2k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 4u>::shift(unsigned int, unsigned int)
Line
Count
Source
283
9
  void shift(unsigned i, unsigned Size) {
284
9
    moveRight(i, i + 1, Size - i);
285
9
  }
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 11u>::shift(unsigned int, unsigned int)
Line
Count
Source
283
292k
  void shift(unsigned i, unsigned Size) {
284
292k
    moveRight(i, i + 1, Size - i);
285
292k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::shift(unsigned int, unsigned int)
Line
Count
Source
283
6.77M
  void shift(unsigned i, unsigned Size) {
284
6.77M
    moveRight(i, i + 1, Size - i);
285
6.77M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::shift(unsigned int, unsigned int)
Line
Count
Source
283
367k
  void shift(unsigned i, unsigned Size) {
284
367k
    moveRight(i, i + 1, Size - i);
285
367k
  }
286
287
  /// transferToLeftSib - Transfer elements to a left sibling node.
288
  /// @param Size  Number of elements in this.
289
  /// @param Sib   Left sibling node.
290
  /// @param SSize Number of elements in sib.
291
  /// @param Count Number of elements to transfer.
292
  void transferToLeftSib(unsigned Size, NodeBase &Sib, unsigned SSize,
293
893k
                         unsigned Count) {
294
893k
    Sib.copy(*this, 0, SSize, Count);
295
893k
    erase(0, Count, Size);
296
893k
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::transferToLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>&, unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::transferToLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>&, unsigned int, unsigned int)
Line
Count
Source
293
16.1k
                         unsigned Count) {
294
16.1k
    Sib.copy(*this, 0, SSize, Count);
295
16.1k
    erase(0, Count, Size);
296
16.1k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::transferToLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>&, unsigned int, unsigned int)
Line
Count
Source
293
856k
                         unsigned Count) {
294
856k
    Sib.copy(*this, 0, SSize, Count);
295
856k
    erase(0, Count, Size);
296
856k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::transferToLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>&, unsigned int, unsigned int)
Line
Count
Source
293
21.4k
                         unsigned Count) {
294
21.4k
    Sib.copy(*this, 0, SSize, Count);
295
21.4k
    erase(0, Count, Size);
296
21.4k
  }
297
298
  /// transferToRightSib - Transfer elements to a right sibling node.
299
  /// @param Size  Number of elements in this.
300
  /// @param Sib   Right sibling node.
301
  /// @param SSize Number of elements in sib.
302
  /// @param Count Number of elements to transfer.
303
  void transferToRightSib(unsigned Size, NodeBase &Sib, unsigned SSize,
304
748k
                          unsigned Count) {
305
748k
    Sib.moveRight(0, Count, SSize);
306
748k
    Sib.copy(*this, Size-Count, 0, Count);
307
748k
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::transferToRightSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>&, unsigned int, unsigned int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::transferToRightSib(unsigned int, llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>&, unsigned int, unsigned int)
Line
Count
Source
304
13.7k
                          unsigned Count) {
305
13.7k
    Sib.moveRight(0, Count, SSize);
306
13.7k
    Sib.copy(*this, Size-Count, 0, Count);
307
13.7k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::transferToRightSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>&, unsigned int, unsigned int)
Line
Count
Source
304
721k
                          unsigned Count) {
305
721k
    Sib.moveRight(0, Count, SSize);
306
721k
    Sib.copy(*this, Size-Count, 0, Count);
307
721k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::transferToRightSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>&, unsigned int, unsigned int)
Line
Count
Source
304
13.8k
                          unsigned Count) {
305
13.8k
    Sib.moveRight(0, Count, SSize);
306
13.8k
    Sib.copy(*this, Size-Count, 0, Count);
307
13.8k
  }
308
309
  /// adjustFromLeftSib - Adjust the number if elements in this node by moving
310
  /// elements to or from a left sibling node.
311
  /// @param Size  Number of elements in this.
312
  /// @param Sib   Right sibling node.
313
  /// @param SSize Number of elements in sib.
314
  /// @param Add   The number of elements to add to this node, possibly < 0.
315
  /// @return      Number of elements added to this node, possibly negative.
316
1.64M
  int adjustFromLeftSib(unsigned Size, NodeBase &Sib, unsigned SSize, int Add) {
317
1.64M
    if (Add > 0) {
318
748k
      // We want to grow, copy from sib.
319
748k
      unsigned Count = std::min(std::min(unsigned(Add), SSize), N - Size);
320
748k
      Sib.transferToRightSib(SSize, *this, Size, Count);
321
748k
      return Count;
322
893k
    } else {
323
893k
      // We want to shrink, copy to sib.
324
893k
      unsigned Count = std::min(std::min(unsigned(-Add), Size), N - SSize);
325
893k
      transferToLeftSib(Size, Sib, SSize, Count);
326
893k
      return -Count;
327
893k
    }
328
1.64M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>::adjustFromLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, DbgValueLocation, 9u>&, unsigned int, int)
llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>::adjustFromLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex, 12u>&, unsigned int, int)
Line
Count
Source
316
29.9k
  int adjustFromLeftSib(unsigned Size, NodeBase &Sib, unsigned SSize, int Add) {
317
29.9k
    if (Add > 0) {
318
13.7k
      // We want to grow, copy from sib.
319
13.7k
      unsigned Count = std::min(std::min(unsigned(Add), SSize), N - Size);
320
13.7k
      Sib.transferToRightSib(SSize, *this, Size, Count);
321
13.7k
      return Count;
322
16.1k
    } else {
323
16.1k
      // We want to shrink, copy to sib.
324
16.1k
      unsigned Count = std::min(std::min(unsigned(-Add), Size), N - SSize);
325
16.1k
      transferToLeftSib(Size, Sib, SSize, Count);
326
16.1k
      return -Count;
327
16.1k
    }
328
29.9k
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>::adjustFromLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, llvm::LiveInterval*, 8u>&, unsigned int, int)
Line
Count
Source
316
1.57M
  int adjustFromLeftSib(unsigned Size, NodeBase &Sib, unsigned SSize, int Add) {
317
1.57M
    if (Add > 0) {
318
721k
      // We want to grow, copy from sib.
319
721k
      unsigned Count = std::min(std::min(unsigned(Add), SSize), N - Size);
320
721k
      Sib.transferToRightSib(SSize, *this, Size, Count);
321
721k
      return Count;
322
856k
    } else {
323
856k
      // We want to shrink, copy to sib.
324
856k
      unsigned Count = std::min(std::min(unsigned(-Add), Size), N - SSize);
325
856k
      transferToLeftSib(Size, Sib, SSize, Count);
326
856k
      return -Count;
327
856k
    }
328
1.57M
  }
llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>::adjustFromLeftSib(unsigned int, llvm::IntervalMapImpl::NodeBase<std::__1::pair<llvm::SlotIndex, llvm::SlotIndex>, unsigned int, 9u>&, unsigned int, int)
Line
Count
Source
316
35.2k
  int adjustFromLeftSib(unsigned Size, NodeBase &Sib, unsigned SSize, int Add) {
317
35.2k
    if (Add > 0) {
318
13.8k
      // We want to grow, copy from sib.
319
13.8k
      unsigned Count = std::min(std::min(unsigned(Add), SSize), N - Size);
320
13.8k
      Sib.transferToRightSib(SSize, *this, Size, Count);
321
13.8k
      return Count;
322
21.4k
    } else {
323
21.4k
      // We want to shrink, copy to sib.
324
21.4k
      unsigned Count = std::min(std::min(unsigned(-Add), Size), N - SSize);
325
21.4k
      transferToLeftSib(Size, Sib, SSize, Count);
326
21.4k
      return -Count;
327
21.4k
    }
328
35.2k
  }
329
};
330
331
/// IntervalMapImpl::adjustSiblingSizes - Move elements between sibling nodes.
332
/// @param Node  Array of pointers to sibling nodes.
333
/// @param Nodes Number of nodes.
334
/// @param CurSize Array of current node sizes, will be overwritten.
335
/// @param NewSize Array of desired node sizes.
336
template <typename NodeT>
337
void adjustSiblingSizes(NodeT *Node[], unsigned Nodes,
338
1.09M
                        unsigned CurSize[], const unsigned NewSize[]) {
339
1.09M
  // Move elements right.
340
2.87M
  for (int n = Nodes - 1; n; 
--n1.78M
) {
341
1.78M
    if (CurSize[n] == NewSize[n])
342
160k
      continue;
343
1.62M
    for (int m = n - 1; m != -1; 
--m0
) {
344
1.62M
      int d = Node[n]->adjustFromLeftSib(CurSize[n], *Node[m], CurSize[m],
345
1.62M
                                         NewSize[n] - CurSize[n]);
346
1.62M
      CurSize[m] -= d;
347
1.62M
      CurSize[n] += d;
348
1.62M
      // Keep going if the current node was exhausted.
349
1.62M
      if (CurSize[n] >= NewSize[n])
350
1.62M
          break;
351
1.62M
    }
352
1.62M
  }
353
1.09M
354
1.09M
  if (Nodes == 0)
355
0
    return;
356
1.09M
357
1.09M
  // Move elements left.
358
2.87M
  
for (unsigned n = 0; 1.09M
n != Nodes - 1;
++n1.78M
) {
359
1.78M
    if (CurSize[n] == NewSize[n])
360
1.75M
      continue;
361
21.4k
    for (unsigned m = n + 1; m != Nodes; 
++m0
) {
362
21.4k
      int d = Node[m]->adjustFromLeftSib(CurSize[m], *Node[n], CurSize[n],
363
21.4k
                                        CurSize[n] -  NewSize[n]);
364
21.4k
      CurSize[m] += d;
365
21.4k
      CurSize[n] -= d;
366
21.4k
      // Keep going if the current node was exhausted.
367
21.4k
      if (CurSize[n] >= NewSize[n])
368
21.4k
          break;
369
21.4k
    }
370
21.4k
  }
371
1.09M
372
1.09M
#ifndef NDEBUG
373
1.09M
  for (unsigned n = 0; n != Nodes; n++)
374
1.09M
    assert(CurSize[n] == NewSize[n] && "Insufficient element shuffle");
375
1.09M
#endif
376
1.09M
}
Unexecuted instantiation: void llvm::IntervalMapImpl::adjustSiblingSizes<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >**, unsigned int, unsigned int*, unsigned int const*)
Unexecuted instantiation: void llvm::IntervalMapImpl::adjustSiblingSizes<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >**, unsigned int, unsigned int*, unsigned int const*)
void llvm::IntervalMapImpl::adjustSiblingSizes<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >**, unsigned int, unsigned int*, unsigned int const*)
Line
Count
Source
338
1.04M
                        unsigned CurSize[], const unsigned NewSize[]) {
339
1.04M
  // Move elements right.
340
2.75M
  for (int n = Nodes - 1; n; 
--n1.71M
) {
341
1.71M
    if (CurSize[n] == NewSize[n])
342
155k
      continue;
343
1.55M
    for (int m = n - 1; m != -1; 
--m0
) {
344
1.55M
      int d = Node[n]->adjustFromLeftSib(CurSize[n], *Node[m], CurSize[m],
345
1.55M
                                         NewSize[n] - CurSize[n]);
346
1.55M
      CurSize[m] -= d;
347
1.55M
      CurSize[n] += d;
348
1.55M
      // Keep going if the current node was exhausted.
349
1.55M
      if (CurSize[n] >= NewSize[n])
350
1.55M
          break;
351
1.55M
    }
352
1.55M
  }
353
1.04M
354
1.04M
  if (Nodes == 0)
355
0
    return;
356
1.04M
357
1.04M
  // Move elements left.
358
2.75M
  
for (unsigned n = 0; 1.04M
n != Nodes - 1;
++n1.71M
) {
359
1.71M
    if (CurSize[n] == NewSize[n])
360
1.69M
      continue;
361
19.9k
    for (unsigned m = n + 1; m != Nodes; 
++m0
) {
362
19.9k
      int d = Node[m]->adjustFromLeftSib(CurSize[m], *Node[n], CurSize[n],
363
19.9k
                                        CurSize[n] -  NewSize[n]);
364
19.9k
      CurSize[m] += d;
365
19.9k
      CurSize[n] -= d;
366
19.9k
      // Keep going if the current node was exhausted.
367
19.9k
      if (CurSize[n] >= NewSize[n])
368
19.9k
          break;
369
19.9k
    }
370
19.9k
  }
371
1.04M
372
1.04M
#ifndef NDEBUG
373
1.04M
  for (unsigned n = 0; n != Nodes; n++)
374
1.04M
    assert(CurSize[n] == NewSize[n] && "Insufficient element shuffle");
375
1.04M
#endif
376
1.04M
}
void llvm::IntervalMapImpl::adjustSiblingSizes<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >**, unsigned int, unsigned int*, unsigned int const*)
Line
Count
Source
338
22.5k
                        unsigned CurSize[], const unsigned NewSize[]) {
339
22.5k
  // Move elements right.
340
53.0k
  for (int n = Nodes - 1; n; 
--n30.5k
) {
341
30.5k
    if (CurSize[n] == NewSize[n])
342
1.08k
      continue;
343
29.4k
    for (int m = n - 1; m != -1; 
--m0
) {
344
29.4k
      int d = Node[n]->adjustFromLeftSib(CurSize[n], *Node[m], CurSize[m],
345
29.4k
                                         NewSize[n] - CurSize[n]);
346
29.4k
      CurSize[m] -= d;
347
29.4k
      CurSize[n] += d;
348
29.4k
      // Keep going if the current node was exhausted.
349
29.4k
      if (CurSize[n] >= NewSize[n])
350
29.4k
          break;
351
29.4k
    }
352
29.4k
  }
353
22.5k
354
22.5k
  if (Nodes == 0)
355
0
    return;
356
22.5k
357
22.5k
  // Move elements left.
358
53.0k
  
for (unsigned n = 0; 22.5k
n != Nodes - 1;
++n30.5k
) {
359
30.5k
    if (CurSize[n] == NewSize[n])
360
30.1k
      continue;
361
376
    for (unsigned m = n + 1; m != Nodes; 
++m0
) {
362
376
      int d = Node[m]->adjustFromLeftSib(CurSize[m], *Node[n], CurSize[n],
363
376
                                        CurSize[n] -  NewSize[n]);
364
376
      CurSize[m] += d;
365
376
      CurSize[n] -= d;
366
376
      // Keep going if the current node was exhausted.
367
376
      if (CurSize[n] >= NewSize[n])
368
376
          break;
369
376
    }
370
376
  }
371
22.5k
372
22.5k
#ifndef NDEBUG
373
22.5k
  for (unsigned n = 0; n != Nodes; n++)
374
22.5k
    assert(CurSize[n] == NewSize[n] && "Insufficient element shuffle");
375
22.5k
#endif
376
22.5k
}
void llvm::IntervalMapImpl::adjustSiblingSizes<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >**, unsigned int, unsigned int*, unsigned int const*)
Line
Count
Source
338
25.2k
                        unsigned CurSize[], const unsigned NewSize[]) {
339
25.2k
  // Move elements right.
340
62.6k
  for (int n = Nodes - 1; n; 
--n37.4k
) {
341
37.4k
    if (CurSize[n] == NewSize[n])
342
3.25k
      continue;
343
34.1k
    for (int m = n - 1; m != -1; 
--m0
) {
344
34.1k
      int d = Node[n]->adjustFromLeftSib(CurSize[n], *Node[m], CurSize[m],
345
34.1k
                                         NewSize[n] - CurSize[n]);
346
34.1k
      CurSize[m] -= d;
347
34.1k
      CurSize[n] += d;
348
34.1k
      // Keep going if the current node was exhausted.
349
34.1k
      if (CurSize[n] >= NewSize[n])
350
34.1k
          break;
351
34.1k
    }
352
34.1k
  }
353
25.2k
354
25.2k
  if (Nodes == 0)
355
0
    return;
356
25.2k
357
25.2k
  // Move elements left.
358
62.6k
  
for (unsigned n = 0; 25.2k
n != Nodes - 1;
++n37.4k
) {
359
37.4k
    if (CurSize[n] == NewSize[n])
360
36.3k
      continue;
361
1.11k
    for (unsigned m = n + 1; m != Nodes; 
++m0
) {
362
1.11k
      int d = Node[m]->adjustFromLeftSib(CurSize[m], *Node[n], CurSize[n],
363
1.11k
                                        CurSize[n] -  NewSize[n]);
364
1.11k
      CurSize[m] += d;
365
1.11k
      CurSize[n] -= d;
366
1.11k
      // Keep going if the current node was exhausted.
367
1.11k
      if (CurSize[n] >= NewSize[n])
368
1.11k
          break;
369
1.11k
    }
370
1.11k
  }
371
25.2k
372
25.2k
#ifndef NDEBUG
373
25.2k
  for (unsigned n = 0; n != Nodes; n++)
374
25.2k
    assert(CurSize[n] == NewSize[n] && "Insufficient element shuffle");
375
25.2k
#endif
376
25.2k
}
void llvm::IntervalMapImpl::adjustSiblingSizes<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >**, unsigned int, unsigned int*, unsigned int const*)
Line
Count
Source
338
94
                        unsigned CurSize[], const unsigned NewSize[]) {
339
94
  // Move elements right.
340
202
  for (int n = Nodes - 1; n; 
--n108
) {
341
108
    if (CurSize[n] == NewSize[n])
342
0
      continue;
343
108
    for (int m = n - 1; m != -1; 
--m0
) {
344
108
      int d = Node[n]->adjustFromLeftSib(CurSize[n], *Node[m], CurSize[m],
345
108
                                         NewSize[n] - CurSize[n]);
346
108
      CurSize[m] -= d;
347
108
      CurSize[n] += d;
348
108
      // Keep going if the current node was exhausted.
349
108
      if (CurSize[n] >= NewSize[n])
350
108
          break;
351
108
    }
352
108
  }
353
94
354
94
  if (Nodes == 0)
355
0
    return;
356
94
357
94
  // Move elements left.
358
202
  
for (unsigned n = 0; 94
n != Nodes - 1;
++n108
) {
359
108
    if (CurSize[n] == NewSize[n])
360
106
      continue;
361
2
    for (unsigned m = n + 1; m != Nodes; 
++m0
) {
362
2
      int d = Node[m]->adjustFromLeftSib(CurSize[m], *Node[n], CurSize[n],
363
2
                                        CurSize[n] -  NewSize[n]);
364
2
      CurSize[m] += d;
365
2
      CurSize[n] -= d;
366
2
      // Keep going if the current node was exhausted.
367
2
      if (CurSize[n] >= NewSize[n])
368
2
          break;
369
2
    }
370
2
  }
371
94
372
94
#ifndef NDEBUG
373
94
  for (unsigned n = 0; n != Nodes; n++)
374
94
    assert(CurSize[n] == NewSize[n] && "Insufficient element shuffle");
375
94
#endif
376
94
}
377
378
/// IntervalMapImpl::distribute - Compute a new distribution of node elements
379
/// after an overflow or underflow. Reserve space for a new element at Position,
380
/// and compute the node that will hold Position after redistributing node
381
/// elements.
382
///
383
/// It is required that
384
///
385
///   Elements == sum(CurSize), and
386
///   Elements + Grow <= Nodes * Capacity.
387
///
388
/// NewSize[] will be filled in such that:
389
///
390
///   sum(NewSize) == Elements, and
391
///   NewSize[i] <= Capacity.
392
///
393
/// The returned index is the node where Position will go, so:
394
///
395
///   sum(NewSize[0..idx-1]) <= Position
396
///   sum(NewSize[0..idx])   >= Position
397
///
398
/// The last equality, sum(NewSize[0..idx]) == Position, can only happen when
399
/// Grow is set and NewSize[idx] == Capacity-1. The index points to the node
400
/// before the one holding the Position'th element where there is room for an
401
/// insertion.
402
///
403
/// @param Nodes    The number of nodes.
404
/// @param Elements Total elements in all nodes.
405
/// @param Capacity The capacity of each node.
406
/// @param CurSize  Array[Nodes] of current node sizes, or NULL.
407
/// @param NewSize  Array[Nodes] to receive the new node sizes.
408
/// @param Position Insert position.
409
/// @param Grow     Reserve space for a new element at Position.
410
/// @return         (node, offset) for Position.
411
IdxPair distribute(unsigned Nodes, unsigned Elements, unsigned Capacity,
412
                   const unsigned *CurSize, unsigned NewSize[],
413
                   unsigned Position, bool Grow);
414
415
//===----------------------------------------------------------------------===//
416
//---                   IntervalMapImpl::NodeSizer                         ---//
417
//===----------------------------------------------------------------------===//
418
//
419
// Compute node sizes from key and value types.
420
//
421
// The branching factors are chosen to make nodes fit in three cache lines.
422
// This may not be possible if keys or values are very large. Such large objects
423
// are handled correctly, but a std::map would probably give better performance.
424
//
425
//===----------------------------------------------------------------------===//
426
427
enum {
428
  // Cache line size. Most architectures have 32 or 64 byte cache lines.
429
  // We use 64 bytes here because it provides good branching factors.
430
  Log2CacheLine = 6,
431
  CacheLineBytes = 1 << Log2CacheLine,
432
  DesiredNodeBytes = 3 * CacheLineBytes
433
};
434
435
template <typename KeyT, typename ValT>
436
struct NodeSizer {
437
  enum {
438
    // Compute the leaf node branching factor that makes a node fit in three
439
    // cache lines. The branching factor must be at least 3, or some B+-tree
440
    // balancing algorithms won't work.
441
    // LeafSize can't be larger than CacheLineBytes. This is required by the
442
    // PointerIntPair used by NodeRef.
443
    DesiredLeafSize = DesiredNodeBytes /
444
      static_cast<unsigned>(2*sizeof(KeyT)+sizeof(ValT)),
445
    MinLeafSize = 3,
446
    LeafSize = DesiredLeafSize > MinLeafSize ? DesiredLeafSize : MinLeafSize
447
  };
448
449
  using LeafBase = NodeBase<std::pair<KeyT, KeyT>, ValT, LeafSize>;
450
451
  enum {
452
    // Now that we have the leaf branching factor, compute the actual allocation
453
    // unit size by rounding up to a whole number of cache lines.
454
    AllocBytes = (sizeof(LeafBase) + CacheLineBytes-1) & ~(CacheLineBytes-1),
455
456
    // Determine the branching factor for branch nodes.
457
    BranchSize = AllocBytes /
458
      static_cast<unsigned>(sizeof(KeyT) + sizeof(void*))
459
  };
460
461
  /// Allocator - The recycling allocator used for both branch and leaf nodes.
462
  /// This typedef is very likely to be identical for all IntervalMaps with
463
  /// reasonably sized entries, so the same allocator can be shared among
464
  /// different kinds of maps.
465
  using Allocator =
466
      RecyclingAllocator<BumpPtrAllocator, char, AllocBytes, CacheLineBytes>;
467
};
468
469
//===----------------------------------------------------------------------===//
470
//---                     IntervalMapImpl::NodeRef                         ---//
471
//===----------------------------------------------------------------------===//
472
//
473
// B+-tree nodes can be leaves or branches, so we need a polymorphic node
474
// pointer that can point to both kinds.
475
//
476
// All nodes are cache line aligned and the low 6 bits of a node pointer are
477
// always 0. These bits are used to store the number of elements in the
478
// referenced node. Besides saving space, placing node sizes in the parents
479
// allow tree balancing algorithms to run without faulting cache lines for nodes
480
// that may not need to be modified.
481
//
482
// A NodeRef doesn't know whether it references a leaf node or a branch node.
483
// It is the responsibility of the caller to use the correct types.
484
//
485
// Nodes are never supposed to be empty, and it is invalid to store a node size
486
// of 0 in a NodeRef. The valid range of sizes is 1-64.
487
//
488
//===----------------------------------------------------------------------===//
489
490
0
class NodeRef {
Unexecuted instantiation: llvm::IntervalMapImpl::NodeRef::operator=(llvm::IntervalMapImpl::NodeRef&&)
Unexecuted instantiation: llvm::IntervalMapImpl::NodeRef::operator=(llvm::IntervalMapImpl::NodeRef const&)
491
  struct CacheAlignedPointerTraits {
492
1.00M
    static inline void *getAsVoidPointer(void *P) { return P; }
493
77.2M
    static inline void *getFromVoidPointer(void *P) { return P; }
494
    enum { NumLowBitsAvailable = Log2CacheLine };
495
  };
496
  PointerIntPair<void*, Log2CacheLine, unsigned, CacheAlignedPointerTraits> pip;
497
498
public:
499
  /// NodeRef - Create a null ref.
500
5.14M
  NodeRef() = default;
501
502
  /// operator bool - Detect a null ref.
503
3.65M
  explicit operator bool() const { return pip.getOpaqueValue(); }
504
505
  /// NodeRef - Create a reference to the node p with n elements.
506
  template <typename NodeT>
507
1.00M
  NodeRef(NodeT *p, unsigned n) : pip(p, n - 1) {
508
1.00M
    assert(n <= NodeT::Capacity && "Size too big for node");
509
1.00M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::NodeRef::NodeRef<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >*, unsigned int)
llvm::IntervalMapImpl::NodeRef::NodeRef<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >*, unsigned int)
Line
Count
Source
507
5
  NodeRef(NodeT *p, unsigned n) : pip(p, n - 1) {
508
5
    assert(n <= NodeT::Capacity && "Size too big for node");
509
5
  }
llvm::IntervalMapImpl::NodeRef::NodeRef<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >*, unsigned int)
Line
Count
Source
507
16.1k
  NodeRef(NodeT *p, unsigned n) : pip(p, n - 1) {
508
16.1k
    assert(n <= NodeT::Capacity && "Size too big for node");
509
16.1k
  }
llvm::IntervalMapImpl::NodeRef::NodeRef<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >*, unsigned int)
Line
Count
Source
507
960k
  NodeRef(NodeT *p, unsigned n) : pip(p, n - 1) {
508
960k
    assert(n <= NodeT::Capacity && "Size too big for node");
509
960k
  }
llvm::IntervalMapImpl::NodeRef::NodeRef<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >*, unsigned int)
Line
Count
Source
507
112
  NodeRef(NodeT *p, unsigned n) : pip(p, n - 1) {
508
112
    assert(n <= NodeT::Capacity && "Size too big for node");
509
112
  }
llvm::IntervalMapImpl::NodeRef::NodeRef<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >*, unsigned int)
Line
Count
Source
507
31.6k
  NodeRef(NodeT *p, unsigned n) : pip(p, n - 1) {
508
31.6k
    assert(n <= NodeT::Capacity && "Size too big for node");
509
31.6k
  }
510
511
  /// size - Return the number of elements in the referenced node.
512
44.0M
  unsigned size() const { return pip.getInt() + 1; }
513
514
  /// setSize - Update the node size.
515
7.88M
  void setSize(unsigned n) { pip.setInt(n - 1); }
516
517
  /// subtree - Access the i'th subtree reference in a branch node.
518
  /// This depends on branch nodes storing the NodeRef array as their first
519
  /// member.
520
42.0M
  NodeRef &subtree(unsigned i) const {
521
42.0M
    return reinterpret_cast<NodeRef*>(pip.getPointer())[i];
522
42.0M
  }
523
524
  /// get - Dereference as a NodeT reference.
525
  template <typename NodeT>
526
35.1M
  NodeT &get() const {
527
35.1M
    return *reinterpret_cast<NodeT*>(pip.getPointer());
528
35.1M
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::NodeRef::get<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
526
2.65M
  NodeT &get() const {
527
2.65M
    return *reinterpret_cast<NodeT*>(pip.getPointer());
528
2.65M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::NodeRef::get<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
526
31.4M
  NodeT &get() const {
527
31.4M
    return *reinterpret_cast<NodeT*>(pip.getPointer());
528
31.4M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::NodeRef::get<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::NodeRef::get<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
526
65
  NodeT &get() const {
527
65
    return *reinterpret_cast<NodeT*>(pip.getPointer());
528
65
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::NodeRef::get<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
526
38.9k
  NodeT &get() const {
527
38.9k
    return *reinterpret_cast<NodeT*>(pip.getPointer());
528
38.9k
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::NodeRef::get<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
526
1.03M
  NodeT &get() const {
527
1.03M
    return *reinterpret_cast<NodeT*>(pip.getPointer());
528
1.03M
  }
529
530
0
  bool operator==(const NodeRef &RHS) const {
531
0
    if (pip == RHS.pip)
532
0
      return true;
533
0
    assert(pip.getPointer() != RHS.pip.getPointer() && "Inconsistent NodeRefs");
534
0
    return false;
535
0
  }
536
537
0
  bool operator!=(const NodeRef &RHS) const {
538
0
    return !operator==(RHS);
539
0
  }
540
};
541
542
//===----------------------------------------------------------------------===//
543
//---                      IntervalMapImpl::LeafNode                       ---//
544
//===----------------------------------------------------------------------===//
545
//
546
// Leaf nodes store up to N disjoint intervals with corresponding values.
547
//
548
// The intervals are kept sorted and fully coalesced so there are no adjacent
549
// intervals mapping to the same value.
550
//
551
// These constraints are always satisfied:
552
//
553
// - Traits::stopLess(start(i), stop(i))    - Non-empty, sane intervals.
554
//
555
// - Traits::stopLess(stop(i), start(i + 1) - Sorted.
556
//
557
// - value(i) != value(i + 1) || !Traits::adjacent(stop(i), start(i + 1))
558
//                                          - Fully coalesced.
559
//
560
//===----------------------------------------------------------------------===//
561
562
template <typename KeyT, typename ValT, unsigned N, typename Traits>
563
class LeafNode : public NodeBase<std::pair<KeyT, KeyT>, ValT, N> {
564
public:
565
2.08M
  const KeyT &start(unsigned i) const { return this->first[i].first; }
Unexecuted instantiation: llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::start(unsigned int) const
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::start(unsigned int) const
Line
Count
Source
565
2.08M
  const KeyT &start(unsigned i) const { return this->first[i].first; }
566
340M
  const KeyT &stop(unsigned i) const { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
566
330M
  const KeyT &stop(unsigned i) const { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
566
187
  const KeyT &stop(unsigned i) const { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
566
2.40k
  const KeyT &stop(unsigned i) const { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
566
10.2M
  const KeyT &stop(unsigned i) const { return this->first[i].second; }
567
912k
  const ValT &value(unsigned i) const { return this->second[i]; }
568
569
305M
  KeyT &start(unsigned i) { return this->first[i].first; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::start(unsigned int)
Line
Count
Source
569
301M
  KeyT &start(unsigned i) { return this->first[i].first; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::start(unsigned int)
Line
Count
Source
569
202
  KeyT &start(unsigned i) { return this->first[i].first; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::start(unsigned int)
Line
Count
Source
569
5.50k
  KeyT &start(unsigned i) { return this->first[i].first; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::start(unsigned int)
Line
Count
Source
569
3.72M
  KeyT &start(unsigned i) { return this->first[i].first; }
570
266M
  KeyT &stop(unsigned i) { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
570
261M
  KeyT &stop(unsigned i) { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
570
146
  KeyT &stop(unsigned i) { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
570
3.46k
  KeyT &stop(unsigned i) { return this->first[i].second; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
570
4.85M
  KeyT &stop(unsigned i) { return this->first[i].second; }
571
187M
  ValT &value(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::value(unsigned int)
Line
Count
Source
571
261
  ValT &value(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::value(unsigned int)
Line
Count
Source
571
6.33k
  ValT &value(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::value(unsigned int)
Line
Count
Source
571
182M
  ValT &value(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::value(unsigned int)
Line
Count
Source
571
4.70M
  ValT &value(unsigned i) { return this->second[i]; }
572
573
  /// findFrom - Find the first interval after i that may contain x.
574
  /// @param i    Starting index for the search.
575
  /// @param Size Number of elements in node.
576
  /// @param x    Key to search for.
577
  /// @return     First index with !stopLess(key[i].stop, x), or size.
578
  ///             This is the first interval that can possibly contain x.
579
130M
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
580
130M
    assert(i <= Size && Size <= N && "Bad indices");
581
130M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
582
130M
           "Index is past the needed point");
583
206M
    while (i != Size && 
Traits::stopLess(stop(i), x)193M
)
++i76.3M
;
584
130M
    return i;
585
130M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::findFrom(unsigned int, unsigned int, llvm::SlotIndex) const
Line
Count
Source
579
128M
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
580
128M
    assert(i <= Size && Size <= N && "Bad indices");
581
128M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
582
128M
           "Index is past the needed point");
583
201M
    while (i != Size && 
Traits::stopLess(stop(i), x)188M
)
++i72.9M
;
584
128M
    return i;
585
128M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::findFrom(unsigned int, unsigned int, llvm::SlotIndex) const
Line
Count
Source
579
2.36k
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
580
2.36k
    assert(i <= Size && Size <= N && "Bad indices");
581
2.36k
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
582
2.36k
           "Index is past the needed point");
583
3.67k
    while (i != Size && 
Traits::stopLess(stop(i), x)2.40k
)
++i1.30k
;
584
2.36k
    return i;
585
2.36k
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::findFrom(unsigned int, unsigned int, llvm::SlotIndex) const
Line
Count
Source
579
1.68M
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
580
1.68M
    assert(i <= Size && Size <= N && "Bad indices");
581
1.68M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
582
1.68M
           "Index is past the needed point");
583
5.09M
    while (i != Size && 
Traits::stopLess(stop(i), x)4.63M
)
++i3.41M
;
584
1.68M
    return i;
585
1.68M
  }
586
587
  /// safeFind - Find an interval that is known to exist. This is the same as
588
  /// findFrom except is it assumed that x is at least within range of the last
589
  /// interval.
590
  /// @param i Starting index for the search.
591
  /// @param x Key to search for.
592
  /// @return  First index with !stopLess(key[i].stop, x), never size.
593
  ///          This is the first interval that can possibly contain x.
594
37.6M
  unsigned safeFind(unsigned i, KeyT x) const {
595
37.6M
    assert(i < N && "Bad index");
596
37.6M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
597
37.6M
           "Index is past the needed point");
598
146M
    while (Traits::stopLess(stop(i), x)) 
++i108M
;
599
37.6M
    assert(i < N && "Unsafe intervals");
600
37.6M
    return i;
601
37.6M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
Line
Count
Source
594
35.8M
  unsigned safeFind(unsigned i, KeyT x) const {
595
35.8M
    assert(i < N && "Bad index");
596
35.8M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
597
35.8M
           "Index is past the needed point");
598
141M
    while (Traits::stopLess(stop(i), x)) 
++i105M
;
599
35.8M
    assert(i < N && "Unsafe intervals");
600
35.8M
    return i;
601
35.8M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
Line
Count
Source
594
54
  unsigned safeFind(unsigned i, KeyT x) const {
595
54
    assert(i < N && "Bad index");
596
54
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
597
54
           "Index is past the needed point");
598
187
    while (Traits::stopLess(stop(i), x)) 
++i133
;
599
54
    assert(i < N && "Unsafe intervals");
600
54
    return i;
601
54
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
Line
Count
Source
594
1.75M
  unsigned safeFind(unsigned i, KeyT x) const {
595
1.75M
    assert(i < N && "Bad index");
596
1.75M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
597
1.75M
           "Index is past the needed point");
598
4.73M
    while (Traits::stopLess(stop(i), x)) 
++i2.98M
;
599
1.75M
    assert(i < N && "Unsafe intervals");
600
1.75M
    return i;
601
1.75M
  }
602
603
  /// safeLookup - Lookup mapped value for a safe key.
604
  /// It is assumed that x is within range of the last entry.
605
  /// @param x        Key to search for.
606
  /// @param NotFound Value to return if x is not in any interval.
607
  /// @return         The mapped value at x or NotFound.
608
1.06M
  ValT safeLookup(KeyT x, ValT NotFound) const {
609
1.06M
    unsigned i = safeFind(0, x);
610
1.06M
    return Traits::startLess(x, start(i)) ? 
NotFound148k
:
value(i)912k
;
611
1.06M
  }
612
613
  unsigned insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y);
614
};
615
616
/// insertFrom - Add mapping of [a;b] to y if possible, coalescing as much as
617
/// possible. This may cause the node to grow by 1, or it may cause the node
618
/// to shrink because of coalescing.
619
/// @param Pos  Starting index = insertFrom(0, size, a)
620
/// @param Size Number of elements in node.
621
/// @param a    Interval start.
622
/// @param b    Interval stop.
623
/// @param y    Value be mapped.
624
/// @return     (insert position, new size), or (i, Capacity+1) on overflow.
625
template <typename KeyT, typename ValT, unsigned N, typename Traits>
626
unsigned LeafNode<KeyT, ValT, N, Traits>::
627
18.2M
insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y) {
628
18.2M
  unsigned i = Pos;
629
18.2M
  assert(i <= Size && Size <= N && "Invalid index");
630
18.2M
  assert(!Traits::stopLess(b, a) && "Invalid interval");
631
18.2M
632
18.2M
  // Verify the findFrom invariant.
633
18.2M
  assert((i == 0 || Traits::stopLess(stop(i - 1), a)));
634
18.2M
  assert((i == Size || !Traits::stopLess(stop(i), a)));
635
18.2M
  assert((i == Size || Traits::stopLess(b, start(i))) && "Overlapping insert");
636
18.2M
637
18.2M
  // Coalesce with previous interval.
638
18.2M
  if (i && 
value(i - 1) == y12.6M
&&
Traits::adjacent(stop(i - 1), a)6.03M
) {
639
2.42M
    Pos = i - 1;
640
2.42M
    // Also coalesce with next interval?
641
2.42M
    if (i != Size && 
value(i) == y2.33M
&&
Traits::adjacent(b, start(i))1.62M
) {
642
489k
      stop(i - 1) = stop(i);
643
489k
      this->erase(i, Size);
644
489k
      return Size - 1;
645
489k
    }
646
1.93M
    stop(i - 1) = b;
647
1.93M
    return Size;
648
1.93M
  }
649
15.8M
650
15.8M
  // Detect overflow.
651
15.8M
  if (i == N)
652
333k
    return N + 1;
653
15.5M
654
15.5M
  // Add new interval at end.
655
15.5M
  if (i == Size) {
656
6.74M
    start(i) = a;
657
6.74M
    stop(i) = b;
658
6.74M
    value(i) = y;
659
6.74M
    return Size + 1;
660
6.74M
  }
661
8.78M
662
8.78M
  // Try to coalesce with following interval.
663
8.78M
  if (value(i) == y && 
Traits::adjacent(b, start(i))4.20M
) {
664
597k
    start(i) = a;
665
597k
    return Size;
666
597k
  }
667
8.19M
668
8.19M
  // We must insert before i. Detect overflow.
669
8.19M
  if (Size == N)
670
1.05M
    return N + 1;
671
7.13M
672
7.13M
  // Insert before i.
673
7.13M
  this->shift(i, Size);
674
7.13M
  start(i) = a;
675
7.13M
  stop(i) = b;
676
7.13M
  value(i) = y;
677
7.13M
  return Size + 1;
678
7.13M
}
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insertFrom(unsigned int&, unsigned int, llvm::SlotIndex, llvm::SlotIndex, DbgValueLocation)
Line
Count
Source
627
39
insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y) {
628
39
  unsigned i = Pos;
629
39
  assert(i <= Size && Size <= N && "Invalid index");
630
39
  assert(!Traits::stopLess(b, a) && "Invalid interval");
631
39
632
39
  // Verify the findFrom invariant.
633
39
  assert((i == 0 || Traits::stopLess(stop(i - 1), a)));
634
39
  assert((i == Size || !Traits::stopLess(stop(i), a)));
635
39
  assert((i == Size || Traits::stopLess(b, start(i))) && "Overlapping insert");
636
39
637
39
  // Coalesce with previous interval.
638
39
  if (i && value(i - 1) == y && 
Traits::adjacent(stop(i - 1), a)32
) {
639
27
    Pos = i - 1;
640
27
    // Also coalesce with next interval?
641
27
    if (i != Size && 
value(i) == y21
&&
Traits::adjacent(b, start(i))15
) {
642
3
      stop(i - 1) = stop(i);
643
3
      this->erase(i, Size);
644
3
      return Size - 1;
645
3
    }
646
24
    stop(i - 1) = b;
647
24
    return Size;
648
24
  }
649
12
650
12
  // Detect overflow.
651
12
  if (i == N)
652
0
    return N + 1;
653
12
654
12
  // Add new interval at end.
655
12
  if (i == Size) {
656
10
    start(i) = a;
657
10
    stop(i) = b;
658
10
    value(i) = y;
659
10
    return Size + 1;
660
10
  }
661
2
662
2
  // Try to coalesce with following interval.
663
2
  if (value(i) == y && Traits::adjacent(b, start(i))) {
664
0
    start(i) = a;
665
0
    return Size;
666
0
  }
667
2
668
2
  // We must insert before i. Detect overflow.
669
2
  if (Size == N)
670
0
    return N + 1;
671
2
672
2
  // Insert before i.
673
2
  this->shift(i, Size);
674
2
  start(i) = a;
675
2
  stop(i) = b;
676
2
  value(i) = y;
677
2
  return Size + 1;
678
2
}
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insertFrom(unsigned int&, unsigned int, llvm::SlotIndex, llvm::SlotIndex, DbgValueLocation)
Line
Count
Source
627
1.34k
insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y) {
628
1.34k
  unsigned i = Pos;
629
1.34k
  assert(i <= Size && Size <= N && "Invalid index");
630
1.34k
  assert(!Traits::stopLess(b, a) && "Invalid interval");
631
1.34k
632
1.34k
  // Verify the findFrom invariant.
633
1.34k
  assert((i == 0 || Traits::stopLess(stop(i - 1), a)));
634
1.34k
  assert((i == Size || !Traits::stopLess(stop(i), a)));
635
1.34k
  assert((i == Size || Traits::stopLess(b, start(i))) && "Overlapping insert");
636
1.34k
637
1.34k
  // Coalesce with previous interval.
638
1.34k
  if (i && 
value(i - 1) == y805
&&
Traits::adjacent(stop(i - 1), a)559
) {
639
527
    Pos = i - 1;
640
527
    // Also coalesce with next interval?
641
527
    if (i != Size && 
value(i) == y84
&&
Traits::adjacent(b, start(i))17
) {
642
4
      stop(i - 1) = stop(i);
643
4
      this->erase(i, Size);
644
4
      return Size - 1;
645
4
    }
646
523
    stop(i - 1) = b;
647
523
    return Size;
648
523
  }
649
820
650
820
  // Detect overflow.
651
820
  if (i == N)
652
5
    return N + 1;
653
815
654
815
  // Add new interval at end.
655
815
  if (i == Size) {
656
806
    start(i) = a;
657
806
    stop(i) = b;
658
806
    value(i) = y;
659
806
    return Size + 1;
660
806
  }
661
9
662
9
  // Try to coalesce with following interval.
663
9
  if (value(i) == y && 
Traits::adjacent(b, start(i))0
) {
664
0
    start(i) = a;
665
0
    return Size;
666
0
  }
667
9
668
9
  // We must insert before i. Detect overflow.
669
9
  if (Size == N)
670
0
    return N + 1;
671
9
672
9
  // Insert before i.
673
9
  this->shift(i, Size);
674
9
  start(i) = a;
675
9
  stop(i) = b;
676
9
  value(i) = y;
677
9
  return Size + 1;
678
9
}
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insertFrom(unsigned int&, unsigned int, llvm::SlotIndex, llvm::SlotIndex, llvm::LiveInterval*)
Line
Count
Source
627
16.3M
insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y) {
628
16.3M
  unsigned i = Pos;
629
16.3M
  assert(i <= Size && Size <= N && "Invalid index");
630
16.3M
  assert(!Traits::stopLess(b, a) && "Invalid interval");
631
16.3M
632
16.3M
  // Verify the findFrom invariant.
633
16.3M
  assert((i == 0 || Traits::stopLess(stop(i - 1), a)));
634
16.3M
  assert((i == Size || !Traits::stopLess(stop(i), a)));
635
16.3M
  assert((i == Size || Traits::stopLess(b, start(i))) && "Overlapping insert");
636
16.3M
637
16.3M
  // Coalesce with previous interval.
638
16.3M
  if (i && 
value(i - 1) == y10.8M
&&
Traits::adjacent(stop(i - 1), a)4.32M
) {
639
1.46M
    Pos = i - 1;
640
1.46M
    // Also coalesce with next interval?
641
1.46M
    if (i != Size && value(i) == y && 
Traits::adjacent(b, start(i))781k
) {
642
207k
      stop(i - 1) = stop(i);
643
207k
      this->erase(i, Size);
644
207k
      return Size - 1;
645
207k
    }
646
1.25M
    stop(i - 1) = b;
647
1.25M
    return Size;
648
1.25M
  }
649
14.8M
650
14.8M
  // Detect overflow.
651
14.8M
  if (i == N)
652
321k
    return N + 1;
653
14.5M
654
14.5M
  // Add new interval at end.
655
14.5M
  if (i == Size) {
656
6.33M
    start(i) = a;
657
6.33M
    stop(i) = b;
658
6.33M
    value(i) = y;
659
6.33M
    return Size + 1;
660
6.33M
  }
661
8.18M
662
8.18M
  // Try to coalesce with following interval.
663
8.18M
  if (value(i) == y && 
Traits::adjacent(b, start(i))3.61M
) {
664
385k
    start(i) = a;
665
385k
    return Size;
666
385k
  }
667
7.79M
668
7.79M
  // We must insert before i. Detect overflow.
669
7.79M
  if (Size == N)
670
1.02M
    return N + 1;
671
6.77M
672
6.77M
  // Insert before i.
673
6.77M
  this->shift(i, Size);
674
6.77M
  start(i) = a;
675
6.77M
  stop(i) = b;
676
6.77M
  value(i) = y;
677
6.77M
  return Size + 1;
678
6.77M
}
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insertFrom(unsigned int&, unsigned int, llvm::SlotIndex, llvm::SlotIndex, unsigned int)
Line
Count
Source
627
1.98M
insertFrom(unsigned &Pos, unsigned Size, KeyT a, KeyT b, ValT y) {
628
1.98M
  unsigned i = Pos;
629
1.98M
  assert(i <= Size && Size <= N && "Invalid index");
630
1.98M
  assert(!Traits::stopLess(b, a) && "Invalid interval");
631
1.98M
632
1.98M
  // Verify the findFrom invariant.
633
1.98M
  assert((i == 0 || Traits::stopLess(stop(i - 1), a)));
634
1.98M
  assert((i == Size || !Traits::stopLess(stop(i), a)));
635
1.98M
  assert((i == Size || Traits::stopLess(b, start(i))) && "Overlapping insert");
636
1.98M
637
1.98M
  // Coalesce with previous interval.
638
1.98M
  if (i && 
value(i - 1) == y1.78M
&&
Traits::adjacent(stop(i - 1), a)1.70M
) {
639
958k
    Pos = i - 1;
640
958k
    // Also coalesce with next interval?
641
958k
    if (i != Size && 
value(i) == y869k
&&
Traits::adjacent(b, start(i))846k
) {
642
282k
      stop(i - 1) = stop(i);
643
282k
      this->erase(i, Size);
644
282k
      return Size - 1;
645
282k
    }
646
676k
    stop(i - 1) = b;
647
676k
    return Size;
648
676k
  }
649
1.02M
650
1.02M
  // Detect overflow.
651
1.02M
  if (i == N)
652
12.0k
    return N + 1;
653
1.00M
654
1.00M
  // Add new interval at end.
655
1.00M
  if (i == Size) {
656
404k
    start(i) = a;
657
404k
    stop(i) = b;
658
404k
    value(i) = y;
659
404k
    return Size + 1;
660
404k
  }
661
605k
662
605k
  // Try to coalesce with following interval.
663
605k
  if (value(i) == y && 
Traits::adjacent(b, start(i))583k
) {
664
212k
    start(i) = a;
665
212k
    return Size;
666
212k
  }
667
393k
668
393k
  // We must insert before i. Detect overflow.
669
393k
  if (Size == N)
670
25.9k
    return N + 1;
671
367k
672
367k
  // Insert before i.
673
367k
  this->shift(i, Size);
674
367k
  start(i) = a;
675
367k
  stop(i) = b;
676
367k
  value(i) = y;
677
367k
  return Size + 1;
678
367k
}
679
680
//===----------------------------------------------------------------------===//
681
//---                   IntervalMapImpl::BranchNode                        ---//
682
//===----------------------------------------------------------------------===//
683
//
684
// A branch node stores references to 1--N subtrees all of the same height.
685
//
686
// The key array in a branch node holds the rightmost stop key of each subtree.
687
// It is redundant to store the last stop key since it can be found in the
688
// parent node, but doing so makes tree balancing a lot simpler.
689
//
690
// It is unusual for a branch node to only have one subtree, but it can happen
691
// in the root node if it is smaller than the normal nodes.
692
//
693
// When all of the leaf nodes from all the subtrees are concatenated, they must
694
// satisfy the same constraints as a single leaf node. They must be sorted,
695
// sane, and fully coalesced.
696
//
697
//===----------------------------------------------------------------------===//
698
699
template <typename KeyT, typename ValT, unsigned N, typename Traits>
700
class BranchNode : public NodeBase<NodeRef, KeyT, N> {
701
public:
702
89.7M
  const KeyT &stop(unsigned i) const { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
702
71.7M
  const KeyT &stop(unsigned i) const { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
702
15.6M
  const KeyT &stop(unsigned i) const { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
702
59
  const KeyT &stop(unsigned i) const { return this->second[i]; }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
702
2.16M
  const KeyT &stop(unsigned i) const { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int) const
Line
Count
Source
702
187k
  const KeyT &stop(unsigned i) const { return this->second[i]; }
703
277k
  const NodeRef &subtree(unsigned i) const { return this->first[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int) const
Line
Count
Source
703
267k
  const NodeRef &subtree(unsigned i) const { return this->first[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int) const
Line
Count
Source
703
9.99k
  const NodeRef &subtree(unsigned i) const { return this->first[i]; }
704
705
5.59M
  KeyT &stop(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
705
982k
  KeyT &stop(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
705
4.43M
  KeyT &stop(unsigned i) { return this->second[i]; }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
705
21
  KeyT &stop(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
705
9.38k
  KeyT &stop(unsigned i) { return this->second[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::stop(unsigned int)
Line
Count
Source
705
164k
  KeyT &stop(unsigned i) { return this->second[i]; }
706
1.83M
  NodeRef &subtree(unsigned i) { return this->first[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int)
Line
Count
Source
706
10
  NodeRef &subtree(unsigned i) { return this->first[i]; }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int)
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int)
Line
Count
Source
706
1.68M
  NodeRef &subtree(unsigned i) { return this->first[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int)
Line
Count
Source
706
82.8k
  NodeRef &subtree(unsigned i) { return this->first[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int)
Line
Count
Source
706
60.9k
  NodeRef &subtree(unsigned i) { return this->first[i]; }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::subtree(unsigned int)
Line
Count
Source
706
413
  NodeRef &subtree(unsigned i) { return this->first[i]; }
707
708
  /// findFrom - Find the first subtree after i that may contain x.
709
  /// @param i    Starting index for the search.
710
  /// @param Size Number of elements in node.
711
  /// @param x    Key to search for.
712
  /// @return     First index with !stopLess(key[i], x), or size.
713
  ///             This is the first subtree that can possibly contain x.
714
30.6M
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
715
30.6M
    assert(i <= Size && Size <= N && "Bad indices");
716
30.6M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
717
30.6M
           "Index to findFrom is past the needed point");
718
75.4M
    while (i != Size && 
Traits::stopLess(stop(i), x)73.1M
)
++i44.8M
;
719
30.6M
    return i;
720
30.6M
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::findFrom(unsigned int, unsigned int, llvm::SlotIndex) const
Line
Count
Source
714
30.0M
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
715
30.0M
    assert(i <= Size && Size <= N && "Bad indices");
716
30.0M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
717
30.0M
           "Index to findFrom is past the needed point");
718
74.0M
    while (i != Size && 
Traits::stopLess(stop(i), x)71.7M
)
++i44.0M
;
719
30.0M
    return i;
720
30.0M
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::findFrom(unsigned int, unsigned int, llvm::SlotIndex) const
Line
Count
Source
714
59
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
715
59
    assert(i <= Size && Size <= N && "Bad indices");
716
59
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
717
59
           "Index to findFrom is past the needed point");
718
68
    while (i != Size && 
Traits::stopLess(stop(i), x)59
)
++i9
;
719
59
    return i;
720
59
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::findFrom(unsigned int, unsigned int, llvm::SlotIndex) const
Line
Count
Source
714
629k
  unsigned findFrom(unsigned i, unsigned Size, KeyT x) const {
715
629k
    assert(i <= Size && Size <= N && "Bad indices");
716
629k
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
717
629k
           "Index to findFrom is past the needed point");
718
1.42M
    while (i != Size && 
Traits::stopLess(stop(i), x)1.38M
)
++i790k
;
719
629k
    return i;
720
629k
  }
721
722
  /// safeFind - Find a subtree that is known to exist. This is the same as
723
  /// findFrom except is it assumed that x is in range.
724
  /// @param i Starting index for the search.
725
  /// @param x Key to search for.
726
  /// @return  First index with !stopLess(key[i], x), never size.
727
  ///          This is the first subtree that can possibly contain x.
728
3.26M
  unsigned safeFind(unsigned i, KeyT x) const {
729
3.26M
    assert(i < N && "Bad index");
730
3.26M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
731
3.26M
           "Index is past the needed point");
732
16.2M
    while (Traits::stopLess(stop(i), x)) 
++i13.0M
;
733
3.26M
    assert(i < N && "Unsafe intervals");
734
3.26M
    return i;
735
3.26M
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
Line
Count
Source
728
2.96M
  unsigned safeFind(unsigned i, KeyT x) const {
729
2.96M
    assert(i < N && "Bad index");
730
2.96M
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
731
2.96M
           "Index is past the needed point");
732
15.6M
    while (Traits::stopLess(stop(i), x)) 
++i12.6M
;
733
2.96M
    assert(i < N && "Unsafe intervals");
734
2.96M
    return i;
735
2.96M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
Line
Count
Source
728
38.9k
  unsigned safeFind(unsigned i, KeyT x) const {
729
38.9k
    assert(i < N && "Bad index");
730
38.9k
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
731
38.9k
           "Index is past the needed point");
732
187k
    while (Traits::stopLess(stop(i), x)) 
++i148k
;
733
38.9k
    assert(i < N && "Unsafe intervals");
734
38.9k
    return i;
735
38.9k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeFind(unsigned int, llvm::SlotIndex) const
Line
Count
Source
728
267k
  unsigned safeFind(unsigned i, KeyT x) const {
729
267k
    assert(i < N && "Bad index");
730
267k
    assert((i == 0 || Traits::stopLess(stop(i - 1), x)) &&
731
267k
           "Index is past the needed point");
732
508k
    while (Traits::stopLess(stop(i), x)) 
++i241k
;
733
267k
    assert(i < N && "Unsafe intervals");
734
267k
    return i;
735
267k
  }
736
737
  /// safeLookup - Get the subtree containing x, Assuming that x is in range.
738
  /// @param x Key to search for.
739
  /// @return  Subtree containing x
740
277k
  NodeRef safeLookup(KeyT x) const {
741
277k
    return subtree(safeFind(0, x));
742
277k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeLookup(llvm::SlotIndex) const
Line
Count
Source
740
267k
  NodeRef safeLookup(KeyT x) const {
741
267k
    return subtree(safeFind(0, x));
742
267k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::safeLookup(llvm::SlotIndex) const
Line
Count
Source
740
9.99k
  NodeRef safeLookup(KeyT x) const {
741
9.99k
    return subtree(safeFind(0, x));
742
9.99k
  }
743
744
  /// insert - Insert a new (subtree, stop) pair.
745
  /// @param i    Insert position, following entries will be shifted.
746
  /// @param Size Number of elements in node.
747
  /// @param Node Subtree to insert.
748
  /// @param Stop Last key in subtree.
749
376k
  void insert(unsigned i, unsigned Size, NodeRef Node, KeyT Stop) {
750
376k
    assert(Size < N && "branch node overflow");
751
376k
    assert(i <= Size && "Bad insert position");
752
376k
    this->shift(i, Size);
753
376k
    subtree(i) = Node;
754
376k
    stop(i) = Stop;
755
376k
  }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insert(unsigned int, unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insert(unsigned int, unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insert(unsigned int, unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Line
Count
Source
749
287k
  void insert(unsigned i, unsigned Size, NodeRef Node, KeyT Stop) {
750
287k
    assert(Size < N && "branch node overflow");
751
287k
    assert(i <= Size && "Bad insert position");
752
287k
    this->shift(i, Size);
753
287k
    subtree(i) = Node;
754
287k
    stop(i) = Stop;
755
287k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insert(unsigned int, unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Line
Count
Source
749
82.8k
  void insert(unsigned i, unsigned Size, NodeRef Node, KeyT Stop) {
750
82.8k
    assert(Size < N && "branch node overflow");
751
82.8k
    assert(i <= Size && "Bad insert position");
752
82.8k
    this->shift(i, Size);
753
82.8k
    subtree(i) = Node;
754
82.8k
    stop(i) = Stop;
755
82.8k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insert(unsigned int, unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Line
Count
Source
749
5.67k
  void insert(unsigned i, unsigned Size, NodeRef Node, KeyT Stop) {
750
5.67k
    assert(Size < N && "branch node overflow");
751
5.67k
    assert(i <= Size && "Bad insert position");
752
5.67k
    this->shift(i, Size);
753
5.67k
    subtree(i) = Node;
754
5.67k
    stop(i) = Stop;
755
5.67k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >::insert(unsigned int, unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Line
Count
Source
749
413
  void insert(unsigned i, unsigned Size, NodeRef Node, KeyT Stop) {
750
413
    assert(Size < N && "branch node overflow");
751
413
    assert(i <= Size && "Bad insert position");
752
413
    this->shift(i, Size);
753
413
    subtree(i) = Node;
754
413
    stop(i) = Stop;
755
413
  }
756
};
757
758
//===----------------------------------------------------------------------===//
759
//---                         IntervalMapImpl::Path                        ---//
760
//===----------------------------------------------------------------------===//
761
//
762
// A Path is used by iterators to represent a position in a B+-tree, and the
763
// path to get there from the root.
764
//
765
// The Path class also contains the tree navigation code that doesn't have to
766
// be templatized.
767
//
768
//===----------------------------------------------------------------------===//
769
770
class Path {
771
  /// Entry - Each step in the path is a node pointer and an offset into that
772
  /// node.
773
0
  struct Entry {
774
    void *node;
775
    unsigned size;
776
    unsigned offset;
777
778
    Entry(void *Node, unsigned Size, unsigned Offset)
779
151M
      : node(Node), size(Size), offset(Offset) {}
780
781
    Entry(NodeRef Node, unsigned Offset)
782
38.9M
      : node(&Node.subtree(0)), size(Node.size()), offset(Offset) {}
783
784
45.5M
    NodeRef &subtree(unsigned i) const {
785
45.5M
      return reinterpret_cast<NodeRef*>(node)[i];
786
45.5M
    }
787
  };
788
789
  /// path - The path entries, path[0] is the root node, path.back() is a leaf.
790
  SmallVector<Entry, 4> path;
791
792
public:
793
  // Node accessors.
794
5.61M
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
5.61M
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
5.61M
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
1.29M
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
1.29M
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
1.29M
  }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
16
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
16
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
16
  }
Unexecuted instantiation: llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
3.09M
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
3.09M
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
3.09M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
1.04M
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
1.04M
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
1.04M
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
9.62k
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
9.62k
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
9.62k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 11u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
132k
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
132k
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
132k
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::node<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int) const
Line
Count
Source
794
25.2k
  template <typename NodeT> NodeT &node(unsigned Level) const {
795
25.2k
    return *reinterpret_cast<NodeT*>(path[Level].node);
796
25.2k
  }
797
1.35M
  unsigned size(unsigned Level) const { return path[Level].size; }
798
0
  unsigned offset(unsigned Level) const { return path[Level].offset; }
799
10.2M
  unsigned &offset(unsigned Level) { return path[Level].offset; }
800
801
  // Leaf accessors.
802
687M
  template <typename NodeT> NodeT &leaf() const {
803
687M
    return *reinterpret_cast<NodeT*>(path.back().node);
804
687M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::leaf<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
802
684M
  template <typename NodeT> NodeT &leaf() const {
803
684M
    return *reinterpret_cast<NodeT*>(path.back().node);
804
684M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::leaf<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
802
465
  template <typename NodeT> NodeT &leaf() const {
803
465
    return *reinterpret_cast<NodeT*>(path.back().node);
804
465
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::leaf<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
802
10.8k
  template <typename NodeT> NodeT &leaf() const {
803
10.8k
    return *reinterpret_cast<NodeT*>(path.back().node);
804
10.8k
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMapImpl::Path::leaf<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
802
3.44M
  template <typename NodeT> NodeT &leaf() const {
803
3.44M
    return *reinterpret_cast<NodeT*>(path.back().node);
804
3.44M
  }
805
54.9M
  unsigned leafSize() const { return path.back().size; }
806
662M
  unsigned leafOffset() const { return path.back().offset; }
807
109M
  unsigned &leafOffset() { return path.back().offset; }
808
809
  /// valid - Return true if path is at a valid node, not at end().
810
382M
  bool valid() const {
811
382M
    return 
!path.empty()382M
&& path.front().offset < path.front().size;
812
382M
  }
813
814
  /// height - Return the height of the tree corresponding to this path.
815
  /// This matches map->height in a full path.
816
68.8M
  unsigned height() const { return path.size() - 1; }
817
818
  /// subtree - Get the subtree referenced from Level. When the path is
819
  /// consistent, node(Level + 1) == subtree(Level).
820
  /// @param Level 0..height-1. The leaves have no subtrees.
821
43.8M
  NodeRef &subtree(unsigned Level) const {
822
43.8M
    return path[Level].subtree(path[Level].offset);
823
43.8M
  }
824
825
  /// reset - Reset cached information about node(Level) from subtree(Level -1).
826
  /// @param Level 1..height. THe node to update after parent node changed.
827
398k
  void reset(unsigned Level) {
828
398k
    path[Level] = Entry(subtree(Level - 1), offset(Level));
829
398k
  }
830
831
  /// push - Add entry to path.
832
  /// @param Node Node to add, should be subtree(path.size()-1).
833
  /// @param Offset Offset into Node.
834
31.3M
  void push(NodeRef Node, unsigned Offset) {
835
31.3M
    path.push_back(Entry(Node, Offset));
836
31.3M
  }
837
838
  /// pop - Remove the last path entry.
839
2.36M
  void pop() {
840
2.36M
    path.pop_back();
841
2.36M
  }
842
843
  /// setSize - Set the size of a node both in the path and in the tree.
844
  /// @param Level 0..height. Note that setting the root size won't change
845
  ///              map->rootSize.
846
  /// @param Size New node size.
847
19.8M
  void setSize(unsigned Level, unsigned Size) {
848
19.8M
    path[Level].size = Size;
849
19.8M
    if (Level)
850
7.88M
      subtree(Level - 1).setSize(Size);
851
19.8M
  }
852
853
  /// setRoot - Clear the path and set a new root node.
854
  /// @param Node New root node.
855
  /// @param Size New root size.
856
  /// @param Offset Offset into root node.
857
150M
  void setRoot(void *Node, unsigned Size, unsigned Offset) {
858
150M
    path.clear();
859
150M
    path.push_back(Entry(Node, Size, Offset));
860
150M
  }
861
862
  /// replaceRoot - Replace the current root node with two new entries after the
863
  /// tree height has increased.
864
  /// @param Root The new root node.
865
  /// @param Size Number of entries in the new root.
866
  /// @param Offsets Offsets into the root and first branch nodes.
867
  void replaceRoot(void *Root, unsigned Size, IdxPair Offsets);
868
869
  /// getLeftSibling - Get the left sibling node at Level, or a null NodeRef.
870
  /// @param Level Get the sibling to node(Level).
871
  /// @return Left sibling, or NodeRef().
872
  NodeRef getLeftSibling(unsigned Level) const;
873
874
  /// moveLeft - Move path to the left sibling at Level. Leave nodes below Level
875
  /// unaltered.
876
  /// @param Level Move node(Level).
877
  void moveLeft(unsigned Level);
878
879
  /// fillLeft - Grow path to Height by taking leftmost branches.
880
  /// @param Height The target height.
881
12.8k
  void fillLeft(unsigned Height) {
882
25.7k
    while (height() < Height)
883
12.9k
      push(subtree(height()), 0);
884
12.8k
  }
885
886
  /// getLeftSibling - Get the left sibling node at Level, or a null NodeRef.
887
  /// @param Level Get the sinbling to node(Level).
888
  /// @return Left sibling, or NodeRef().
889
  NodeRef getRightSibling(unsigned Level) const;
890
891
  /// moveRight - Move path to the left sibling at Level. Leave nodes below
892
  /// Level unaltered.
893
  /// @param Level Move node(Level).
894
  void moveRight(unsigned Level);
895
896
  /// atBegin - Return true if path is at begin().
897
329k
  bool atBegin() const {
898
723k
    for (unsigned i = 0, e = path.size(); i != e; 
++i394k
)
899
556k
      if (path[i].offset != 0)
900
162k
        return false;
901
329k
    
return true167k
;
902
329k
  }
903
904
  /// atLastEntry - Return true if the path is at the last entry of the node at
905
  /// Level.
906
  /// @param Level Node to examine.
907
3.61M
  bool atLastEntry(unsigned Level) const {
908
3.61M
    return path[Level].offset == path[Level].size - 1;
909
3.61M
  }
910
911
  /// legalizeForInsert - Prepare the path for an insertion at Level. When the
912
  /// path is at end(), node(Level) may not be a legal node. legalizeForInsert
913
  /// ensures that node(Level) is real by moving back to the last node at Level,
914
  /// and setting offset(Level) to size(Level) if required.
915
  /// @param Level The level where an insertion is about to take place.
916
996k
  void legalizeForInsert(unsigned Level) {
917
996k
    if (valid())
918
83.4k
      return;
919
913k
    moveLeft(Level);
920
913k
    ++path[Level].offset;
921
913k
  }
922
};
923
924
} // end namespace IntervalMapImpl
925
926
//===----------------------------------------------------------------------===//
927
//---                          IntervalMap                                ----//
928
//===----------------------------------------------------------------------===//
929
930
template <typename KeyT, typename ValT,
931
          unsigned N = IntervalMapImpl::NodeSizer<KeyT, ValT>::LeafSize,
932
          typename Traits = IntervalMapInfo<KeyT>>
933
class IntervalMap {
934
  using Sizer = IntervalMapImpl::NodeSizer<KeyT, ValT>;
935
  using Leaf = IntervalMapImpl::LeafNode<KeyT, ValT, Sizer::LeafSize, Traits>;
936
  using Branch =
937
      IntervalMapImpl::BranchNode<KeyT, ValT, Sizer::BranchSize, Traits>;
938
  using RootLeaf = IntervalMapImpl::LeafNode<KeyT, ValT, N, Traits>;
939
  using IdxPair = IntervalMapImpl::IdxPair;
940
941
  // The RootLeaf capacity is given as a template parameter. We must compute the
942
  // corresponding RootBranch capacity.
943
  enum {
944
    DesiredRootBranchCap = (sizeof(RootLeaf) - sizeof(KeyT)) /
945
      (sizeof(KeyT) + sizeof(IntervalMapImpl::NodeRef)),
946
    RootBranchCap = DesiredRootBranchCap ? DesiredRootBranchCap : 1
947
  };
948
949
  using RootBranch =
950
      IntervalMapImpl::BranchNode<KeyT, ValT, RootBranchCap, Traits>;
951
952
  // When branched, we store a global start key as well as the branch node.
953
  struct RootBranchData {
954
    KeyT start;
955
    RootBranch node;
956
  };
957
958
public:
959
  using Allocator = typename Sizer::Allocator;
960
  using KeyType = KeyT;
961
  using ValueType = ValT;
962
  using KeyTraits = Traits;
963
964
private:
965
  // The root data is either a RootLeaf or a RootBranchData instance.
966
  AlignedCharArrayUnion<RootLeaf, RootBranchData> data;
967
968
  // Tree height.
969
  // 0: Leaves in root.
970
  // 1: Root points to leaf.
971
  // 2: root->branch->leaf ...
972
  unsigned height;
973
974
  // Number of entries in the root node.
975
  unsigned rootSize;
976
977
  // Allocator used for creating external nodes.
978
  Allocator &allocator;
979
980
  /// dataAs - Represent data as a node type without breaking aliasing rules.
981
  template <typename T>
982
344M
  T &dataAs() const {
983
344M
    union {
984
344M
      const char *d;
985
344M
      T *t;
986
344M
    } u;
987
344M
    u.d = data.buffer;
988
344M
    return *u.t;
989
344M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::RootBranchData& llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::dataAs<llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::RootBranchData>() const
Line
Count
Source
982
64.2M
  T &dataAs() const {
983
64.2M
    union {
984
64.2M
      const char *d;
985
64.2M
      T *t;
986
64.2M
    } u;
987
64.2M
    u.d = data.buffer;
988
64.2M
    return *u.t;
989
64.2M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::dataAs<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
982
271M
  T &dataAs() const {
983
271M
    union {
984
271M
      const char *d;
985
271M
      T *t;
986
271M
    } u;
987
271M
    u.d = data.buffer;
988
271M
    return *u.t;
989
271M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::dataAs<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
982
8.31k
  T &dataAs() const {
983
8.31k
    union {
984
8.31k
      const char *d;
985
8.31k
      T *t;
986
8.31k
    } u;
987
8.31k
    u.d = data.buffer;
988
8.31k
    return *u.t;
989
8.31k
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::RootBranchData& llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::dataAs<llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::RootBranchData>() const
Line
Count
Source
982
172
  T &dataAs() const {
983
172
    union {
984
172
      const char *d;
985
172
      T *t;
986
172
    } u;
987
172
    u.d = data.buffer;
988
172
    return *u.t;
989
172
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::RootBranchData& llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::dataAs<llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::RootBranchData>() const
Line
Count
Source
982
2.21M
  T &dataAs() const {
983
2.21M
    union {
984
2.21M
      const char *d;
985
2.21M
      T *t;
986
2.21M
    } u;
987
2.21M
    u.d = data.buffer;
988
2.21M
    return *u.t;
989
2.21M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >& llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::dataAs<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >() const
Line
Count
Source
982
6.93M
  T &dataAs() const {
983
6.93M
    union {
984
6.93M
      const char *d;
985
6.93M
      T *t;
986
6.93M
    } u;
987
6.93M
    u.d = data.buffer;
988
6.93M
    return *u.t;
989
6.93M
  }
990
991
2.74M
  const RootLeaf &rootLeaf() const {
992
2.74M
    assert(!branched() && "Cannot acces leaf data in branched root");
993
2.74M
    return dataAs<RootLeaf>();
994
2.74M
  }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootLeaf() const
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootLeaf() const
Line
Count
Source
991
2.74M
  const RootLeaf &rootLeaf() const {
992
2.74M
    assert(!branched() && "Cannot acces leaf data in branched root");
993
2.74M
    return dataAs<RootLeaf>();
994
2.74M
  }
995
275M
  RootLeaf &rootLeaf() {
996
275M
    assert(!branched() && "Cannot acces leaf data in branched root");
997
275M
    return dataAs<RootLeaf>();
998
275M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootLeaf()
Line
Count
Source
995
271M
  RootLeaf &rootLeaf() {
996
271M
    assert(!branched() && "Cannot acces leaf data in branched root");
997
271M
    return dataAs<RootLeaf>();
998
271M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootLeaf()
Line
Count
Source
995
8.31k
  RootLeaf &rootLeaf() {
996
8.31k
    assert(!branched() && "Cannot acces leaf data in branched root");
997
8.31k
    return dataAs<RootLeaf>();
998
8.31k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootLeaf()
Line
Count
Source
995
4.19M
  RootLeaf &rootLeaf() {
996
4.19M
    assert(!branched() && "Cannot acces leaf data in branched root");
997
4.19M
    return dataAs<RootLeaf>();
998
4.19M
  }
999
1000
807k
  RootBranchData &rootBranchData() const {
1001
807k
    assert(branched() && "Cannot access branch data in non-branched root");
1002
807k
    return dataAs<RootBranchData>();
1003
807k
  }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchData() const
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchData() const
Line
Count
Source
1000
807k
  RootBranchData &rootBranchData() const {
1001
807k
    assert(branched() && "Cannot access branch data in non-branched root");
1002
807k
    return dataAs<RootBranchData>();
1003
807k
  }
1004
65.6M
  RootBranchData &rootBranchData() {
1005
65.6M
    assert(branched() && "Cannot access branch data in non-branched root");
1006
65.6M
    return dataAs<RootBranchData>();
1007
65.6M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchData()
Line
Count
Source
1004
64.2M
  RootBranchData &rootBranchData() {
1005
64.2M
    assert(branched() && "Cannot access branch data in non-branched root");
1006
64.2M
    return dataAs<RootBranchData>();
1007
64.2M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchData()
Line
Count
Source
1004
172
  RootBranchData &rootBranchData() {
1005
172
    assert(branched() && "Cannot access branch data in non-branched root");
1006
172
    return dataAs<RootBranchData>();
1007
172
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchData()
Line
Count
Source
1004
1.41M
  RootBranchData &rootBranchData() {
1005
1.41M
    assert(branched() && "Cannot access branch data in non-branched root");
1006
1.41M
    return dataAs<RootBranchData>();
1007
1.41M
  }
1008
1009
536k
  const RootBranch &rootBranch() const { return rootBranchData().node; }
1010
64.4M
  RootBranch &rootBranch()             { return rootBranchData().node; }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranch()
Line
Count
Source
1010
63.1M
  RootBranch &rootBranch()             { return rootBranchData().node; }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranch()
Line
Count
Source
1010
157
  RootBranch &rootBranch()             { return rootBranchData().node; }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranch()
Line
Count
Source
1010
1.37M
  RootBranch &rootBranch()             { return rootBranchData().node; }
1011
271k
  KeyT rootBranchStart() const { return rootBranchData().start; }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchStart() const
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchStart() const
Line
Count
Source
1011
271k
  KeyT rootBranchStart() const { return rootBranchData().start; }
1012
571k
  KeyT &rootBranchStart()      { return rootBranchData().start; }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchStart()
Line
Count
Source
1012
5
  KeyT &rootBranchStart()      { return rootBranchData().start; }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchStart()
Line
Count
Source
1012
558k
  KeyT &rootBranchStart()      { return rootBranchData().start; }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::rootBranchStart()
Line
Count
Source
1012
13.3k
  KeyT &rootBranchStart()      { return rootBranchData().start; }
1013
1014
1.00M
  template <typename NodeT> NodeT *newNode() {
1015
1.00M
    return new(allocator.template Allocate<NodeT>()) NodeT();
1016
1.00M
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >* llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::newNode<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >()
Line
Count
Source
1014
5
  template <typename NodeT> NodeT *newNode() {
1015
5
    return new(allocator.template Allocate<NodeT>()) NodeT();
1016
5
  }
Unexecuted instantiation: llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >* llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::newNode<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >()
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >* llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::newNode<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >()
Line
Count
Source
1014
960k
  template <typename NodeT> NodeT *newNode() {
1015
960k
    return new(allocator.template Allocate<NodeT>()) NodeT();
1016
960k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >* llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::newNode<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >()
Line
Count
Source
1014
16.1k
  template <typename NodeT> NodeT *newNode() {
1015
16.1k
    return new(allocator.template Allocate<NodeT>()) NodeT();
1016
16.1k
  }
llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >* llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::newNode<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >()
Line
Count
Source
1014
31.6k
  template <typename NodeT> NodeT *newNode() {
1015
31.6k
    return new(allocator.template Allocate<NodeT>()) NodeT();
1016
31.6k
  }
llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >* llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::newNode<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >()
Line
Count
Source
1014
112
  template <typename NodeT> NodeT *newNode() {
1015
112
    return new(allocator.template Allocate<NodeT>()) NodeT();
1016
112
  }
1017
1018
1.00M
  template <typename NodeT> void deleteNode(NodeT *P) {
1019
1.00M
    P->~NodeT();
1020
1.00M
    allocator.Deallocate(P);
1021
1.00M
  }
Unexecuted instantiation: void llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >*)
void llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >*)
Line
Count
Source
1018
5
  template <typename NodeT> void deleteNode(NodeT *P) {
1019
5
    P->~NodeT();
1020
5
    allocator.Deallocate(P);
1021
5
  }
void llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >*)
Line
Count
Source
1018
16.1k
  template <typename NodeT> void deleteNode(NodeT *P) {
1019
16.1k
    P->~NodeT();
1020
16.1k
    allocator.Deallocate(P);
1021
16.1k
  }
void llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >*)
Line
Count
Source
1018
960k
  template <typename NodeT> void deleteNode(NodeT *P) {
1019
960k
    P->~NodeT();
1020
960k
    allocator.Deallocate(P);
1021
960k
  }
void llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> >*)
Line
Count
Source
1018
112
  template <typename NodeT> void deleteNode(NodeT *P) {
1019
112
    P->~NodeT();
1020
112
    allocator.Deallocate(P);
1021
112
  }
void llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >*)
Line
Count
Source
1018
31.6k
  template <typename NodeT> void deleteNode(NodeT *P) {
1019
31.6k
    P->~NodeT();
1020
31.6k
    allocator.Deallocate(P);
1021
31.6k
  }
1022
1023
  IdxPair branchRoot(unsigned Position);
1024
  IdxPair splitRoot(unsigned Position);
1025
1026
312k
  void switchRootToBranch() {
1027
312k
    rootLeaf().~RootLeaf();
1028
312k
    height = 1;
1029
312k
    new (&rootBranchData()) RootBranchData();
1030
312k
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::switchRootToBranch()
Line
Count
Source
1026
5
  void switchRootToBranch() {
1027
5
    rootLeaf().~RootLeaf();
1028
5
    height = 1;
1029
5
    new (&rootBranchData()) RootBranchData();
1030
5
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::switchRootToBranch()
Line
Count
Source
1026
300k
  void switchRootToBranch() {
1027
300k
    rootLeaf().~RootLeaf();
1028
300k
    height = 1;
1029
300k
    new (&rootBranchData()) RootBranchData();
1030
300k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::switchRootToBranch()
Line
Count
Source
1026
12.7k
  void switchRootToBranch() {
1027
12.7k
    rootLeaf().~RootLeaf();
1028
12.7k
    height = 1;
1029
12.7k
    new (&rootBranchData()) RootBranchData();
1030
12.7k
  }
1031
1032
312k
  void switchRootToLeaf() {
1033
312k
    rootBranchData().~RootBranchData();
1034
312k
    height = 0;
1035
312k
    new(&rootLeaf()) RootLeaf();
1036
312k
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::switchRootToLeaf()
Line
Count
Source
1032
5
  void switchRootToLeaf() {
1033
5
    rootBranchData().~RootBranchData();
1034
5
    height = 0;
1035
5
    new(&rootLeaf()) RootLeaf();
1036
5
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::switchRootToLeaf()
Line
Count
Source
1032
300k
  void switchRootToLeaf() {
1033
300k
    rootBranchData().~RootBranchData();
1034
300k
    height = 0;
1035
300k
    new(&rootLeaf()) RootLeaf();
1036
300k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::switchRootToLeaf()
Line
Count
Source
1032
12.7k
  void switchRootToLeaf() {
1033
12.7k
    rootBranchData().~RootBranchData();
1034
12.7k
    height = 0;
1035
12.7k
    new(&rootLeaf()) RootLeaf();
1036
12.7k
  }
1037
1038
1.08G
  bool branched() const { return height > 0; }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::branched() const
Line
Count
Source
1038
1.07G
  bool branched() const { return height > 0; }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::branched() const
Line
Count
Source
1038
23.5k
  bool branched() const { return height > 0; }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::branched() const
Line
Count
Source
1038
11.4M
  bool branched() const { return height > 0; }
1039
1040
  ValT treeSafeLookup(KeyT x, ValT NotFound) const;
1041
  void visitNodes(void (IntervalMap::*f)(IntervalMapImpl::NodeRef,
1042
                  unsigned Level));
1043
  void deleteNode(IntervalMapImpl::NodeRef Node, unsigned Level);
1044
1045
public:
1046
5.27M
  explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
1047
5.27M
    assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
1048
5.27M
           "Insufficient alignment");
1049
5.27M
    new(&rootLeaf()) RootLeaf();
1050
5.27M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::IntervalMap(llvm::RecyclingAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>, char, 192ul, 64ul>&)
Line
Count
Source
1046
536
  explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
1047
536
    assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
1048
536
           "Insufficient alignment");
1049
536
    new(&rootLeaf()) RootLeaf();
1050
536
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::IntervalMap(llvm::RecyclingAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>, char, 192ul, 64ul>&)
Line
Count
Source
1046
4.82M
  explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
1047
4.82M
    assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
1048
4.82M
           "Insufficient alignment");
1049
4.82M
    new(&rootLeaf()) RootLeaf();
1050
4.82M
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::IntervalMap(llvm::RecyclingAllocator<llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>, char, 192ul, 64ul>&)
Line
Count
Source
1046
447k
  explicit IntervalMap(Allocator &a) : height(0), rootSize(0), allocator(a) {
1047
447k
    assert((uintptr_t(data.buffer) & (alignof(RootLeaf) - 1)) == 0 &&
1048
447k
           "Insufficient alignment");
1049
447k
    new(&rootLeaf()) RootLeaf();
1050
447k
  }
1051
1052
5.27M
  ~IntervalMap() {
1053
5.27M
    clear();
1054
5.27M
    rootLeaf().~RootLeaf();
1055
5.27M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::~IntervalMap()
Line
Count
Source
1052
536
  ~IntervalMap() {
1053
536
    clear();
1054
536
    rootLeaf().~RootLeaf();
1055
536
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::~IntervalMap()
Line
Count
Source
1052
4.82M
  ~IntervalMap() {
1053
4.82M
    clear();
1054
4.82M
    rootLeaf().~RootLeaf();
1055
4.82M
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::~IntervalMap()
Line
Count
Source
1052
446k
  ~IntervalMap() {
1053
446k
    clear();
1054
446k
    rootLeaf().~RootLeaf();
1055
446k
  }
1056
1057
  /// empty -  Return true when no intervals are mapped.
1058
132M
  bool empty() const {
1059
132M
    return rootSize == 0;
1060
132M
  }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::empty() const
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::empty() const
Line
Count
Source
1058
131M
  bool empty() const {
1059
131M
    return rootSize == 0;
1060
131M
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::empty() const
Line
Count
Source
1058
1.29M
  bool empty() const {
1059
1.29M
    return rootSize == 0;
1060
1.29M
  }
1061
1062
  /// start - Return the smallest mapped key in a non-empty map.
1063
1.29M
  KeyT start() const {
1064
1.29M
    assert(!empty() && "Empty IntervalMap has no start");
1065
1.29M
    return !branched() ? 
rootLeaf().start(0)1.02M
:
rootBranchStart()271k
;
1066
1.29M
  }
1067
1068
  /// stop - Return the largest mapped key in a non-empty map.
1069
1.19M
  KeyT stop() const {
1070
1.19M
    assert(!empty() && "Empty IntervalMap has no stop");
1071
1.19M
    return !branched() ? 
rootLeaf().stop(rootSize - 1)930k
:
1072
1.19M
                         
rootBranch().stop(rootSize - 1)269k
;
1073
1.19M
  }
1074
1075
  /// lookup - Return the mapped value at x or NotFound.
1076
1.29M
  ValT lookup(KeyT x, ValT NotFound = ValT()) const {
1077
1.29M
    if (empty() || Traits::startLess(x, start()) || 
Traits::stopLess(stop(), x)1.19M
)
1078
230k
      return NotFound;
1079
1.06M
    return branched() ? 
treeSafeLookup(x, NotFound)267k
:
1080
1.06M
                        
rootLeaf().safeLookup(x, NotFound)794k
;
1081
1.06M
  }
1082
1083
  /// insert - Add a mapping of [a;b] to y, coalesce with adjacent intervals.
1084
  /// It is assumed that no key in the interval is mapped to another value, but
1085
  /// overlapping intervals already mapped to y will be coalesced.
1086
1.96M
  void insert(KeyT a, KeyT b, ValT y) {
1087
1.96M
    if (branched() || 
rootSize == RootLeaf::Capacity1.36M
)
1088
642k
      return find(a).insert(a, b, y);
1089
1.32M
1090
1.32M
    // Easy insert into root leaf.
1091
1.32M
    unsigned p = rootLeaf().findFrom(0, rootSize, a);
1092
1.32M
    rootSize = rootLeaf().insertFrom(p, rootSize, a, b, y);
1093
1.32M
  }
1094
1095
  /// clear - Remove all entries.
1096
  void clear();
1097
1098
  class const_iterator;
1099
  class iterator;
1100
  friend class const_iterator;
1101
  friend class iterator;
1102
1103
0
  const_iterator begin() const {
1104
0
    const_iterator I(*this);
1105
0
    I.goToBegin();
1106
0
    return I;
1107
0
  }
1108
1109
136k
  iterator begin() {
1110
136k
    iterator I(*this);
1111
136k
    I.goToBegin();
1112
136k
    return I;
1113
136k
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::begin()
Line
Count
Source
1109
2.11k
  iterator begin() {
1110
2.11k
    iterator I(*this);
1111
2.11k
    I.goToBegin();
1112
2.11k
    return I;
1113
2.11k
  }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::begin()
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::begin()
Line
Count
Source
1109
134k
  iterator begin() {
1110
134k
    iterator I(*this);
1111
134k
    I.goToBegin();
1112
134k
    return I;
1113
134k
  }
1114
1115
  const_iterator end() const {
1116
    const_iterator I(*this);
1117
    I.goToEnd();
1118
    return I;
1119
  }
1120
1121
  iterator end() {
1122
    iterator I(*this);
1123
    I.goToEnd();
1124
    return I;
1125
  }
1126
1127
  /// find - Return an iterator pointing to the first interval ending at or
1128
  /// after x, or end().
1129
0
  const_iterator find(KeyT x) const {
1130
0
    const_iterator I(*this);
1131
0
    I.find(x);
1132
0
    return I;
1133
0
  }
1134
1135
11.2M
  iterator find(KeyT x) {
1136
11.2M
    iterator I(*this);
1137
11.2M
    I.find(x);
1138
11.2M
    return I;
1139
11.2M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::find(llvm::SlotIndex)
Line
Count
Source
1135
1.42k
  iterator find(KeyT x) {
1136
1.42k
    iterator I(*this);
1137
1.42k
    I.find(x);
1138
1.42k
    return I;
1139
1.42k
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::find(llvm::SlotIndex)
Line
Count
Source
1135
10.5M
  iterator find(KeyT x) {
1136
10.5M
    iterator I(*this);
1137
10.5M
    I.find(x);
1138
10.5M
    return I;
1139
10.5M
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::find(llvm::SlotIndex)
Line
Count
Source
1135
642k
  iterator find(KeyT x) {
1136
642k
    iterator I(*this);
1137
642k
    I.find(x);
1138
642k
    return I;
1139
642k
  }
1140
};
1141
1142
/// treeSafeLookup - Return the mapped value at x or NotFound, assuming a
1143
/// branched root.
1144
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1145
ValT IntervalMap<KeyT, ValT, N, Traits>::
1146
267k
treeSafeLookup(KeyT x, ValT NotFound) const {
1147
267k
  assert(branched() && "treeLookup assumes a branched root");
1148
267k
1149
267k
  IntervalMapImpl::NodeRef NR = rootBranch().safeLookup(x);
1150
277k
  for (unsigned h = height-1; h; 
--h9.99k
)
1151
9.99k
    NR = NR.get<Branch>().safeLookup(x);
1152
267k
  return NR.get<Leaf>().safeLookup(x, NotFound);
1153
267k
}
1154
1155
// branchRoot - Switch from a leaf root to a branched root.
1156
// Return the new (root offset, node offset) corresponding to Position.
1157
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1158
IntervalMapImpl::IdxPair IntervalMap<KeyT, ValT, N, Traits>::
1159
312k
branchRoot(unsigned Position) {
1160
312k
  using namespace IntervalMapImpl;
1161
312k
  // How many external leaf nodes to hold RootLeaf+1?
1162
312k
  const unsigned Nodes = RootLeaf::Capacity / Leaf::Capacity + 1;
1163
312k
1164
312k
  // Compute element distribution among new nodes.
1165
312k
  unsigned size[Nodes];
1166
312k
  IdxPair NewOffset(0, Position);
1167
312k
1168
312k
  // Is is very common for the root node to be smaller than external nodes.
1169
312k
  if (Nodes == 1)
1170
5
    size[0] = rootSize;
1171
312k
  else
1172
312k
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, size,
1173
312k
                           Position, true);
1174
312k
1175
312k
  // Allocate new nodes.
1176
312k
  unsigned pos = 0;
1177
312k
  NodeRef node[Nodes];
1178
938k
  for (unsigned n = 0; n != Nodes; 
++n625k
) {
1179
625k
    Leaf *L = newNode<Leaf>();
1180
625k
    L->copy(rootLeaf(), pos, 0, size[n]);
1181
625k
    node[n] = NodeRef(L, size[n]);
1182
625k
    pos += size[n];
1183
625k
  }
1184
312k
1185
312k
  // Destroy the old leaf node, construct branch node instead.
1186
312k
  switchRootToBranch();
1187
938k
  for (unsigned n = 0; n != Nodes; 
++n625k
) {
1188
625k
    rootBranch().stop(n) = node[n].template get<Leaf>().stop(size[n]-1);
1189
625k
    rootBranch().subtree(n) = node[n];
1190
625k
  }
1191
312k
  rootBranchStart() = node[0].template get<Leaf>().start(0);
1192
312k
  rootSize = Nodes;
1193
312k
  return NewOffset;
1194
312k
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::branchRoot(unsigned int)
Line
Count
Source
1159
5
branchRoot(unsigned Position) {
1160
5
  using namespace IntervalMapImpl;
1161
5
  // How many external leaf nodes to hold RootLeaf+1?
1162
5
  const unsigned Nodes = RootLeaf::Capacity / Leaf::Capacity + 1;
1163
5
1164
5
  // Compute element distribution among new nodes.
1165
5
  unsigned size[Nodes];
1166
5
  IdxPair NewOffset(0, Position);
1167
5
1168
5
  // Is is very common for the root node to be smaller than external nodes.
1169
5
  if (Nodes == 1)
1170
5
    size[0] = rootSize;
1171
0
  else
1172
0
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, size,
1173
0
                           Position, true);
1174
5
1175
5
  // Allocate new nodes.
1176
5
  unsigned pos = 0;
1177
5
  NodeRef node[Nodes];
1178
10
  for (unsigned n = 0; n != Nodes; 
++n5
) {
1179
5
    Leaf *L = newNode<Leaf>();
1180
5
    L->copy(rootLeaf(), pos, 0, size[n]);
1181
5
    node[n] = NodeRef(L, size[n]);
1182
5
    pos += size[n];
1183
5
  }
1184
5
1185
5
  // Destroy the old leaf node, construct branch node instead.
1186
5
  switchRootToBranch();
1187
10
  for (unsigned n = 0; n != Nodes; 
++n5
) {
1188
5
    rootBranch().stop(n) = node[n].template get<Leaf>().stop(size[n]-1);
1189
5
    rootBranch().subtree(n) = node[n];
1190
5
  }
1191
5
  rootBranchStart() = node[0].template get<Leaf>().start(0);
1192
5
  rootSize = Nodes;
1193
5
  return NewOffset;
1194
5
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::branchRoot(unsigned int)
Line
Count
Source
1159
300k
branchRoot(unsigned Position) {
1160
300k
  using namespace IntervalMapImpl;
1161
300k
  // How many external leaf nodes to hold RootLeaf+1?
1162
300k
  const unsigned Nodes = RootLeaf::Capacity / Leaf::Capacity + 1;
1163
300k
1164
300k
  // Compute element distribution among new nodes.
1165
300k
  unsigned size[Nodes];
1166
300k
  IdxPair NewOffset(0, Position);
1167
300k
1168
300k
  // Is is very common for the root node to be smaller than external nodes.
1169
300k
  if (Nodes == 1)
1170
0
    size[0] = rootSize;
1171
300k
  else
1172
300k
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, size,
1173
300k
                           Position, true);
1174
300k
1175
300k
  // Allocate new nodes.
1176
300k
  unsigned pos = 0;
1177
300k
  NodeRef node[Nodes];
1178
900k
  for (unsigned n = 0; n != Nodes; 
++n600k
) {
1179
600k
    Leaf *L = newNode<Leaf>();
1180
600k
    L->copy(rootLeaf(), pos, 0, size[n]);
1181
600k
    node[n] = NodeRef(L, size[n]);
1182
600k
    pos += size[n];
1183
600k
  }
1184
300k
1185
300k
  // Destroy the old leaf node, construct branch node instead.
1186
300k
  switchRootToBranch();
1187
900k
  for (unsigned n = 0; n != Nodes; 
++n600k
) {
1188
600k
    rootBranch().stop(n) = node[n].template get<Leaf>().stop(size[n]-1);
1189
600k
    rootBranch().subtree(n) = node[n];
1190
600k
  }
1191
300k
  rootBranchStart() = node[0].template get<Leaf>().start(0);
1192
300k
  rootSize = Nodes;
1193
300k
  return NewOffset;
1194
300k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::branchRoot(unsigned int)
Line
Count
Source
1159
12.7k
branchRoot(unsigned Position) {
1160
12.7k
  using namespace IntervalMapImpl;
1161
12.7k
  // How many external leaf nodes to hold RootLeaf+1?
1162
12.7k
  const unsigned Nodes = RootLeaf::Capacity / Leaf::Capacity + 1;
1163
12.7k
1164
12.7k
  // Compute element distribution among new nodes.
1165
12.7k
  unsigned size[Nodes];
1166
12.7k
  IdxPair NewOffset(0, Position);
1167
12.7k
1168
12.7k
  // Is is very common for the root node to be smaller than external nodes.
1169
12.7k
  if (Nodes == 1)
1170
0
    size[0] = rootSize;
1171
12.7k
  else
1172
12.7k
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, size,
1173
12.7k
                           Position, true);
1174
12.7k
1175
12.7k
  // Allocate new nodes.
1176
12.7k
  unsigned pos = 0;
1177
12.7k
  NodeRef node[Nodes];
1178
38.3k
  for (unsigned n = 0; n != Nodes; 
++n25.5k
) {
1179
25.5k
    Leaf *L = newNode<Leaf>();
1180
25.5k
    L->copy(rootLeaf(), pos, 0, size[n]);
1181
25.5k
    node[n] = NodeRef(L, size[n]);
1182
25.5k
    pos += size[n];
1183
25.5k
  }
1184
12.7k
1185
12.7k
  // Destroy the old leaf node, construct branch node instead.
1186
12.7k
  switchRootToBranch();
1187
38.3k
  for (unsigned n = 0; n != Nodes; 
++n25.5k
) {
1188
25.5k
    rootBranch().stop(n) = node[n].template get<Leaf>().stop(size[n]-1);
1189
25.5k
    rootBranch().subtree(n) = node[n];
1190
25.5k
  }
1191
12.7k
  rootBranchStart() = node[0].template get<Leaf>().start(0);
1192
12.7k
  rootSize = Nodes;
1193
12.7k
  return NewOffset;
1194
12.7k
}
1195
1196
// splitRoot - Split the current BranchRoot into multiple Branch nodes.
1197
// Return the new (root offset, node offset) corresponding to Position.
1198
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1199
IntervalMapImpl::IdxPair IntervalMap<KeyT, ValT, N, Traits>::
1200
6.41k
splitRoot(unsigned Position) {
1201
6.41k
  using namespace IntervalMapImpl;
1202
6.41k
  // How many external leaf nodes to hold RootBranch+1?
1203
6.41k
  const unsigned Nodes = RootBranch::Capacity / Branch::Capacity + 1;
1204
6.41k
1205
6.41k
  // Compute element distribution among new nodes.
1206
6.41k
  unsigned Size[Nodes];
1207
6.41k
  IdxPair NewOffset(0, Position);
1208
6.41k
1209
6.41k
  // Is is very common for the root node to be smaller than external nodes.
1210
6.41k
  if (Nodes == 1)
1211
6.41k
    Size[0] = rootSize;
1212
0
  else
1213
0
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, Size,
1214
0
                           Position, true);
1215
6.41k
1216
6.41k
  // Allocate new nodes.
1217
6.41k
  unsigned Pos = 0;
1218
6.41k
  NodeRef Node[Nodes];
1219
12.8k
  for (unsigned n = 0; n != Nodes; 
++n6.41k
) {
1220
6.41k
    Branch *B = newNode<Branch>();
1221
6.41k
    B->copy(rootBranch(), Pos, 0, Size[n]);
1222
6.41k
    Node[n] = NodeRef(B, Size[n]);
1223
6.41k
    Pos += Size[n];
1224
6.41k
  }
1225
6.41k
1226
12.8k
  for (unsigned n = 0; n != Nodes; 
++n6.41k
) {
1227
6.41k
    rootBranch().stop(n) = Node[n].template get<Branch>().stop(Size[n]-1);
1228
6.41k
    rootBranch().subtree(n) = Node[n];
1229
6.41k
  }
1230
6.41k
  rootSize = Nodes;
1231
6.41k
  ++height;
1232
6.41k
  return NewOffset;
1233
6.41k
}
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::splitRoot(unsigned int)
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::splitRoot(unsigned int)
Line
Count
Source
1200
6.35k
splitRoot(unsigned Position) {
1201
6.35k
  using namespace IntervalMapImpl;
1202
6.35k
  // How many external leaf nodes to hold RootBranch+1?
1203
6.35k
  const unsigned Nodes = RootBranch::Capacity / Branch::Capacity + 1;
1204
6.35k
1205
6.35k
  // Compute element distribution among new nodes.
1206
6.35k
  unsigned Size[Nodes];
1207
6.35k
  IdxPair NewOffset(0, Position);
1208
6.35k
1209
6.35k
  // Is is very common for the root node to be smaller than external nodes.
1210
6.35k
  if (Nodes == 1)
1211
6.35k
    Size[0] = rootSize;
1212
0
  else
1213
0
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, Size,
1214
0
                           Position, true);
1215
6.35k
1216
6.35k
  // Allocate new nodes.
1217
6.35k
  unsigned Pos = 0;
1218
6.35k
  NodeRef Node[Nodes];
1219
12.7k
  for (unsigned n = 0; n != Nodes; 
++n6.35k
) {
1220
6.35k
    Branch *B = newNode<Branch>();
1221
6.35k
    B->copy(rootBranch(), Pos, 0, Size[n]);
1222
6.35k
    Node[n] = NodeRef(B, Size[n]);
1223
6.35k
    Pos += Size[n];
1224
6.35k
  }
1225
6.35k
1226
12.7k
  for (unsigned n = 0; n != Nodes; 
++n6.35k
) {
1227
6.35k
    rootBranch().stop(n) = Node[n].template get<Branch>().stop(Size[n]-1);
1228
6.35k
    rootBranch().subtree(n) = Node[n];
1229
6.35k
  }
1230
6.35k
  rootSize = Nodes;
1231
6.35k
  ++height;
1232
6.35k
  return NewOffset;
1233
6.35k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::splitRoot(unsigned int)
Line
Count
Source
1200
54
splitRoot(unsigned Position) {
1201
54
  using namespace IntervalMapImpl;
1202
54
  // How many external leaf nodes to hold RootBranch+1?
1203
54
  const unsigned Nodes = RootBranch::Capacity / Branch::Capacity + 1;
1204
54
1205
54
  // Compute element distribution among new nodes.
1206
54
  unsigned Size[Nodes];
1207
54
  IdxPair NewOffset(0, Position);
1208
54
1209
54
  // Is is very common for the root node to be smaller than external nodes.
1210
54
  if (Nodes == 1)
1211
54
    Size[0] = rootSize;
1212
0
  else
1213
0
    NewOffset = distribute(Nodes, rootSize, Leaf::Capacity,  nullptr, Size,
1214
0
                           Position, true);
1215
54
1216
54
  // Allocate new nodes.
1217
54
  unsigned Pos = 0;
1218
54
  NodeRef Node[Nodes];
1219
108
  for (unsigned n = 0; n != Nodes; 
++n54
) {
1220
54
    Branch *B = newNode<Branch>();
1221
54
    B->copy(rootBranch(), Pos, 0, Size[n]);
1222
54
    Node[n] = NodeRef(B, Size[n]);
1223
54
    Pos += Size[n];
1224
54
  }
1225
54
1226
108
  for (unsigned n = 0; n != Nodes; 
++n54
) {
1227
54
    rootBranch().stop(n) = Node[n].template get<Branch>().stop(Size[n]-1);
1228
54
    rootBranch().subtree(n) = Node[n];
1229
54
  }
1230
54
  rootSize = Nodes;
1231
54
  ++height;
1232
54
  return NewOffset;
1233
54
}
1234
1235
/// visitNodes - Visit each external node.
1236
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1237
void IntervalMap<KeyT, ValT, N, Traits>::
1238
303k
visitNodes(void (IntervalMap::*f)(IntervalMapImpl::NodeRef, unsigned Height)) {
1239
303k
  if (!branched())
1240
0
    return;
1241
303k
  SmallVector<IntervalMapImpl::NodeRef, 4> Refs, NextRefs;
1242
303k
1243
303k
  // Collect level 0 nodes from the root.
1244
1.12M
  for (unsigned i = 0; i != rootSize; 
++i823k
)
1245
823k
    Refs.push_back(rootBranch().subtree(i));
1246
303k
1247
303k
  // Visit all branch nodes.
1248
309k
  for (unsigned h = height - 1; h; 
--h6.35k
) {
1249
22.4k
    for (unsigned i = 0, e = Refs.size(); i != e; 
++i16.0k
) {
1250
167k
      for (unsigned j = 0, s = Refs[i].size(); j != s; 
++j151k
)
1251
151k
        NextRefs.push_back(Refs[i].subtree(j));
1252
16.0k
      (this->*f)(Refs[i], h);
1253
16.0k
    }
1254
6.35k
    Refs.clear();
1255
6.35k
    Refs.swap(NextRefs);
1256
6.35k
  }
1257
303k
1258
303k
  // Visit all leaf nodes.
1259
1.26M
  for (unsigned i = 0, e = Refs.size(); i != e; 
++i958k
)
1260
958k
    (this->*f)(Refs[i], 0);
1261
303k
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::visitNodes(void (llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::*)(llvm::IntervalMapImpl::NodeRef, unsigned int))
Line
Count
Source
1238
5
visitNodes(void (IntervalMap::*f)(IntervalMapImpl::NodeRef, unsigned Height)) {
1239
5
  if (!branched())
1240
0
    return;
1241
5
  SmallVector<IntervalMapImpl::NodeRef, 4> Refs, NextRefs;
1242
5
1243
5
  // Collect level 0 nodes from the root.
1244
10
  for (unsigned i = 0; i != rootSize; 
++i5
)
1245
5
    Refs.push_back(rootBranch().subtree(i));
1246
5
1247
5
  // Visit all branch nodes.
1248
5
  for (unsigned h = height - 1; h; 
--h0
) {
1249
0
    for (unsigned i = 0, e = Refs.size(); i != e; ++i) {
1250
0
      for (unsigned j = 0, s = Refs[i].size(); j != s; ++j)
1251
0
        NextRefs.push_back(Refs[i].subtree(j));
1252
0
      (this->*f)(Refs[i], h);
1253
0
    }
1254
0
    Refs.clear();
1255
0
    Refs.swap(NextRefs);
1256
0
  }
1257
5
1258
5
  // Visit all leaf nodes.
1259
10
  for (unsigned i = 0, e = Refs.size(); i != e; 
++i5
)
1260
5
    (this->*f)(Refs[i], 0);
1261
5
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::visitNodes(void (llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::*)(llvm::IntervalMapImpl::NodeRef, unsigned int))
Line
Count
Source
1238
290k
visitNodes(void (IntervalMap::*f)(IntervalMapImpl::NodeRef, unsigned Height)) {
1239
290k
  if (!branched())
1240
0
    return;
1241
290k
  SmallVector<IntervalMapImpl::NodeRef, 4> Refs, NextRefs;
1242
290k
1243
290k
  // Collect level 0 nodes from the root.
1244
1.08M
  for (unsigned i = 0; i != rootSize; 
++i793k
)
1245
793k
    Refs.push_back(rootBranch().subtree(i));
1246
290k
1247
290k
  // Visit all branch nodes.
1248
296k
  for (unsigned h = height - 1; h; 
--h6.30k
) {
1249
22.2k
    for (unsigned i = 0, e = Refs.size(); i != e; 
++i15.9k
) {
1250
166k
      for (unsigned j = 0, s = Refs[i].size(); j != s; 
++j150k
)
1251
150k
        NextRefs.push_back(Refs[i].subtree(j));
1252
15.9k
      (this->*f)(Refs[i], h);
1253
15.9k
    }
1254
6.30k
    Refs.clear();
1255
6.30k
    Refs.swap(NextRefs);
1256
6.30k
  }
1257
290k
1258
290k
  // Visit all leaf nodes.
1259
1.21M
  for (unsigned i = 0, e = Refs.size(); i != e; 
++i928k
)
1260
928k
    (this->*f)(Refs[i], 0);
1261
290k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::visitNodes(void (llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::*)(llvm::IntervalMapImpl::NodeRef, unsigned int))
Line
Count
Source
1238
12.7k
visitNodes(void (IntervalMap::*f)(IntervalMapImpl::NodeRef, unsigned Height)) {
1239
12.7k
  if (!branched())
1240
0
    return;
1241
12.7k
  SmallVector<IntervalMapImpl::NodeRef, 4> Refs, NextRefs;
1242
12.7k
1243
12.7k
  // Collect level 0 nodes from the root.
1244
42.3k
  for (unsigned i = 0; i != rootSize; 
++i29.5k
)
1245
29.5k
    Refs.push_back(rootBranch().subtree(i));
1246
12.7k
1247
12.7k
  // Visit all branch nodes.
1248
12.8k
  for (unsigned h = height - 1; h; 
--h54
) {
1249
162
    for (unsigned i = 0, e = Refs.size(); i != e; 
++i108
) {
1250
880
      for (unsigned j = 0, s = Refs[i].size(); j != s; 
++j772
)
1251
772
        NextRefs.push_back(Refs[i].subtree(j));
1252
108
      (this->*f)(Refs[i], h);
1253
108
    }
1254
54
    Refs.clear();
1255
54
    Refs.swap(NextRefs);
1256
54
  }
1257
12.7k
1258
12.7k
  // Visit all leaf nodes.
1259
43.0k
  for (unsigned i = 0, e = Refs.size(); i != e; 
++i30.2k
)
1260
30.2k
    (this->*f)(Refs[i], 0);
1261
12.7k
}
1262
1263
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1264
void IntervalMap<KeyT, ValT, N, Traits>::
1265
974k
deleteNode(IntervalMapImpl::NodeRef Node, unsigned Level) {
1266
974k
  if (Level)
1267
16.0k
    deleteNode(&Node.get<Branch>());
1268
958k
  else
1269
958k
    deleteNode(&Node.get<Leaf>());
1270
974k
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode(llvm::IntervalMapImpl::NodeRef, unsigned int)
Line
Count
Source
1265
5
deleteNode(IntervalMapImpl::NodeRef Node, unsigned Level) {
1266
5
  if (Level)
1267
0
    deleteNode(&Node.get<Branch>());
1268
5
  else
1269
5
    deleteNode(&Node.get<Leaf>());
1270
5
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode(llvm::IntervalMapImpl::NodeRef, unsigned int)
Line
Count
Source
1265
944k
deleteNode(IntervalMapImpl::NodeRef Node, unsigned Level) {
1266
944k
  if (Level)
1267
15.9k
    deleteNode(&Node.get<Branch>());
1268
928k
  else
1269
928k
    deleteNode(&Node.get<Leaf>());
1270
944k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::deleteNode(llvm::IntervalMapImpl::NodeRef, unsigned int)
Line
Count
Source
1265
30.3k
deleteNode(IntervalMapImpl::NodeRef Node, unsigned Level) {
1266
30.3k
  if (Level)
1267
108
    deleteNode(&Node.get<Branch>());
1268
30.2k
  else
1269
30.2k
    deleteNode(&Node.get<Leaf>());
1270
30.3k
}
1271
1272
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1273
void IntervalMap<KeyT, ValT, N, Traits>::
1274
72.7M
clear() {
1275
72.7M
  if (branched()) {
1276
303k
    visitNodes(&IntervalMap::deleteNode);
1277
303k
    switchRootToLeaf();
1278
303k
  }
1279
72.7M
  rootSize = 0;
1280
72.7M
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::clear()
Line
Count
Source
1274
536
clear() {
1275
536
  if (branched()) {
1276
5
    visitNodes(&IntervalMap::deleteNode);
1277
5
    switchRootToLeaf();
1278
5
  }
1279
536
  rootSize = 0;
1280
536
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::clear()
Line
Count
Source
1274
72.0M
clear() {
1275
72.0M
  if (branched()) {
1276
290k
    visitNodes(&IntervalMap::deleteNode);
1277
290k
    switchRootToLeaf();
1278
290k
  }
1279
72.0M
  rootSize = 0;
1280
72.0M
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::clear()
Line
Count
Source
1274
695k
clear() {
1275
695k
  if (branched()) {
1276
12.7k
    visitNodes(&IntervalMap::deleteNode);
1277
12.7k
    switchRootToLeaf();
1278
12.7k
  }
1279
695k
  rootSize = 0;
1280
695k
}
1281
1282
//===----------------------------------------------------------------------===//
1283
//---                   IntervalMap::const_iterator                       ----//
1284
//===----------------------------------------------------------------------===//
1285
1286
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1287
class IntervalMap<KeyT, ValT, N, Traits>::const_iterator :
1288
  public std::iterator<std::bidirectional_iterator_tag, ValT> {
1289
1290
protected:
1291
  friend class IntervalMap;
1292
1293
  // The map referred to.
1294
  IntervalMap *map = nullptr;
1295
1296
  // We store a full path from the root to the current position.
1297
  // The path may be partially filled, but never between iterator calls.
1298
  IntervalMapImpl::Path path;
1299
1300
  explicit const_iterator(const IntervalMap &map) :
1301
11.3M
    map(const_cast<IntervalMap*>(&map)) {}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::const_iterator(llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> > const&)
Line
Count
Source
1301
3.54k
    map(const_cast<IntervalMap*>(&map)) {}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::const_iterator(llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > const&)
Line
Count
Source
1301
10.5M
    map(const_cast<IntervalMap*>(&map)) {}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::const_iterator(llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > const&)
Line
Count
Source
1301
776k
    map(const_cast<IntervalMap*>(&map)) {}
1302
1303
1.00G
  bool branched() const {
1304
1.00G
    assert(map && "Invalid iterator");
1305
1.00G
    return map->branched();
1306
1.00G
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::branched() const
Line
Count
Source
1303
1.00G
  bool branched() const {
1304
1.00G
    assert(map && "Invalid iterator");
1305
1.00G
    return map->branched();
1306
1.00G
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::branched() const
Line
Count
Source
1303
22.9k
  bool branched() const {
1304
22.9k
    assert(map && "Invalid iterator");
1305
22.9k
    return map->branched();
1306
22.9k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::branched() const
Line
Count
Source
1303
5.26M
  bool branched() const {
1304
5.26M
    assert(map && "Invalid iterator");
1305
5.26M
    return map->branched();
1306
5.26M
  }
1307
1308
150M
  void setRoot(unsigned Offset) {
1309
150M
    if (branched())
1310
30.6M
      path.setRoot(&map->rootBranch(), map->rootSize, Offset);
1311
119M
    else
1312
119M
      path.setRoot(&map->rootLeaf(), map->rootSize, Offset);
1313
150M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::setRoot(unsigned int)
Line
Count
Source
1308
149M
  void setRoot(unsigned Offset) {
1309
149M
    if (branched())
1310
30.0M
      path.setRoot(&map->rootBranch(), map->rootSize, Offset);
1311
119M
    else
1312
119M
      path.setRoot(&map->rootLeaf(), map->rootSize, Offset);
1313
149M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::setRoot(unsigned int)
Line
Count
Source
1308
3.59k
  void setRoot(unsigned Offset) {
1309
3.59k
    if (branched())
1310
78
      path.setRoot(&map->rootBranch(), map->rootSize, Offset);
1311
3.51k
    else
1312
3.51k
      path.setRoot(&map->rootLeaf(), map->rootSize, Offset);
1313
3.59k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::setRoot(unsigned int)
Line
Count
Source
1308
835k
  void setRoot(unsigned Offset) {
1309
835k
    if (branched())
1310
642k
      path.setRoot(&map->rootBranch(), map->rootSize, Offset);
1311
192k
    else
1312
192k
      path.setRoot(&map->rootLeaf(), map->rootSize, Offset);
1313
835k
  }
1314
1315
  void pathFillFind(KeyT x);
1316
  void treeFind(KeyT x);
1317
  void treeAdvanceTo(KeyT x);
1318
1319
  /// unsafeStart - Writable access to start() for iterator.
1320
283M
  KeyT &unsafeStart() const {
1321
283M
    assert(valid() && "Cannot access invalid iterator");
1322
283M
    return branched() ? 
path.leaf<Leaf>().start(path.leafOffset())76.5M
:
1323
283M
                        
path.leaf<RootLeaf>().start(path.leafOffset())207M
;
1324
283M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeStart() const
Line
Count
Source
1320
282M
  KeyT &unsafeStart() const {
1321
282M
    assert(valid() && "Cannot access invalid iterator");
1322
282M
    return branched() ? 
path.leaf<Leaf>().start(path.leafOffset())76.2M
:
1323
282M
                        
path.leaf<RootLeaf>().start(path.leafOffset())206M
;
1324
282M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeStart() const
Line
Count
Source
1320
4.83k
  KeyT &unsafeStart() const {
1321
4.83k
    assert(valid() && "Cannot access invalid iterator");
1322
4.83k
    return branched() ? 
path.leaf<Leaf>().start(path.leafOffset())168
:
1323
4.83k
                        
path.leaf<RootLeaf>().start(path.leafOffset())4.67k
;
1324
4.83k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeStart() const
Line
Count
Source
1320
1.11M
  KeyT &unsafeStart() const {
1321
1.11M
    assert(valid() && "Cannot access invalid iterator");
1322
1.11M
    return branched() ? 
path.leaf<Leaf>().start(path.leafOffset())357k
:
1323
1.11M
                        
path.leaf<RootLeaf>().start(path.leafOffset())761k
;
1324
1.11M
  }
1325
1326
  /// unsafeStop - Writable access to stop() for iterator.
1327
229M
  KeyT &unsafeStop() const {
1328
229M
    assert(valid() && "Cannot access invalid iterator");
1329
229M
    return branched() ? 
path.leaf<Leaf>().stop(path.leafOffset())47.1M
:
1330
229M
                        
path.leaf<RootLeaf>().stop(path.leafOffset())182M
;
1331
229M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeStop() const
Line
Count
Source
1327
229M
  KeyT &unsafeStop() const {
1328
229M
    assert(valid() && "Cannot access invalid iterator");
1329
229M
    return branched() ? 
path.leaf<Leaf>().stop(path.leafOffset())46.8M
:
1330
229M
                        
path.leaf<RootLeaf>().stop(path.leafOffset())182M
;
1331
229M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeStop() const
Line
Count
Source
1327
1.61k
  KeyT &unsafeStop() const {
1328
1.61k
    assert(valid() && "Cannot access invalid iterator");
1329
1.61k
    return branched() ? 
path.leaf<Leaf>().stop(path.leafOffset())59
:
1330
1.61k
                        
path.leaf<RootLeaf>().stop(path.leafOffset())1.55k
;
1331
1.61k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeStop() const
Line
Count
Source
1327
830k
  KeyT &unsafeStop() const {
1328
830k
    assert(valid() && "Cannot access invalid iterator");
1329
830k
    return branched() ? 
path.leaf<Leaf>().stop(path.leafOffset())252k
:
1330
830k
                        
path.leaf<RootLeaf>().stop(path.leafOffset())578k
;
1331
830k
  }
1332
1333
  /// unsafeValue - Writable access to value() for iterator.
1334
149M
  ValT &unsafeValue() const {
1335
149M
    assert(valid() && "Cannot access invalid iterator");
1336
149M
    return branched() ? 
path.leaf<Leaf>().value(path.leafOffset())32.4M
:
1337
149M
                        
path.leaf<RootLeaf>().value(path.leafOffset())116M
;
1338
149M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeValue() const
Line
Count
Source
1334
4.77k
  ValT &unsafeValue() const {
1335
4.77k
    assert(valid() && "Cannot access invalid iterator");
1336
4.77k
    return branched() ? 
path.leaf<Leaf>().value(path.leafOffset())187
:
1337
4.77k
                        
path.leaf<RootLeaf>().value(path.leafOffset())4.58k
;
1338
4.77k
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeValue() const
Line
Count
Source
1334
148M
  ValT &unsafeValue() const {
1335
148M
    assert(valid() && "Cannot access invalid iterator");
1336
148M
    return branched() ? 
path.leaf<Leaf>().value(path.leafOffset())32.3M
:
1337
148M
                        
path.leaf<RootLeaf>().value(path.leafOffset())116M
;
1338
148M
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::unsafeValue() const
Line
Count
Source
1334
551k
  ValT &unsafeValue() const {
1335
551k
    assert(valid() && "Cannot access invalid iterator");
1336
551k
    return branched() ? 
path.leaf<Leaf>().value(path.leafOffset())173k
:
1337
551k
                        
path.leaf<RootLeaf>().value(path.leafOffset())377k
;
1338
551k
  }
1339
1340
public:
1341
  /// const_iterator - Create an iterator that isn't pointing anywhere.
1342
97.4M
  const_iterator() = default;
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::const_iterator()
Line
Count
Source
1342
97.3M
  const_iterator() = default;
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::const_iterator()
Line
Count
Source
1342
15
  const_iterator() = default;
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::const_iterator()
Line
Count
Source
1342
106k
  const_iterator() = default;
1343
1344
  /// setMap - Change the map iterated over. This call must be followed by a
1345
  /// call to goToBegin(), goToEnd(), or find()
1346
129M
  void setMap(const IntervalMap &m) { map = const_cast<IntervalMap*>(&m); }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::setMap(llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > const&)
Line
Count
Source
1346
128M
  void setMap(const IntervalMap &m) { map = const_cast<IntervalMap*>(&m); }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::setMap(llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> > const&)
Line
Count
Source
1346
15
  void setMap(const IntervalMap &m) { map = const_cast<IntervalMap*>(&m); }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::setMap(llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > const&)
Line
Count
Source
1346
106k
  void setMap(const IntervalMap &m) { map = const_cast<IntervalMap*>(&m); }
1347
1348
  /// valid - Return true if the current position is valid, false for end().
1349
373M
  bool valid() const { return path.valid(); }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::valid() const
Line
Count
Source
1349
371M
  bool valid() const { return path.valid(); }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::valid() const
Line
Count
Source
1349
8.21k
  bool valid() const { return path.valid(); }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::valid() const
Line
Count
Source
1349
2.04M
  bool valid() const { return path.valid(); }
1350
1351
  /// atBegin - Return true if the current position is the first map entry.
1352
  bool atBegin() const { return path.atBegin(); }
1353
1354
  /// start - Return the beginning of the current interval.
1355
283M
  const KeyT &start() const { return unsafeStart(); }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::start() const
Line
Count
Source
1355
282M
  const KeyT &start() const { return unsafeStart(); }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::start() const
Line
Count
Source
1355
3.80k
  const KeyT &start() const { return unsafeStart(); }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::start() const
Line
Count
Source
1355
1.11M
  const KeyT &start() const { return unsafeStart(); }
1356
1357
  /// stop - Return the end of the current interval.
1358
229M
  const KeyT &stop() const { return unsafeStop(); }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::stop() const
Line
Count
Source
1358
229M
  const KeyT &stop() const { return unsafeStop(); }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::stop() const
Line
Count
Source
1358
1.56k
  const KeyT &stop() const { return unsafeStop(); }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::stop() const
Line
Count
Source
1358
830k
  const KeyT &stop() const { return unsafeStop(); }
1359
1360
  /// value - Return the mapped value at the current interval.
1361
149M
  const ValT &value() const { return unsafeValue(); }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::value() const
Line
Count
Source
1361
3.90k
  const ValT &value() const { return unsafeValue(); }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::value() const
Line
Count
Source
1361
148M
  const ValT &value() const { return unsafeValue(); }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::value() const
Line
Count
Source
1361
551k
  const ValT &value() const { return unsafeValue(); }
1362
1363
  const ValT &operator*() const { return value(); }
1364
1365
  bool operator==(const const_iterator &RHS) const {
1366
    assert(map == RHS.map && "Cannot compare iterators from different maps");
1367
    if (!valid())
1368
      return !RHS.valid();
1369
    if (path.leafOffset() != RHS.path.leafOffset())
1370
      return false;
1371
    return &path.template leaf<Leaf>() == &RHS.path.template leaf<Leaf>();
1372
  }
1373
1374
  bool operator!=(const const_iterator &RHS) const {
1375
    return !operator==(RHS);
1376
  }
1377
1378
  /// goToBegin - Move to the first interval in map.
1379
136k
  void goToBegin() {
1380
136k
    setRoot(0);
1381
136k
    if (branched())
1382
12.8k
      path.fillLeft(map->height);
1383
136k
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::goToBegin()
Line
Count
Source
1379
2.13k
  void goToBegin() {
1380
2.13k
    setRoot(0);
1381
2.13k
    if (branched())
1382
19
      path.fillLeft(map->height);
1383
2.13k
  }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::goToBegin()
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::goToBegin()
Line
Count
Source
1379
134k
  void goToBegin() {
1380
134k
    setRoot(0);
1381
134k
    if (branched())
1382
12.7k
      path.fillLeft(map->height);
1383
134k
  }
1384
1385
  /// goToEnd - Move beyond the last interval in map.
1386
  void goToEnd() {
1387
    setRoot(map->rootSize);
1388
  }
1389
1390
  /// preincrement - move to the next interval.
1391
36.4M
  const_iterator &operator++() {
1392
36.4M
    assert(valid() && "Cannot increment end()");
1393
36.4M
    if (++path.leafOffset() == path.leafSize() && 
branched()10.9M
)
1394
3.32M
      path.moveRight(map->height);
1395
36.4M
    return *this;
1396
36.4M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::operator++()
Line
Count
Source
1391
36.1M
  const_iterator &operator++() {
1392
36.1M
    assert(valid() && "Cannot increment end()");
1393
36.1M
    if (++path.leafOffset() == path.leafSize() && 
branched()10.8M
)
1394
3.31M
      path.moveRight(map->height);
1395
36.1M
    return *this;
1396
36.1M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::operator++()
Line
Count
Source
1391
3.08k
  const_iterator &operator++() {
1392
3.08k
    assert(valid() && "Cannot increment end()");
1393
3.08k
    if (++path.leafOffset() == path.leafSize() && 
branched()2.09k
)
1394
22
      path.moveRight(map->height);
1395
3.08k
    return *this;
1396
3.08k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::operator++()
Line
Count
Source
1391
265k
  const_iterator &operator++() {
1392
265k
    assert(valid() && "Cannot increment end()");
1393
265k
    if (++path.leafOffset() == path.leafSize() && 
branched()71.3k
)
1394
10.3k
      path.moveRight(map->height);
1395
265k
    return *this;
1396
265k
  }
1397
1398
  /// postincrement - Dont do that!
1399
  const_iterator operator++(int) {
1400
    const_iterator tmp = *this;
1401
    operator++();
1402
    return tmp;
1403
  }
1404
1405
  /// predecrement - move to the previous interval.
1406
4.11M
  const_iterator &operator--() {
1407
4.11M
    if (path.leafOffset() && 
(3.83M
valid()3.83M
||
!branched()709k
))
1408
3.64M
      --path.leafOffset();
1409
465k
    else
1410
465k
      path.moveLeft(map->height);
1411
4.11M
    return *this;
1412
4.11M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::operator--()
Line
Count
Source
1406
4.11M
  const_iterator &operator--() {
1407
4.11M
    if (path.leafOffset() && 
(3.83M
valid()3.83M
||
!branched()709k
))
1408
3.64M
      --path.leafOffset();
1409
465k
    else
1410
465k
      path.moveLeft(map->height);
1411
4.11M
    return *this;
1412
4.11M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::operator--()
Line
Count
Source
1406
12
  const_iterator &operator--() {
1407
12
    if (path.leafOffset() && (valid() || 
!branched()0
))
1408
12
      --path.leafOffset();
1409
0
    else
1410
0
      path.moveLeft(map->height);
1411
12
    return *this;
1412
12
  }
1413
1414
  /// postdecrement - Dont do that!
1415
  const_iterator operator--(int) {
1416
    const_iterator tmp = *this;
1417
    operator--();
1418
    return tmp;
1419
  }
1420
1421
  /// find - Move to the first interval with stop >= x, or end().
1422
  /// This is a full search from the root, the current position is ignored.
1423
148M
  void find(KeyT x) {
1424
148M
    if (branched())
1425
28.6M
      treeFind(x);
1426
119M
    else
1427
119M
      setRoot(map->rootLeaf().findFrom(0, map->rootSize, x));
1428
148M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::find(llvm::SlotIndex)
Line
Count
Source
1423
147M
  void find(KeyT x) {
1424
147M
    if (branched())
1425
28.0M
      treeFind(x);
1426
119M
    else
1427
119M
      setRoot(map->rootLeaf().findFrom(0, map->rootSize, x));
1428
147M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::find(llvm::SlotIndex)
Line
Count
Source
1423
1.45k
  void find(KeyT x) {
1424
1.45k
    if (branched())
1425
55
      treeFind(x);
1426
1.39k
    else
1427
1.39k
      setRoot(map->rootLeaf().findFrom(0, map->rootSize, x));
1428
1.45k
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::find(llvm::SlotIndex)
Line
Count
Source
1423
691k
  void find(KeyT x) {
1424
691k
    if (branched())
1425
620k
      treeFind(x);
1426
71.2k
    else
1427
71.2k
      setRoot(map->rootLeaf().findFrom(0, map->rootSize, x));
1428
691k
  }
1429
1430
  /// advanceTo - Move to the first interval with stop >= x, or end().
1431
  /// The search is started from the current position, and no earlier positions
1432
  /// can be found. This is much faster than find() for small moves.
1433
26.4M
  void advanceTo(KeyT x) {
1434
26.4M
    if (!valid())
1435
6.27M
      return;
1436
20.1M
    if (branched())
1437
10.2M
      treeAdvanceTo(x);
1438
9.93M
    else
1439
9.93M
      path.leafOffset() =
1440
9.93M
        map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x);
1441
20.1M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::advanceTo(llvm::SlotIndex)
Line
Count
Source
1433
25.9M
  void advanceTo(KeyT x) {
1434
25.9M
    if (!valid())
1435
6.21M
      return;
1436
19.7M
    if (branched())
1437
10.1M
      treeAdvanceTo(x);
1438
9.65M
    else
1439
9.65M
      path.leafOffset() =
1440
9.65M
        map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x);
1441
19.7M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::advanceTo(llvm::SlotIndex)
Line
Count
Source
1433
980
  void advanceTo(KeyT x) {
1434
980
    if (!valid())
1435
2
      return;
1436
978
    if (branched())
1437
8
      treeAdvanceTo(x);
1438
970
    else
1439
970
      path.leafOffset() =
1440
970
        map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x);
1441
978
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::advanceTo(llvm::SlotIndex)
Line
Count
Source
1433
446k
  void advanceTo(KeyT x) {
1434
446k
    if (!valid())
1435
54.6k
      return;
1436
391k
    if (branched())
1437
104k
      treeAdvanceTo(x);
1438
287k
    else
1439
287k
      path.leafOffset() =
1440
287k
        map->rootLeaf().findFrom(path.leafOffset(), map->rootSize, x);
1441
391k
  }
1442
};
1443
1444
/// pathFillFind - Complete path by searching for x.
1445
/// @param x Key to search for.
1446
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1447
void IntervalMap<KeyT, ValT, N, Traits>::
1448
28.6M
const_iterator::pathFillFind(KeyT x) {
1449
28.6M
  IntervalMapImpl::NodeRef NR = path.subtree(path.height());
1450
31.3M
  for (unsigned i = map->height - path.height() - 1; i; 
--i2.64M
) {
1451
2.64M
    unsigned p = NR.get<Branch>().safeFind(0, x);
1452
2.64M
    path.push(NR, p);
1453
2.64M
    NR = NR.subtree(p);
1454
2.64M
  }
1455
28.6M
  path.push(NR, NR.get<Leaf>().safeFind(0, x));
1456
28.6M
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::pathFillFind(llvm::SlotIndex)
Line
Count
Source
1448
28.0M
const_iterator::pathFillFind(KeyT x) {
1449
28.0M
  IntervalMapImpl::NodeRef NR = path.subtree(path.height());
1450
30.6M
  for (unsigned i = map->height - path.height() - 1; i; 
--i2.61M
) {
1451
2.61M
    unsigned p = NR.get<Branch>().safeFind(0, x);
1452
2.61M
    path.push(NR, p);
1453
2.61M
    NR = NR.subtree(p);
1454
2.61M
  }
1455
28.0M
  path.push(NR, NR.get<Leaf>().safeFind(0, x));
1456
28.0M
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::pathFillFind(llvm::SlotIndex)
Line
Count
Source
1448
50
const_iterator::pathFillFind(KeyT x) {
1449
50
  IntervalMapImpl::NodeRef NR = path.subtree(path.height());
1450
50
  for (unsigned i = map->height - path.height() - 1; i; 
--i0
) {
1451
0
    unsigned p = NR.get<Branch>().safeFind(0, x);
1452
0
    path.push(NR, p);
1453
0
    NR = NR.subtree(p);
1454
0
  }
1455
50
  path.push(NR, NR.get<Leaf>().safeFind(0, x));
1456
50
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::pathFillFind(llvm::SlotIndex)
Line
Count
Source
1448
597k
const_iterator::pathFillFind(KeyT x) {
1449
597k
  IntervalMapImpl::NodeRef NR = path.subtree(path.height());
1450
626k
  for (unsigned i = map->height - path.height() - 1; i; 
--i28.7k
) {
1451
28.7k
    unsigned p = NR.get<Branch>().safeFind(0, x);
1452
28.7k
    path.push(NR, p);
1453
28.7k
    NR = NR.subtree(p);
1454
28.7k
  }
1455
597k
  path.push(NR, NR.get<Leaf>().safeFind(0, x));
1456
597k
}
1457
1458
/// treeFind - Find in a branched tree.
1459
/// @param x Key to search for.
1460
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1461
void IntervalMap<KeyT, ValT, N, Traits>::
1462
28.6M
const_iterator::treeFind(KeyT x) {
1463
28.6M
  setRoot(map->rootBranch().findFrom(0, map->rootSize, x));
1464
28.6M
  if (valid())
1465
26.7M
    pathFillFind(x);
1466
28.6M
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::treeFind(llvm::SlotIndex)
Line
Count
Source
1462
28.0M
const_iterator::treeFind(KeyT x) {
1463
28.0M
  setRoot(map->rootBranch().findFrom(0, map->rootSize, x));
1464
28.0M
  if (valid())
1465
26.1M
    pathFillFind(x);
1466
28.0M
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::treeFind(llvm::SlotIndex)
Line
Count
Source
1462
55
const_iterator::treeFind(KeyT x) {
1463
55
  setRoot(map->rootBranch().findFrom(0, map->rootSize, x));
1464
55
  if (valid())
1465
50
    pathFillFind(x);
1466
55
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::treeFind(llvm::SlotIndex)
Line
Count
Source
1462
620k
const_iterator::treeFind(KeyT x) {
1463
620k
  setRoot(map->rootBranch().findFrom(0, map->rootSize, x));
1464
620k
  if (valid())
1465
589k
    pathFillFind(x);
1466
620k
}
1467
1468
/// treeAdvanceTo - Find position after the current one.
1469
/// @param x Key to search for.
1470
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1471
void IntervalMap<KeyT, ValT, N, Traits>::
1472
10.2M
const_iterator::treeAdvanceTo(KeyT x) {
1473
10.2M
  // Can we stay on the same leaf node?
1474
10.2M
  if (!Traits::stopLess(path.leaf<Leaf>().stop(path.leafSize() - 1), x)) {
1475
7.87M
    path.leafOffset() = path.leaf<Leaf>().safeFind(path.leafOffset(), x);
1476
7.87M
    return;
1477
7.87M
  }
1478
2.35M
1479
2.35M
  // Drop the current leaf.
1480
2.35M
  path.pop();
1481
2.35M
1482
2.35M
  // Search towards the root for a usable subtree.
1483
2.35M
  if (path.height()) {
1484
465k
    for (unsigned l = path.height() - 1; l; 
--l5.75k
) {
1485
17.7k
      if (!Traits::stopLess(path.node<Branch>(l).stop(path.offset(l)), x)) {
1486
11.9k
        // The branch node at l+1 is usable
1487
11.9k
        path.offset(l + 1) =
1488
11.9k
          path.node<Branch>(l + 1).safeFind(path.offset(l + 1), x);
1489
11.9k
        return pathFillFind(x);
1490
11.9k
      }
1491
5.75k
      path.pop();
1492
5.75k
    }
1493
460k
    // Is the level-1 Branch usable?
1494
460k
    
if (448k
!Traits::stopLess(map->rootBranch().stop(path.offset(0)), x)448k
) {
1495
339k
      path.offset(1) = path.node<Branch>(1).safeFind(path.offset(1), x);
1496
339k
      return pathFillFind(x);
1497
339k
    }
1498
2.00M
  }
1499
2.00M
1500
2.00M
  // We reached the root.
1501
2.00M
  setRoot(map->rootBranch().findFrom(path.offset(0), map->rootSize, x));
1502
2.00M
  if (valid())
1503
1.56M
    pathFillFind(x);
1504
2.00M
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::treeAdvanceTo(llvm::SlotIndex)
Line
Count
Source
1472
10.1M
const_iterator::treeAdvanceTo(KeyT x) {
1473
10.1M
  // Can we stay on the same leaf node?
1474
10.1M
  if (!Traits::stopLess(path.leaf<Leaf>().stop(path.leafSize() - 1), x)) {
1475
7.77M
    path.leafOffset() = path.leaf<Leaf>().safeFind(path.leafOffset(), x);
1476
7.77M
    return;
1477
7.77M
  }
1478
2.34M
1479
2.34M
  // Drop the current leaf.
1480
2.34M
  path.pop();
1481
2.34M
1482
2.34M
  // Search towards the root for a usable subtree.
1483
2.34M
  if (path.height()) {
1484
465k
    for (unsigned l = path.height() - 1; l; 
--l5.75k
) {
1485
17.7k
      if (!Traits::stopLess(path.node<Branch>(l).stop(path.offset(l)), x)) {
1486
11.9k
        // The branch node at l+1 is usable
1487
11.9k
        path.offset(l + 1) =
1488
11.9k
          path.node<Branch>(l + 1).safeFind(path.offset(l + 1), x);
1489
11.9k
        return pathFillFind(x);
1490
11.9k
      }
1491
5.75k
      path.pop();
1492
5.75k
    }
1493
459k
    // Is the level-1 Branch usable?
1494
459k
    
if (447k
!Traits::stopLess(map->rootBranch().stop(path.offset(0)), x)447k
) {
1495
339k
      path.offset(1) = path.node<Branch>(1).safeFind(path.offset(1), x);
1496
339k
      return pathFillFind(x);
1497
339k
    }
1498
1.99M
  }
1499
1.99M
1500
1.99M
  // We reached the root.
1501
1.99M
  setRoot(map->rootBranch().findFrom(path.offset(0), map->rootSize, x));
1502
1.99M
  if (valid())
1503
1.55M
    pathFillFind(x);
1504
1.99M
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::treeAdvanceTo(llvm::SlotIndex)
Line
Count
Source
1472
8
const_iterator::treeAdvanceTo(KeyT x) {
1473
8
  // Can we stay on the same leaf node?
1474
8
  if (!Traits::stopLess(path.leaf<Leaf>().stop(path.leafSize() - 1), x)) {
1475
4
    path.leafOffset() = path.leaf<Leaf>().safeFind(path.leafOffset(), x);
1476
4
    return;
1477
4
  }
1478
4
1479
4
  // Drop the current leaf.
1480
4
  path.pop();
1481
4
1482
4
  // Search towards the root for a usable subtree.
1483
4
  if (path.height()) {
1484
0
    for (unsigned l = path.height() - 1; l; --l) {
1485
0
      if (!Traits::stopLess(path.node<Branch>(l).stop(path.offset(l)), x)) {
1486
0
        // The branch node at l+1 is usable
1487
0
        path.offset(l + 1) =
1488
0
          path.node<Branch>(l + 1).safeFind(path.offset(l + 1), x);
1489
0
        return pathFillFind(x);
1490
0
      }
1491
0
      path.pop();
1492
0
    }
1493
0
    // Is the level-1 Branch usable?
1494
0
    if (!Traits::stopLess(map->rootBranch().stop(path.offset(0)), x)) {
1495
0
      path.offset(1) = path.node<Branch>(1).safeFind(path.offset(1), x);
1496
0
      return pathFillFind(x);
1497
0
    }
1498
4
  }
1499
4
1500
4
  // We reached the root.
1501
4
  setRoot(map->rootBranch().findFrom(path.offset(0), map->rootSize, x));
1502
4
  if (valid())
1503
0
    pathFillFind(x);
1504
4
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::const_iterator::treeAdvanceTo(llvm::SlotIndex)
Line
Count
Source
1472
104k
const_iterator::treeAdvanceTo(KeyT x) {
1473
104k
  // Can we stay on the same leaf node?
1474
104k
  if (!Traits::stopLess(path.leaf<Leaf>().stop(path.leafSize() - 1), x)) {
1475
94.7k
    path.leafOffset() = path.leaf<Leaf>().safeFind(path.leafOffset(), x);
1476
94.7k
    return;
1477
94.7k
  }
1478
9.61k
1479
9.61k
  // Drop the current leaf.
1480
9.61k
  path.pop();
1481
9.61k
1482
9.61k
  // Search towards the root for a usable subtree.
1483
9.61k
  if (path.height()) {
1484
234
    for (unsigned l = path.height() - 1; l; 
--l0
) {
1485
0
      if (!Traits::stopLess(path.node<Branch>(l).stop(path.offset(l)), x)) {
1486
0
        // The branch node at l+1 is usable
1487
0
        path.offset(l + 1) =
1488
0
          path.node<Branch>(l + 1).safeFind(path.offset(l + 1), x);
1489
0
        return pathFillFind(x);
1490
0
      }
1491
0
      path.pop();
1492
0
    }
1493
234
    // Is the level-1 Branch usable?
1494
234
    if (!Traits::stopLess(map->rootBranch().stop(path.offset(0)), x)) {
1495
208
      path.offset(1) = path.node<Branch>(1).safeFind(path.offset(1), x);
1496
208
      return pathFillFind(x);
1497
208
    }
1498
9.40k
  }
1499
9.40k
1500
9.40k
  // We reached the root.
1501
9.40k
  setRoot(map->rootBranch().findFrom(path.offset(0), map->rootSize, x));
1502
9.40k
  if (valid())
1503
7.80k
    pathFillFind(x);
1504
9.40k
}
1505
1506
//===----------------------------------------------------------------------===//
1507
//---                       IntervalMap::iterator                         ----//
1508
//===----------------------------------------------------------------------===//
1509
1510
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1511
class IntervalMap<KeyT, ValT, N, Traits>::iterator : public const_iterator {
1512
  friend class IntervalMap;
1513
1514
  using IdxPair = IntervalMapImpl::IdxPair;
1515
1516
11.3M
  explicit iterator(IntervalMap &map) : const_iterator(map) {}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::iterator(llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >&)
Line
Count
Source
1516
3.54k
  explicit iterator(IntervalMap &map) : const_iterator(map) {}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::iterator(llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >&)
Line
Count
Source
1516
10.5M
  explicit iterator(IntervalMap &map) : const_iterator(map) {}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::iterator(llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >&)
Line
Count
Source
1516
776k
  explicit iterator(IntervalMap &map) : const_iterator(map) {}
1517
1518
  void setNodeStop(unsigned Level, KeyT Stop);
1519
  bool insertNode(unsigned Level, IntervalMapImpl::NodeRef Node, KeyT Stop);
1520
  template <typename NodeT> bool overflow(unsigned Level);
1521
  void treeInsert(KeyT a, KeyT b, ValT y);
1522
  void eraseNode(unsigned Level);
1523
  void treeErase(bool UpdateRoot = true);
1524
  bool canCoalesceLeft(KeyT Start, ValT x);
1525
  bool canCoalesceRight(KeyT Stop, ValT x);
1526
1527
public:
1528
  /// iterator - Create null iterator.
1529
2.60M
  iterator() = default;
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::iterator()
Line
Count
Source
1529
2.49M
  iterator() = default;
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::iterator()
Line
Count
Source
1529
15
  iterator() = default;
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::iterator()
Line
Count
Source
1529
106k
  iterator() = default;
1530
1531
  /// setStart - Move the start of the current interval.
1532
  /// This may cause coalescing with the previous interval.
1533
  /// @param a New start key, must not overlap the previous interval.
1534
  void setStart(KeyT a);
1535
1536
  /// setStop - Move the end of the current interval.
1537
  /// This may cause coalescing with the following interval.
1538
  /// @param b New stop key, must not overlap the following interval.
1539
  void setStop(KeyT b);
1540
1541
  /// setValue - Change the mapped value of the current interval.
1542
  /// This may cause coalescing with the previous and following intervals.
1543
  /// @param x New value.
1544
  void setValue(ValT x);
1545
1546
  /// setStartUnchecked - Move the start of the current interval without
1547
  /// checking for coalescing or overlaps.
1548
  /// This should only be used when it is known that coalescing is not required.
1549
  /// @param a New start key.
1550
253
  void setStartUnchecked(KeyT a) { this->unsafeStart() = a; }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setStartUnchecked(llvm::SlotIndex)
Line
Count
Source
1550
253
  void setStartUnchecked(KeyT a) { this->unsafeStart() = a; }
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setStartUnchecked(llvm::SlotIndex)
1551
1552
  /// setStopUnchecked - Move the end of the current interval without checking
1553
  /// for coalescing or overlaps.
1554
  /// This should only be used when it is known that coalescing is not required.
1555
  /// @param b New stop key.
1556
237
  void setStopUnchecked(KeyT b) {
1557
237
    this->unsafeStop() = b;
1558
237
    // Update keys in branch nodes as well.
1559
237
    if (this->path.atLastEntry(this->path.height()))
1560
77
      setNodeStop(this->path.height(), b);
1561
237
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setStopUnchecked(llvm::SlotIndex)
Line
Count
Source
1556
45
  void setStopUnchecked(KeyT b) {
1557
45
    this->unsafeStop() = b;
1558
45
    // Update keys in branch nodes as well.
1559
45
    if (this->path.atLastEntry(this->path.height()))
1560
44
      setNodeStop(this->path.height(), b);
1561
45
  }
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setStopUnchecked(llvm::SlotIndex)
Line
Count
Source
1556
192
  void setStopUnchecked(KeyT b) {
1557
192
    this->unsafeStop() = b;
1558
192
    // Update keys in branch nodes as well.
1559
192
    if (this->path.atLastEntry(this->path.height()))
1560
33
      setNodeStop(this->path.height(), b);
1561
192
  }
1562
1563
  /// setValueUnchecked - Change the mapped value of the current interval
1564
  /// without checking for coalescing.
1565
  /// @param x New value.
1566
872
  void setValueUnchecked(ValT x) { this->unsafeValue() = x; }
1567
1568
  /// insert - Insert mapping [a;b] -> y before the current position.
1569
  void insert(KeyT a, KeyT b, ValT y);
1570
1571
  /// erase - Erase the current interval.
1572
  void erase();
1573
1574
13.4M
  iterator &operator++() {
1575
13.4M
    const_iterator::operator++();
1576
13.4M
    return *this;
1577
13.4M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::operator++()
Line
Count
Source
1574
13.4M
  iterator &operator++() {
1575
13.4M
    const_iterator::operator++();
1576
13.4M
    return *this;
1577
13.4M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::operator++()
Line
Count
Source
1574
1.46k
  iterator &operator++() {
1575
1.46k
    const_iterator::operator++();
1576
1.46k
    return *this;
1577
1.46k
  }
1578
1579
  iterator operator++(int) {
1580
    iterator tmp = *this;
1581
    operator++();
1582
    return tmp;
1583
  }
1584
1585
4.11M
  iterator &operator--() {
1586
4.11M
    const_iterator::operator--();
1587
4.11M
    return *this;
1588
4.11M
  }
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::operator--()
Line
Count
Source
1585
4.11M
  iterator &operator--() {
1586
4.11M
    const_iterator::operator--();
1587
4.11M
    return *this;
1588
4.11M
  }
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::operator--()
Line
Count
Source
1585
12
  iterator &operator--() {
1586
12
    const_iterator::operator--();
1587
12
    return *this;
1588
12
  }
1589
1590
  iterator operator--(int) {
1591
    iterator tmp = *this;
1592
    operator--();
1593
    return tmp;
1594
  }
1595
};
1596
1597
/// canCoalesceLeft - Can the current interval coalesce to the left after
1598
/// changing start or value?
1599
/// @param Start New start of current interval.
1600
/// @param Value New value for current interval.
1601
/// @return True when updating the current interval would enable coalescing.
1602
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1603
bool IntervalMap<KeyT, ValT, N, Traits>::
1604
56
iterator::canCoalesceLeft(KeyT Start, ValT Value) {
1605
56
  using namespace IntervalMapImpl;
1606
56
  Path &P = this->path;
1607
56
  if (!this->branched()) {
1608
56
    unsigned i = P.leafOffset();
1609
56
    RootLeaf &Node = P.leaf<RootLeaf>();
1610
56
    return i && 
Node.value(i-1) == Value21
&&
1611
56
                
Traits::adjacent(Node.stop(i-1), Start)3
;
1612
56
  }
1613
0
  // Branched.
1614
0
  if (unsigned i = P.leafOffset()) {
1615
0
    Leaf &Node = P.leaf<Leaf>();
1616
0
    return Node.value(i-1) == Value && Traits::adjacent(Node.stop(i-1), Start);
1617
0
  } else if (NodeRef NR = P.getLeftSibling(P.height())) {
1618
0
    unsigned i = NR.size() - 1;
1619
0
    Leaf &Node = NR.get<Leaf>();
1620
0
    return Node.value(i) == Value && Traits::adjacent(Node.stop(i), Start);
1621
0
  }
1622
0
  return false;
1623
0
}
1624
1625
/// canCoalesceRight - Can the current interval coalesce to the right after
1626
/// changing stop or value?
1627
/// @param Stop New stop of current interval.
1628
/// @param Value New value for current interval.
1629
/// @return True when updating the current interval would enable coalescing.
1630
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1631
bool IntervalMap<KeyT, ValT, N, Traits>::
1632
56
iterator::canCoalesceRight(KeyT Stop, ValT Value) {
1633
56
  using namespace IntervalMapImpl;
1634
56
  Path &P = this->path;
1635
56
  unsigned i = P.leafOffset() + 1;
1636
56
  if (!this->branched()) {
1637
56
    if (i >= P.leafSize())
1638
44
      return false;
1639
12
    RootLeaf &Node = P.leaf<RootLeaf>();
1640
12
    return Node.value(i) == Value && 
Traits::adjacent(Stop, Node.start(i))0
;
1641
12
  }
1642
0
  // Branched.
1643
0
  if (i < P.leafSize()) {
1644
0
    Leaf &Node = P.leaf<Leaf>();
1645
0
    return Node.value(i) == Value && Traits::adjacent(Stop, Node.start(i));
1646
0
  } else if (NodeRef NR = P.getRightSibling(P.height())) {
1647
0
    Leaf &Node = NR.get<Leaf>();
1648
0
    return Node.value(0) == Value && Traits::adjacent(Stop, Node.start(0));
1649
0
  }
1650
0
  return false;
1651
0
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::canCoalesceRight(llvm::SlotIndex, DbgValueLocation)
Line
Count
Source
1632
56
iterator::canCoalesceRight(KeyT Stop, ValT Value) {
1633
56
  using namespace IntervalMapImpl;
1634
56
  Path &P = this->path;
1635
56
  unsigned i = P.leafOffset() + 1;
1636
56
  if (!this->branched()) {
1637
56
    if (i >= P.leafSize())
1638
44
      return false;
1639
12
    RootLeaf &Node = P.leaf<RootLeaf>();
1640
12
    return Node.value(i) == Value && 
Traits::adjacent(Stop, Node.start(i))0
;
1641
12
  }
1642
0
  // Branched.
1643
0
  if (i < P.leafSize()) {
1644
0
    Leaf &Node = P.leaf<Leaf>();
1645
0
    return Node.value(i) == Value && Traits::adjacent(Stop, Node.start(i));
1646
0
  } else if (NodeRef NR = P.getRightSibling(P.height())) {
1647
0
    Leaf &Node = NR.get<Leaf>();
1648
0
    return Node.value(0) == Value && Traits::adjacent(Stop, Node.start(0));
1649
0
  }
1650
0
  return false;
1651
0
}
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::canCoalesceRight(llvm::SlotIndex, unsigned int)
1652
1653
/// setNodeStop - Update the stop key of the current node at level and above.
1654
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1655
void IntervalMap<KeyT, ValT, N, Traits>::
1656
3.71M
iterator::setNodeStop(unsigned Level, KeyT Stop) {
1657
3.71M
  // There are no references to the root node, so nothing to update.
1658
3.71M
  if (!Level)
1659
44
    return;
1660
3.71M
  IntervalMapImpl::Path &P = this->path;
1661
3.71M
  // Update nodes pointing to the current node.
1662
4.06M
  while (--Level) {
1663
831k
    P.node<Branch>(Level).stop(P.offset(Level)) = Stop;
1664
831k
    if (!P.atLastEntry(Level))
1665
487k
      return;
1666
831k
  }
1667
3.71M
  // Update root separately since it has a different layout.
1668
3.71M
  P.node<RootBranch>(Level).stop(P.offset(Level)) = Stop;
1669
3.23M
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setNodeStop(unsigned int, llvm::SlotIndex)
Line
Count
Source
1656
60
iterator::setNodeStop(unsigned Level, KeyT Stop) {
1657
60
  // There are no references to the root node, so nothing to update.
1658
60
  if (!Level)
1659
44
    return;
1660
16
  IntervalMapImpl::Path &P = this->path;
1661
16
  // Update nodes pointing to the current node.
1662
16
  while (--Level) {
1663
0
    P.node<Branch>(Level).stop(P.offset(Level)) = Stop;
1664
0
    if (!P.atLastEntry(Level))
1665
0
      return;
1666
0
  }
1667
16
  // Update root separately since it has a different layout.
1668
16
  P.node<RootBranch>(Level).stop(P.offset(Level)) = Stop;
1669
16
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setNodeStop(unsigned int, llvm::SlotIndex)
Line
Count
Source
1656
3.57M
iterator::setNodeStop(unsigned Level, KeyT Stop) {
1657
3.57M
  // There are no references to the root node, so nothing to update.
1658
3.57M
  if (!Level)
1659
0
    return;
1660
3.57M
  IntervalMapImpl::Path &P = this->path;
1661
3.57M
  // Update nodes pointing to the current node.
1662
3.92M
  while (--Level) {
1663
822k
    P.node<Branch>(Level).stop(P.offset(Level)) = Stop;
1664
822k
    if (!P.atLastEntry(Level))
1665
481k
      return;
1666
822k
  }
1667
3.57M
  // Update root separately since it has a different layout.
1668
3.57M
  P.node<RootBranch>(Level).stop(P.offset(Level)) = Stop;
1669
3.09M
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::setNodeStop(unsigned int, llvm::SlotIndex)
Line
Count
Source
1656
139k
iterator::setNodeStop(unsigned Level, KeyT Stop) {
1657
139k
  // There are no references to the root node, so nothing to update.
1658
139k
  if (!Level)
1659
0
    return;
1660
139k
  IntervalMapImpl::Path &P = this->path;
1661
139k
  // Update nodes pointing to the current node.
1662
141k
  while (--Level) {
1663
8.67k
    P.node<Branch>(Level).stop(P.offset(Level)) = Stop;
1664
8.67k
    if (!P.atLastEntry(Level))
1665
6.51k
      return;
1666
8.67k
  }
1667
139k
  // Update root separately since it has a different layout.
1668
139k
  P.node<RootBranch>(Level).stop(P.offset(Level)) = Stop;
1669
132k
}
1670
1671
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1672
void IntervalMap<KeyT, ValT, N, Traits>::
1673
785
iterator::setStart(KeyT a) {
1674
785
  assert(Traits::nonEmpty(a, this->stop()) && "Cannot move start beyond stop");
1675
785
  KeyT &CurStart = this->unsafeStart();
1676
785
  if (!Traits::startLess(a, CurStart) || 
!canCoalesceLeft(a, this->value())0
) {
1677
785
    CurStart = a;
1678
785
    return;
1679
785
  }
1680
0
  // Coalesce with the interval to the left.
1681
0
  --*this;
1682
0
  a = this->start();
1683
0
  erase();
1684
0
  setStartUnchecked(a);
1685
0
}
1686
1687
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1688
void IntervalMap<KeyT, ValT, N, Traits>::
1689
192
iterator::setStop(KeyT b) {
1690
192
  assert(Traits::nonEmpty(this->start(), b) && "Cannot move stop beyond start");
1691
192
  if (Traits::startLess(b, this->stop()) ||
1692
192
      
!canCoalesceRight(b, this->value())0
) {
1693
192
    setStopUnchecked(b);
1694
192
    return;
1695
192
  }
1696
0
  // Coalesce with interval to the right.
1697
0
  KeyT a = this->start();
1698
0
  erase();
1699
0
  setStartUnchecked(a);
1700
0
}
1701
1702
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1703
void IntervalMap<KeyT, ValT, N, Traits>::
1704
56
iterator::setValue(ValT x) {
1705
56
  setValueUnchecked(x);
1706
56
  if (canCoalesceRight(this->stop(), x)) {
1707
0
    KeyT a = this->start();
1708
0
    erase();
1709
0
    setStartUnchecked(a);
1710
0
  }
1711
56
  if (canCoalesceLeft(this->start(), x)) {
1712
3
    --*this;
1713
3
    KeyT a = this->start();
1714
3
    erase();
1715
3
    setStartUnchecked(a);
1716
3
  }
1717
56
}
1718
1719
/// insertNode - insert a node before the current path at level.
1720
/// Leave the current path pointing at the new node.
1721
/// @param Level path index of the node to be inserted.
1722
/// @param Node The node to be inserted.
1723
/// @param Stop The last index in the new node.
1724
/// @return True if the tree height was increased.
1725
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1726
bool IntervalMap<KeyT, ValT, N, Traits>::
1727
376k
iterator::insertNode(unsigned Level, IntervalMapImpl::NodeRef Node, KeyT Stop) {
1728
376k
  assert(Level && "Cannot insert next to the root");
1729
376k
  bool SplitRoot = false;
1730
376k
  IntervalMap &IM = *this->map;
1731
376k
  IntervalMapImpl::Path &P = this->path;
1732
376k
1733
376k
  if (Level == 1) {
1734
299k
    // Insert into the root branch node.
1735
299k
    if (IM.rootSize < RootBranch::Capacity) {
1736
292k
      IM.rootBranch().insert(P.offset(0), IM.rootSize, Node, Stop);
1737
292k
      P.setSize(0, ++IM.rootSize);
1738
292k
      P.reset(Level);
1739
292k
      return SplitRoot;
1740
292k
    }
1741
6.41k
1742
6.41k
    // We need to split the root while keeping our position.
1743
6.41k
    SplitRoot = true;
1744
6.41k
    IdxPair Offset = IM.splitRoot(P.offset(0));
1745
6.41k
    P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1746
6.41k
1747
6.41k
    // Fall through to insert at the new higher level.
1748
6.41k
    ++Level;
1749
6.41k
  }
1750
376k
1751
376k
  // When inserting before end(), make sure we have a valid path.
1752
376k
  P.legalizeForInsert(--Level);
1753
83.2k
1754
83.2k
  // Insert into the branch node at Level-1.
1755
83.2k
  if (P.size(Level) == Branch::Capacity) {
1756
22.5k
    // Branch node is full, handle handle the overflow.
1757
22.5k
    assert(!SplitRoot && "Cannot overflow after splitting the root");
1758
22.5k
    SplitRoot = overflow<Branch>(Level);
1759
22.5k
    Level += SplitRoot;
1760
22.5k
  }
1761
83.2k
  P.node<Branch>(Level).insert(P.offset(Level), P.size(Level), Node, Stop);
1762
83.2k
  P.setSize(Level, P.size(Level) + 1);
1763
83.2k
  if (P.atLastEntry(Level))
1764
687
    setNodeStop(Level, Stop);
1765
83.2k
  P.reset(Level + 1);
1766
83.2k
  return SplitRoot;
1767
376k
}
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::insertNode(unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::insertNode(unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Line
Count
Source
1727
370k
iterator::insertNode(unsigned Level, IntervalMapImpl::NodeRef Node, KeyT Stop) {
1728
370k
  assert(Level && "Cannot insert next to the root");
1729
370k
  bool SplitRoot = false;
1730
370k
  IntervalMap &IM = *this->map;
1731
370k
  IntervalMapImpl::Path &P = this->path;
1732
370k
1733
370k
  if (Level == 1) {
1734
293k
    // Insert into the root branch node.
1735
293k
    if (IM.rootSize < RootBranch::Capacity) {
1736
287k
      IM.rootBranch().insert(P.offset(0), IM.rootSize, Node, Stop);
1737
287k
      P.setSize(0, ++IM.rootSize);
1738
287k
      P.reset(Level);
1739
287k
      return SplitRoot;
1740
287k
    }
1741
6.35k
1742
6.35k
    // We need to split the root while keeping our position.
1743
6.35k
    SplitRoot = true;
1744
6.35k
    IdxPair Offset = IM.splitRoot(P.offset(0));
1745
6.35k
    P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1746
6.35k
1747
6.35k
    // Fall through to insert at the new higher level.
1748
6.35k
    ++Level;
1749
6.35k
  }
1750
370k
1751
370k
  // When inserting before end(), make sure we have a valid path.
1752
370k
  P.legalizeForInsert(--Level);
1753
82.8k
1754
82.8k
  // Insert into the branch node at Level-1.
1755
82.8k
  if (P.size(Level) == Branch::Capacity) {
1756
22.5k
    // Branch node is full, handle handle the overflow.
1757
22.5k
    assert(!SplitRoot && "Cannot overflow after splitting the root");
1758
22.5k
    SplitRoot = overflow<Branch>(Level);
1759
22.5k
    Level += SplitRoot;
1760
22.5k
  }
1761
82.8k
  P.node<Branch>(Level).insert(P.offset(Level), P.size(Level), Node, Stop);
1762
82.8k
  P.setSize(Level, P.size(Level) + 1);
1763
82.8k
  if (P.atLastEntry(Level))
1764
684
    setNodeStop(Level, Stop);
1765
82.8k
  P.reset(Level + 1);
1766
82.8k
  return SplitRoot;
1767
370k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::insertNode(unsigned int, llvm::IntervalMapImpl::NodeRef, llvm::SlotIndex)
Line
Count
Source
1727
6.08k
iterator::insertNode(unsigned Level, IntervalMapImpl::NodeRef Node, KeyT Stop) {
1728
6.08k
  assert(Level && "Cannot insert next to the root");
1729
6.08k
  bool SplitRoot = false;
1730
6.08k
  IntervalMap &IM = *this->map;
1731
6.08k
  IntervalMapImpl::Path &P = this->path;
1732
6.08k
1733
6.08k
  if (Level == 1) {
1734
5.72k
    // Insert into the root branch node.
1735
5.72k
    if (IM.rootSize < RootBranch::Capacity) {
1736
5.67k
      IM.rootBranch().insert(P.offset(0), IM.rootSize, Node, Stop);
1737
5.67k
      P.setSize(0, ++IM.rootSize);
1738
5.67k
      P.reset(Level);
1739
5.67k
      return SplitRoot;
1740
5.67k
    }
1741
54
1742
54
    // We need to split the root while keeping our position.
1743
54
    SplitRoot = true;
1744
54
    IdxPair Offset = IM.splitRoot(P.offset(0));
1745
54
    P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1746
54
1747
54
    // Fall through to insert at the new higher level.
1748
54
    ++Level;
1749
54
  }
1750
6.08k
1751
6.08k
  // When inserting before end(), make sure we have a valid path.
1752
6.08k
  P.legalizeForInsert(--Level);
1753
413
1754
413
  // Insert into the branch node at Level-1.
1755
413
  if (P.size(Level) == Branch::Capacity) {
1756
94
    // Branch node is full, handle handle the overflow.
1757
94
    assert(!SplitRoot && "Cannot overflow after splitting the root");
1758
94
    SplitRoot = overflow<Branch>(Level);
1759
94
    Level += SplitRoot;
1760
94
  }
1761
413
  P.node<Branch>(Level).insert(P.offset(Level), P.size(Level), Node, Stop);
1762
413
  P.setSize(Level, P.size(Level) + 1);
1763
413
  if (P.atLastEntry(Level))
1764
3
    setNodeStop(Level, Stop);
1765
413
  P.reset(Level + 1);
1766
413
  return SplitRoot;
1767
6.08k
}
1768
1769
// insert
1770
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1771
void IntervalMap<KeyT, ValT, N, Traits>::
1772
15.6M
iterator::insert(KeyT a, KeyT b, ValT y) {
1773
15.6M
  if (this->branched())
1774
4.63M
    return treeInsert(a, b, y);
1775
10.9M
  IntervalMap &IM = *this->map;
1776
10.9M
  IntervalMapImpl::Path &P = this->path;
1777
10.9M
1778
10.9M
  // Try simple root leaf insert.
1779
10.9M
  unsigned Size = IM.rootLeaf().insertFrom(P.leafOffset(), IM.rootSize, a, b, y);
1780
10.9M
1781
10.9M
  // Was the root node insert successful?
1782
10.9M
  if (Size <= RootLeaf::Capacity) {
1783
10.6M
    P.setSize(0, IM.rootSize = Size);
1784
10.6M
    return;
1785
10.6M
  }
1786
312k
1787
312k
  // Root leaf node is full, we must branch.
1788
312k
  IdxPair Offset = IM.branchRoot(P.leafOffset());
1789
312k
  P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1790
312k
1791
312k
  // Now it fits in the new leaf.
1792
312k
  treeInsert(a, b, y);
1793
312k
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::insert(llvm::SlotIndex, llvm::SlotIndex, DbgValueLocation)
Line
Count
Source
1772
1.38k
iterator::insert(KeyT a, KeyT b, ValT y) {
1773
1.38k
  if (this->branched())
1774
34
    return treeInsert(a, b, y);
1775
1.34k
  IntervalMap &IM = *this->map;
1776
1.34k
  IntervalMapImpl::Path &P = this->path;
1777
1.34k
1778
1.34k
  // Try simple root leaf insert.
1779
1.34k
  unsigned Size = IM.rootLeaf().insertFrom(P.leafOffset(), IM.rootSize, a, b, y);
1780
1.34k
1781
1.34k
  // Was the root node insert successful?
1782
1.34k
  if (Size <= RootLeaf::Capacity) {
1783
1.34k
    P.setSize(0, IM.rootSize = Size);
1784
1.34k
    return;
1785
1.34k
  }
1786
5
1787
5
  // Root leaf node is full, we must branch.
1788
5
  IdxPair Offset = IM.branchRoot(P.leafOffset());
1789
5
  P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1790
5
1791
5
  // Now it fits in the new leaf.
1792
5
  treeInsert(a, b, y);
1793
5
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::insert(llvm::SlotIndex, llvm::SlotIndex, llvm::LiveInterval*)
Line
Count
Source
1772
14.9M
iterator::insert(KeyT a, KeyT b, ValT y) {
1773
14.9M
  if (this->branched())
1774
4.03M
    return treeInsert(a, b, y);
1775
10.9M
  IntervalMap &IM = *this->map;
1776
10.9M
  IntervalMapImpl::Path &P = this->path;
1777
10.9M
1778
10.9M
  // Try simple root leaf insert.
1779
10.9M
  unsigned Size = IM.rootLeaf().insertFrom(P.leafOffset(), IM.rootSize, a, b, y);
1780
10.9M
1781
10.9M
  // Was the root node insert successful?
1782
10.9M
  if (Size <= RootLeaf::Capacity) {
1783
10.6M
    P.setSize(0, IM.rootSize = Size);
1784
10.6M
    return;
1785
10.6M
  }
1786
300k
1787
300k
  // Root leaf node is full, we must branch.
1788
300k
  IdxPair Offset = IM.branchRoot(P.leafOffset());
1789
300k
  P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1790
300k
1791
300k
  // Now it fits in the new leaf.
1792
300k
  treeInsert(a, b, y);
1793
300k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::insert(llvm::SlotIndex, llvm::SlotIndex, unsigned int)
Line
Count
Source
1772
642k
iterator::insert(KeyT a, KeyT b, ValT y) {
1773
642k
  if (this->branched())
1774
598k
    return treeInsert(a, b, y);
1775
44.1k
  IntervalMap &IM = *this->map;
1776
44.1k
  IntervalMapImpl::Path &P = this->path;
1777
44.1k
1778
44.1k
  // Try simple root leaf insert.
1779
44.1k
  unsigned Size = IM.rootLeaf().insertFrom(P.leafOffset(), IM.rootSize, a, b, y);
1780
44.1k
1781
44.1k
  // Was the root node insert successful?
1782
44.1k
  if (Size <= RootLeaf::Capacity) {
1783
31.3k
    P.setSize(0, IM.rootSize = Size);
1784
31.3k
    return;
1785
31.3k
  }
1786
12.7k
1787
12.7k
  // Root leaf node is full, we must branch.
1788
12.7k
  IdxPair Offset = IM.branchRoot(P.leafOffset());
1789
12.7k
  P.replaceRoot(&IM.rootBranch(), IM.rootSize, Offset);
1790
12.7k
1791
12.7k
  // Now it fits in the new leaf.
1792
12.7k
  treeInsert(a, b, y);
1793
12.7k
}
1794
1795
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1796
void IntervalMap<KeyT, ValT, N, Traits>::
1797
4.95M
iterator::treeInsert(KeyT a, KeyT b, ValT y) {
1798
4.95M
  using namespace IntervalMapImpl;
1799
4.95M
  Path &P = this->path;
1800
4.95M
1801
4.95M
  if (!P.valid())
1802
911k
    P.legalizeForInsert(this->map->height);
1803
4.95M
1804
4.95M
  // Check if this insertion will extend the node to the left.
1805
4.95M
  if (P.leafOffset() == 0 && 
Traits::startLess(a, P.leaf<Leaf>().start(0))366k
) {
1806
366k
    // Node is growing to the left, will it affect a left sibling node?
1807
366k
    if (NodeRef Sib = P.getLeftSibling(P.height())) {
1808
275k
      Leaf &SibLeaf = Sib.get<Leaf>();
1809
275k
      unsigned SibOfs = Sib.size() - 1;
1810
275k
      if (SibLeaf.value(SibOfs) == y &&
1811
275k
          
Traits::adjacent(SibLeaf.stop(SibOfs), a)97.9k
) {
1812
59.8k
        // This insertion will coalesce with the last entry in SibLeaf. We can
1813
59.8k
        // handle it in two ways:
1814
59.8k
        //  1. Extend SibLeaf.stop to b and be done, or
1815
59.8k
        //  2. Extend a to SibLeaf, erase the SibLeaf entry and continue.
1816
59.8k
        // We prefer 1., but need 2 when coalescing to the right as well.
1817
59.8k
        Leaf &CurLeaf = P.leaf<Leaf>();
1818
59.8k
        P.moveLeft(P.height());
1819
59.8k
        if (Traits::stopLess(b, CurLeaf.start(0)) &&
1820
59.8k
            (y != CurLeaf.value(0) || 
!Traits::adjacent(b, CurLeaf.start(0))44.2k
)) {
1821
40.4k
          // Easy, just extend SibLeaf and we're done.
1822
40.4k
          setNodeStop(P.height(), SibLeaf.stop(SibOfs) = b);
1823
40.4k
          return;
1824
40.4k
        } else {
1825
19.4k
          // We have both left and right coalescing. Erase the old SibLeaf entry
1826
19.4k
          // and continue inserting the larger interval.
1827
19.4k
          a = SibLeaf.start(SibOfs);
1828
19.4k
          treeErase(/* UpdateRoot= */false);
1829
19.4k
        }
1830
59.8k
      }
1831
275k
    } else {
1832
91.2k
      // No left sibling means we are at begin(). Update cached bound.
1833
91.2k
      this->map->rootBranchStart() = a;
1834
91.2k
    }
1835
366k
  }
1836
4.95M
1837
4.95M
  // When we are inserting at the end of a leaf node, we must update stops.
1838
4.95M
  unsigned Size = P.leafSize();
1839
4.91M
  bool Grow = P.leafOffset() == Size;
1840
4.91M
  Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), Size, a, b, y);
1841
4.91M
1842
4.91M
  // Leaf insertion unsuccessful? Overflow and try again.
1843
4.91M
  if (Size > Leaf::Capacity) {
1844
1.07M
    overflow<Leaf>(P.height());
1845
1.07M
    Grow = P.leafOffset() == P.leafSize();
1846
1.07M
    Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), P.leafSize(), a, b, y);
1847
1.07M
    assert(Size <= Leaf::Capacity && "overflow() didn't make room");
1848
1.07M
  }
1849
4.91M
1850
4.91M
  // Inserted, update offset and leaf size.
1851
4.91M
  P.setSize(P.height(), Size);
1852
4.91M
1853
4.91M
  // Insert was the last node entry, update stops.
1854
4.91M
  if (Grow)
1855
1.10M
    setNodeStop(P.height(), b);
1856
4.91M
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::treeInsert(llvm::SlotIndex, llvm::SlotIndex, DbgValueLocation)
Line
Count
Source
1797
39
iterator::treeInsert(KeyT a, KeyT b, ValT y) {
1798
39
  using namespace IntervalMapImpl;
1799
39
  Path &P = this->path;
1800
39
1801
39
  if (!P.valid())
1802
11
    P.legalizeForInsert(this->map->height);
1803
39
1804
39
  // Check if this insertion will extend the node to the left.
1805
39
  if (P.leafOffset() == 0 && 
Traits::startLess(a, P.leaf<Leaf>().start(0))0
) {
1806
0
    // Node is growing to the left, will it affect a left sibling node?
1807
0
    if (NodeRef Sib = P.getLeftSibling(P.height())) {
1808
0
      Leaf &SibLeaf = Sib.get<Leaf>();
1809
0
      unsigned SibOfs = Sib.size() - 1;
1810
0
      if (SibLeaf.value(SibOfs) == y &&
1811
0
          Traits::adjacent(SibLeaf.stop(SibOfs), a)) {
1812
0
        // This insertion will coalesce with the last entry in SibLeaf. We can
1813
0
        // handle it in two ways:
1814
0
        //  1. Extend SibLeaf.stop to b and be done, or
1815
0
        //  2. Extend a to SibLeaf, erase the SibLeaf entry and continue.
1816
0
        // We prefer 1., but need 2 when coalescing to the right as well.
1817
0
        Leaf &CurLeaf = P.leaf<Leaf>();
1818
0
        P.moveLeft(P.height());
1819
0
        if (Traits::stopLess(b, CurLeaf.start(0)) &&
1820
0
            (y != CurLeaf.value(0) || !Traits::adjacent(b, CurLeaf.start(0)))) {
1821
0
          // Easy, just extend SibLeaf and we're done.
1822
0
          setNodeStop(P.height(), SibLeaf.stop(SibOfs) = b);
1823
0
          return;
1824
0
        } else {
1825
0
          // We have both left and right coalescing. Erase the old SibLeaf entry
1826
0
          // and continue inserting the larger interval.
1827
0
          a = SibLeaf.start(SibOfs);
1828
0
          treeErase(/* UpdateRoot= */false);
1829
0
        }
1830
0
      }
1831
0
    } else {
1832
0
      // No left sibling means we are at begin(). Update cached bound.
1833
0
      this->map->rootBranchStart() = a;
1834
0
    }
1835
0
  }
1836
39
1837
39
  // When we are inserting at the end of a leaf node, we must update stops.
1838
39
  unsigned Size = P.leafSize();
1839
39
  bool Grow = P.leafOffset() == Size;
1840
39
  Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), Size, a, b, y);
1841
39
1842
39
  // Leaf insertion unsuccessful? Overflow and try again.
1843
39
  if (Size > Leaf::Capacity) {
1844
0
    overflow<Leaf>(P.height());
1845
0
    Grow = P.leafOffset() == P.leafSize();
1846
0
    Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), P.leafSize(), a, b, y);
1847
0
    assert(Size <= Leaf::Capacity && "overflow() didn't make room");
1848
0
  }
1849
39
1850
39
  // Inserted, update offset and leaf size.
1851
39
  P.setSize(P.height(), Size);
1852
39
1853
39
  // Insert was the last node entry, update stops.
1854
39
  if (Grow)
1855
16
    setNodeStop(P.height(), b);
1856
39
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::treeInsert(llvm::SlotIndex, llvm::SlotIndex, llvm::LiveInterval*)
Line
Count
Source
1797
4.33M
iterator::treeInsert(KeyT a, KeyT b, ValT y) {
1798
4.33M
  using namespace IntervalMapImpl;
1799
4.33M
  Path &P = this->path;
1800
4.33M
1801
4.33M
  if (!P.valid())
1802
881k
    P.legalizeForInsert(this->map->height);
1803
4.33M
1804
4.33M
  // Check if this insertion will extend the node to the left.
1805
4.33M
  if (P.leafOffset() == 0 && 
Traits::startLess(a, P.leaf<Leaf>().start(0))294k
) {
1806
294k
    // Node is growing to the left, will it affect a left sibling node?
1807
294k
    if (NodeRef Sib = P.getLeftSibling(P.height())) {
1808
204k
      Leaf &SibLeaf = Sib.get<Leaf>();
1809
204k
      unsigned SibOfs = Sib.size() - 1;
1810
204k
      if (SibLeaf.value(SibOfs) == y &&
1811
204k
          
Traits::adjacent(SibLeaf.stop(SibOfs), a)27.0k
) {
1812
15.3k
        // This insertion will coalesce with the last entry in SibLeaf. We can
1813
15.3k
        // handle it in two ways:
1814
15.3k
        //  1. Extend SibLeaf.stop to b and be done, or
1815
15.3k
        //  2. Extend a to SibLeaf, erase the SibLeaf entry and continue.
1816
15.3k
        // We prefer 1., but need 2 when coalescing to the right as well.
1817
15.3k
        Leaf &CurLeaf = P.leaf<Leaf>();
1818
15.3k
        P.moveLeft(P.height());
1819
15.3k
        if (Traits::stopLess(b, CurLeaf.start(0)) &&
1820
15.3k
            (y != CurLeaf.value(0) || 
!Traits::adjacent(b, CurLeaf.start(0))0
)) {
1821
15.3k
          // Easy, just extend SibLeaf and we're done.
1822
15.3k
          setNodeStop(P.height(), SibLeaf.stop(SibOfs) = b);
1823
15.3k
          return;
1824
15.3k
        } else {
1825
0
          // We have both left and right coalescing. Erase the old SibLeaf entry
1826
0
          // and continue inserting the larger interval.
1827
0
          a = SibLeaf.start(SibOfs);
1828
0
          treeErase(/* UpdateRoot= */false);
1829
0
        }
1830
15.3k
      }
1831
204k
    } else {
1832
90.7k
      // No left sibling means we are at begin(). Update cached bound.
1833
90.7k
      this->map->rootBranchStart() = a;
1834
90.7k
    }
1835
294k
  }
1836
4.33M
1837
4.33M
  // When we are inserting at the end of a leaf node, we must update stops.
1838
4.33M
  unsigned Size = P.leafSize();
1839
4.32M
  bool Grow = P.leafOffset() == Size;
1840
4.32M
  Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), Size, a, b, y);
1841
4.32M
1842
4.32M
  // Leaf insertion unsuccessful? Overflow and try again.
1843
4.32M
  if (Size > Leaf::Capacity) {
1844
1.04M
    overflow<Leaf>(P.height());
1845
1.04M
    Grow = P.leafOffset() == P.leafSize();
1846
1.04M
    Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), P.leafSize(), a, b, y);
1847
1.04M
    assert(Size <= Leaf::Capacity && "overflow() didn't make room");
1848
1.04M
  }
1849
4.32M
1850
4.32M
  // Inserted, update offset and leaf size.
1851
4.32M
  P.setSize(P.height(), Size);
1852
4.32M
1853
4.32M
  // Insert was the last node entry, update stops.
1854
4.32M
  if (Grow)
1855
1.06M
    setNodeStop(P.height(), b);
1856
4.32M
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::treeInsert(llvm::SlotIndex, llvm::SlotIndex, unsigned int)
Line
Count
Source
1797
610k
iterator::treeInsert(KeyT a, KeyT b, ValT y) {
1798
610k
  using namespace IntervalMapImpl;
1799
610k
  Path &P = this->path;
1800
610k
1801
610k
  if (!P.valid())
1802
30.5k
    P.legalizeForInsert(this->map->height);
1803
610k
1804
610k
  // Check if this insertion will extend the node to the left.
1805
610k
  if (P.leafOffset() == 0 && 
Traits::startLess(a, P.leaf<Leaf>().start(0))71.9k
) {
1806
71.9k
    // Node is growing to the left, will it affect a left sibling node?
1807
71.9k
    if (NodeRef Sib = P.getLeftSibling(P.height())) {
1808
71.3k
      Leaf &SibLeaf = Sib.get<Leaf>();
1809
71.3k
      unsigned SibOfs = Sib.size() - 1;
1810
71.3k
      if (SibLeaf.value(SibOfs) == y &&
1811
71.3k
          
Traits::adjacent(SibLeaf.stop(SibOfs), a)70.8k
) {
1812
44.4k
        // This insertion will coalesce with the last entry in SibLeaf. We can
1813
44.4k
        // handle it in two ways:
1814
44.4k
        //  1. Extend SibLeaf.stop to b and be done, or
1815
44.4k
        //  2. Extend a to SibLeaf, erase the SibLeaf entry and continue.
1816
44.4k
        // We prefer 1., but need 2 when coalescing to the right as well.
1817
44.4k
        Leaf &CurLeaf = P.leaf<Leaf>();
1818
44.4k
        P.moveLeft(P.height());
1819
44.4k
        if (Traits::stopLess(b, CurLeaf.start(0)) &&
1820
44.4k
            (y != CurLeaf.value(0) || 
!Traits::adjacent(b, CurLeaf.start(0))44.2k
)) {
1821
25.0k
          // Easy, just extend SibLeaf and we're done.
1822
25.0k
          setNodeStop(P.height(), SibLeaf.stop(SibOfs) = b);
1823
25.0k
          return;
1824
25.0k
        } else {
1825
19.4k
          // We have both left and right coalescing. Erase the old SibLeaf entry
1826
19.4k
          // and continue inserting the larger interval.
1827
19.4k
          a = SibLeaf.start(SibOfs);
1828
19.4k
          treeErase(/* UpdateRoot= */false);
1829
19.4k
        }
1830
44.4k
      }
1831
71.3k
    } else {
1832
590
      // No left sibling means we are at begin(). Update cached bound.
1833
590
      this->map->rootBranchStart() = a;
1834
590
    }
1835
71.9k
  }
1836
610k
1837
610k
  // When we are inserting at the end of a leaf node, we must update stops.
1838
610k
  unsigned Size = P.leafSize();
1839
585k
  bool Grow = P.leafOffset() == Size;
1840
585k
  Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), Size, a, b, y);
1841
585k
1842
585k
  // Leaf insertion unsuccessful? Overflow and try again.
1843
585k
  if (Size > Leaf::Capacity) {
1844
25.2k
    overflow<Leaf>(P.height());
1845
25.2k
    Grow = P.leafOffset() == P.leafSize();
1846
25.2k
    Size = P.leaf<Leaf>().insertFrom(P.leafOffset(), P.leafSize(), a, b, y);
1847
25.2k
    assert(Size <= Leaf::Capacity && "overflow() didn't make room");
1848
25.2k
  }
1849
585k
1850
585k
  // Inserted, update offset and leaf size.
1851
585k
  P.setSize(P.height(), Size);
1852
585k
1853
585k
  // Insert was the last node entry, update stops.
1854
585k
  if (Grow)
1855
39.1k
    setNodeStop(P.height(), b);
1856
585k
}
1857
1858
/// erase - erase the current interval and move to the next position.
1859
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1860
void IntervalMap<KeyT, ValT, N, Traits>::
1861
1.34M
iterator::erase() {
1862
1.34M
  IntervalMap &IM = *this->map;
1863
1.34M
  IntervalMapImpl::Path &P = this->path;
1864
1.34M
  assert(P.valid() && "Cannot erase end()");
1865
1.34M
  if (this->branched())
1866
398k
    return treeErase();
1867
945k
  IM.rootLeaf().erase(P.leafOffset(), IM.rootSize);
1868
945k
  P.setSize(0, --IM.rootSize);
1869
945k
}
llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::erase()
Line
Count
Source
1861
3
iterator::erase() {
1862
3
  IntervalMap &IM = *this->map;
1863
3
  IntervalMapImpl::Path &P = this->path;
1864
3
  assert(P.valid() && "Cannot erase end()");
1865
3
  if (this->branched())
1866
0
    return treeErase();
1867
3
  IM.rootLeaf().erase(P.leafOffset(), IM.rootSize);
1868
3
  P.setSize(0, --IM.rootSize);
1869
3
}
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::erase()
Line
Count
Source
1861
1.34M
iterator::erase() {
1862
1.34M
  IntervalMap &IM = *this->map;
1863
1.34M
  IntervalMapImpl::Path &P = this->path;
1864
1.34M
  assert(P.valid() && "Cannot erase end()");
1865
1.34M
  if (this->branched())
1866
398k
    return treeErase();
1867
945k
  IM.rootLeaf().erase(P.leafOffset(), IM.rootSize);
1868
945k
  P.setSize(0, --IM.rootSize);
1869
945k
}
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::erase()
1870
1871
/// treeErase - erase() for a branched tree.
1872
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1873
void IntervalMap<KeyT, ValT, N, Traits>::
1874
418k
iterator::treeErase(bool UpdateRoot) {
1875
418k
  IntervalMap &IM = *this->map;
1876
418k
  IntervalMapImpl::Path &P = this->path;
1877
418k
  Leaf &Node = P.leaf<Leaf>();
1878
418k
1879
418k
  // Nodes are not allowed to become empty.
1880
418k
  if (P.leafSize() == 1) {
1881
33.4k
    IM.deleteNode(&Node);
1882
33.4k
    eraseNode(IM.height);
1883
33.4k
    // Update rootBranchStart if we erased begin().
1884
33.4k
    if (UpdateRoot && 
IM.branched()32.1k
&&
P.valid()22.4k
&&
P.atBegin()20.0k
)
1885
17.1k
      IM.rootBranchStart() = P.leaf<Leaf>().start(0);
1886
33.4k
    return;
1887
33.4k
  }
1888
384k
1889
384k
  // Erase current entry.
1890
384k
  Node.erase(P.leafOffset(), P.leafSize());
1891
384k
  unsigned NewSize = P.leafSize() - 1;
1892
384k
  P.setSize(IM.height, NewSize);
1893
384k
  // When we erase the last entry, update stop and move to a legal position.
1894
384k
  if (P.leafOffset() == NewSize) {
1895
75.5k
    setNodeStop(IM.height, Node.stop(NewSize - 1));
1896
75.5k
    P.moveRight(IM.height);
1897
309k
  } else if (UpdateRoot && P.atBegin())
1898
150k
    IM.rootBranchStart() = P.leaf<Leaf>().start(0);
1899
384k
}
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::treeErase(bool)
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::treeErase(bool)
Line
Count
Source
1874
398k
iterator::treeErase(bool UpdateRoot) {
1875
398k
  IntervalMap &IM = *this->map;
1876
398k
  IntervalMapImpl::Path &P = this->path;
1877
398k
  Leaf &Node = P.leaf<Leaf>();
1878
398k
1879
398k
  // Nodes are not allowed to become empty.
1880
398k
  if (P.leafSize() == 1) {
1881
32.1k
    IM.deleteNode(&Node);
1882
32.1k
    eraseNode(IM.height);
1883
32.1k
    // Update rootBranchStart if we erased begin().
1884
32.1k
    if (UpdateRoot && IM.branched() && 
P.valid()22.4k
&&
P.atBegin()20.0k
)
1885
17.1k
      IM.rootBranchStart() = P.leaf<Leaf>().start(0);
1886
32.1k
    return;
1887
32.1k
  }
1888
366k
1889
366k
  // Erase current entry.
1890
366k
  Node.erase(P.leafOffset(), P.leafSize());
1891
366k
  unsigned NewSize = P.leafSize() - 1;
1892
366k
  P.setSize(IM.height, NewSize);
1893
366k
  // When we erase the last entry, update stop and move to a legal position.
1894
366k
  if (P.leafOffset() == NewSize) {
1895
57.4k
    setNodeStop(IM.height, Node.stop(NewSize - 1));
1896
57.4k
    P.moveRight(IM.height);
1897
309k
  } else if (UpdateRoot && P.atBegin())
1898
150k
    IM.rootBranchStart() = P.leaf<Leaf>().start(0);
1899
366k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::treeErase(bool)
Line
Count
Source
1874
19.4k
iterator::treeErase(bool UpdateRoot) {
1875
19.4k
  IntervalMap &IM = *this->map;
1876
19.4k
  IntervalMapImpl::Path &P = this->path;
1877
19.4k
  Leaf &Node = P.leaf<Leaf>();
1878
19.4k
1879
19.4k
  // Nodes are not allowed to become empty.
1880
19.4k
  if (P.leafSize() == 1) {
1881
1.34k
    IM.deleteNode(&Node);
1882
1.34k
    eraseNode(IM.height);
1883
1.34k
    // Update rootBranchStart if we erased begin().
1884
1.34k
    if (UpdateRoot && 
IM.branched()0
&&
P.valid()0
&&
P.atBegin()0
)
1885
0
      IM.rootBranchStart() = P.leaf<Leaf>().start(0);
1886
1.34k
    return;
1887
1.34k
  }
1888
18.0k
1889
18.0k
  // Erase current entry.
1890
18.0k
  Node.erase(P.leafOffset(), P.leafSize());
1891
18.0k
  unsigned NewSize = P.leafSize() - 1;
1892
18.0k
  P.setSize(IM.height, NewSize);
1893
18.0k
  // When we erase the last entry, update stop and move to a legal position.
1894
18.0k
  if (P.leafOffset() == NewSize) {
1895
18.0k
    setNodeStop(IM.height, Node.stop(NewSize - 1));
1896
18.0k
    P.moveRight(IM.height);
1897
18.0k
  } else 
if (0
UpdateRoot0
&&
P.atBegin()0
)
1898
0
    IM.rootBranchStart() = P.leaf<Leaf>().start(0);
1899
18.0k
}
1900
1901
/// eraseNode - Erase the current node at Level from its parent and move path to
1902
/// the first entry of the next sibling node.
1903
/// The node must be deallocated by the caller.
1904
/// @param Level 1..height, the root node cannot be erased.
1905
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1906
void IntervalMap<KeyT, ValT, N, Traits>::
1907
33.6k
iterator::eraseNode(unsigned Level) {
1908
33.6k
  assert(Level && "Cannot erase root node");
1909
33.6k
  IntervalMap &IM = *this->map;
1910
33.6k
  IntervalMapImpl::Path &P = this->path;
1911
33.6k
1912
33.6k
  if (--Level == 0) {
1913
31.2k
    IM.rootBranch().erase(P.offset(0), IM.rootSize);
1914
31.2k
    P.setSize(0, --IM.rootSize);
1915
31.2k
    // If this cleared the root, switch to height=0.
1916
31.2k
    if (IM.empty()) {
1917
9.71k
      IM.switchRootToLeaf();
1918
9.71k
      this->setRoot(0);
1919
9.71k
      return;
1920
9.71k
    }
1921
2.46k
  } else {
1922
2.46k
    // Remove node ref from branch node at Level.
1923
2.46k
    Branch &Parent = P.node<Branch>(Level);
1924
2.46k
    if (P.size(Level) == 1) {
1925
205
      // Branch node became empty, remove it recursively.
1926
205
      IM.deleteNode(&Parent);
1927
205
      eraseNode(Level);
1928
2.25k
    } else {
1929
2.25k
      // Branch node won't become empty.
1930
2.25k
      Parent.erase(P.offset(Level), P.size(Level));
1931
2.25k
      unsigned NewSize = P.size(Level) - 1;
1932
2.25k
      P.setSize(Level, NewSize);
1933
2.25k
      // If we removed the last branch, update stop and move to a legal pos.
1934
2.25k
      if (P.offset(Level) == NewSize) {
1935
90
        setNodeStop(Level, Parent.stop(NewSize - 1));
1936
90
        P.moveRight(Level);
1937
90
      }
1938
2.25k
    }
1939
2.46k
  }
1940
33.6k
  // Update path cache for the new right sibling position.
1941
33.6k
  
if (23.9k
P.valid()23.9k
) {
1942
21.5k
    P.reset(Level + 1);
1943
21.5k
    P.offset(Level + 1) = 0;
1944
21.5k
  }
1945
23.9k
}
Unexecuted instantiation: llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::eraseNode(unsigned int)
llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::eraseNode(unsigned int)
Line
Count
Source
1907
32.3k
iterator::eraseNode(unsigned Level) {
1908
32.3k
  assert(Level && "Cannot erase root node");
1909
32.3k
  IntervalMap &IM = *this->map;
1910
32.3k
  IntervalMapImpl::Path &P = this->path;
1911
32.3k
1912
32.3k
  if (--Level == 0) {
1913
30.1k
    IM.rootBranch().erase(P.offset(0), IM.rootSize);
1914
30.1k
    P.setSize(0, --IM.rootSize);
1915
30.1k
    // If this cleared the root, switch to height=0.
1916
30.1k
    if (IM.empty()) {
1917
9.71k
      IM.switchRootToLeaf();
1918
9.71k
      this->setRoot(0);
1919
9.71k
      return;
1920
9.71k
    }
1921
2.22k
  } else {
1922
2.22k
    // Remove node ref from branch node at Level.
1923
2.22k
    Branch &Parent = P.node<Branch>(Level);
1924
2.22k
    if (P.size(Level) == 1) {
1925
201
      // Branch node became empty, remove it recursively.
1926
201
      IM.deleteNode(&Parent);
1927
201
      eraseNode(Level);
1928
2.02k
    } else {
1929
2.02k
      // Branch node won't become empty.
1930
2.02k
      Parent.erase(P.offset(Level), P.size(Level));
1931
2.02k
      unsigned NewSize = P.size(Level) - 1;
1932
2.02k
      P.setSize(Level, NewSize);
1933
2.02k
      // If we removed the last branch, update stop and move to a legal pos.
1934
2.02k
      if (P.offset(Level) == NewSize) {
1935
44
        setNodeStop(Level, Parent.stop(NewSize - 1));
1936
44
        P.moveRight(Level);
1937
44
      }
1938
2.02k
    }
1939
2.22k
  }
1940
32.3k
  // Update path cache for the new right sibling position.
1941
32.3k
  
if (22.6k
P.valid()22.6k
) {
1942
20.2k
    P.reset(Level + 1);
1943
20.2k
    P.offset(Level + 1) = 0;
1944
20.2k
  }
1945
22.6k
}
llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::eraseNode(unsigned int)
Line
Count
Source
1907
1.35k
iterator::eraseNode(unsigned Level) {
1908
1.35k
  assert(Level && "Cannot erase root node");
1909
1.35k
  IntervalMap &IM = *this->map;
1910
1.35k
  IntervalMapImpl::Path &P = this->path;
1911
1.35k
1912
1.35k
  if (--Level == 0) {
1913
1.11k
    IM.rootBranch().erase(P.offset(0), IM.rootSize);
1914
1.11k
    P.setSize(0, --IM.rootSize);
1915
1.11k
    // If this cleared the root, switch to height=0.
1916
1.11k
    if (IM.empty()) {
1917
0
      IM.switchRootToLeaf();
1918
0
      this->setRoot(0);
1919
0
      return;
1920
0
    }
1921
235
  } else {
1922
235
    // Remove node ref from branch node at Level.
1923
235
    Branch &Parent = P.node<Branch>(Level);
1924
235
    if (P.size(Level) == 1) {
1925
4
      // Branch node became empty, remove it recursively.
1926
4
      IM.deleteNode(&Parent);
1927
4
      eraseNode(Level);
1928
231
    } else {
1929
231
      // Branch node won't become empty.
1930
231
      Parent.erase(P.offset(Level), P.size(Level));
1931
231
      unsigned NewSize = P.size(Level) - 1;
1932
231
      P.setSize(Level, NewSize);
1933
231
      // If we removed the last branch, update stop and move to a legal pos.
1934
231
      if (P.offset(Level) == NewSize) {
1935
46
        setNodeStop(Level, Parent.stop(NewSize - 1));
1936
46
        P.moveRight(Level);
1937
46
      }
1938
231
    }
1939
235
  }
1940
1.35k
  // Update path cache for the new right sibling position.
1941
1.35k
  if (P.valid()) {
1942
1.35k
    P.reset(Level + 1);
1943
1.35k
    P.offset(Level + 1) = 0;
1944
1.35k
  }
1945
1.35k
}
1946
1947
/// overflow - Distribute entries of the current node evenly among
1948
/// its siblings and ensure that the current node is not full.
1949
/// This may require allocating a new node.
1950
/// @tparam NodeT The type of node at Level (Leaf or Branch).
1951
/// @param Level path index of the overflowing node.
1952
/// @return True when the tree height was changed.
1953
template <typename KeyT, typename ValT, unsigned N, typename Traits>
1954
template <typename NodeT>
1955
bool IntervalMap<KeyT, ValT, N, Traits>::
1956
1.09M
iterator::overflow(unsigned Level) {
1957
1.09M
  using namespace IntervalMapImpl;
1958
1.09M
  Path &P = this->path;
1959
1.09M
  unsigned CurSize[4];
1960
1.09M
  NodeT *Node[4];
1961
1.09M
  unsigned Nodes = 0;
1962
1.09M
  unsigned Elements = 0;
1963
1.09M
  unsigned Offset = P.offset(Level);
1964
1.09M
1965
1.09M
  // Do we have a left sibling?
1966
1.09M
  NodeRef LeftSib = P.getLeftSibling(Level);
1967
1.09M
  if (LeftSib) {
1968
922k
    Offset += Elements = CurSize[Nodes] = LeftSib.size();
1969
922k
    Node[Nodes++] = &LeftSib.get<NodeT>();
1970
922k
  }
1971
1.09M
1972
1.09M
  // Current node.
1973
1.09M
  Elements += CurSize[Nodes] = P.size(Level);
1974
1.09M
  Node[Nodes++] = &P.node<NodeT>(Level);
1975
1.09M
1976
1.09M
  // Do we have a right sibling?
1977
1.09M
  NodeRef RightSib = P.getRightSibling(Level);
1978
1.09M
  if (RightSib) {
1979
482k
    Elements += CurSize[Nodes] = RightSib.size();
1980
482k
    Node[Nodes++] = &RightSib.get<NodeT>();
1981
482k
  }
1982
1.09M
1983
1.09M
  // Do we need to allocate a new node?
1984
1.09M
  unsigned NewNode = 0;
1985
1.09M
  if (Elements + 1 > Nodes * NodeT::Capacity) {
1986
376k
    // Insert NewNode at the penultimate position, or after a single node.
1987
376k
    NewNode = Nodes == 1 ? 
17.47k
:
Nodes - 1368k
;
1988
376k
    CurSize[Nodes] = CurSize[NewNode];
1989
376k
    Node[Nodes] = Node[NewNode];
1990
376k
    CurSize[NewNode] = 0;
1991
376k
    Node[NewNode] = this->map->template newNode<NodeT>();
1992
376k
    ++Nodes;
1993
376k
  }
1994
1.09M
1995
1.09M
  // Compute the new element distribution.
1996
1.09M
  unsigned NewSize[4];
1997
1.09M
  IdxPair NewOffset = distribute(Nodes, Elements, NodeT::Capacity,
1998
1.09M
                                 CurSize, NewSize, Offset, true);
1999
1.09M
  adjustSiblingSizes(Node, Nodes, CurSize, NewSize);
2000
1.09M
2001
1.09M
  // Move current location to the leftmost node.
2002
1.09M
  if (LeftSib)
2003
922k
    P.moveLeft(Level);
2004
1.09M
2005
1.09M
  // Elements have been rearranged, now update node sizes and stops.
2006
1.09M
  bool SplitRoot = false;
2007
1.09M
  unsigned Pos = 0;
2008
2.87M
  while (true) {
2009
2.87M
    KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
2010
2.87M
    if (NewNode && 
Pos == NewNode1.18M
) {
2011
376k
      SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
2012
376k
      Level += SplitRoot;
2013
2.49M
    } else {
2014
2.49M
      P.setSize(Level, NewSize[Pos]);
2015
2.49M
      setNodeStop(Level, Stop);
2016
2.49M
    }
2017
2.87M
    if (Pos + 1 == Nodes)
2018
1.09M
      break;
2019
1.78M
    P.moveRight(Level);
2020
1.78M
    ++Pos;
2021
1.78M
  }
2022
1.09M
2023
1.09M
  // Where was I? Find NewOffset.
2024
1.69M
  while(Pos != NewOffset.first) {
2025
603k
    P.moveLeft(Level);
2026
603k
    --Pos;
2027
603k
  }
2028
1.09M
  P.offset(Level) = NewOffset.second;
2029
1.09M
  return SplitRoot;
2030
1.09M
}
Unexecuted instantiation: bool llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::overflow<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, DbgValueLocation, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int)
Unexecuted instantiation: bool llvm::IntervalMap<llvm::SlotIndex, DbgValueLocation, 4u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::overflow<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, DbgValueLocation, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int)
bool llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::overflow<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int)
Line
Count
Source
1956
1.04M
iterator::overflow(unsigned Level) {
1957
1.04M
  using namespace IntervalMapImpl;
1958
1.04M
  Path &P = this->path;
1959
1.04M
  unsigned CurSize[4];
1960
1.04M
  NodeT *Node[4];
1961
1.04M
  unsigned Nodes = 0;
1962
1.04M
  unsigned Elements = 0;
1963
1.04M
  unsigned Offset = P.offset(Level);
1964
1.04M
1965
1.04M
  // Do we have a left sibling?
1966
1.04M
  NodeRef LeftSib = P.getLeftSibling(Level);
1967
1.04M
  if (LeftSib) {
1968
886k
    Offset += Elements = CurSize[Nodes] = LeftSib.size();
1969
886k
    Node[Nodes++] = &LeftSib.get<NodeT>();
1970
886k
  }
1971
1.04M
1972
1.04M
  // Current node.
1973
1.04M
  Elements += CurSize[Nodes] = P.size(Level);
1974
1.04M
  Node[Nodes++] = &P.node<NodeT>(Level);
1975
1.04M
1976
1.04M
  // Do we have a right sibling?
1977
1.04M
  NodeRef RightSib = P.getRightSibling(Level);
1978
1.04M
  if (RightSib) {
1979
466k
    Elements += CurSize[Nodes] = RightSib.size();
1980
466k
    Node[Nodes++] = &RightSib.get<NodeT>();
1981
466k
  }
1982
1.04M
1983
1.04M
  // Do we need to allocate a new node?
1984
1.04M
  unsigned NewNode = 0;
1985
1.04M
  if (Elements + 1 > Nodes * NodeT::Capacity) {
1986
360k
    // Insert NewNode at the penultimate position, or after a single node.
1987
360k
    NewNode = Nodes == 1 ? 
13.00k
:
Nodes - 1357k
;
1988
360k
    CurSize[Nodes] = CurSize[NewNode];
1989
360k
    Node[Nodes] = Node[NewNode];
1990
360k
    CurSize[NewNode] = 0;
1991
360k
    Node[NewNode] = this->map->template newNode<NodeT>();
1992
360k
    ++Nodes;
1993
360k
  }
1994
1.04M
1995
1.04M
  // Compute the new element distribution.
1996
1.04M
  unsigned NewSize[4];
1997
1.04M
  IdxPair NewOffset = distribute(Nodes, Elements, NodeT::Capacity,
1998
1.04M
                                 CurSize, NewSize, Offset, true);
1999
1.04M
  adjustSiblingSizes(Node, Nodes, CurSize, NewSize);
2000
1.04M
2001
1.04M
  // Move current location to the leftmost node.
2002
1.04M
  if (LeftSib)
2003
886k
    P.moveLeft(Level);
2004
1.04M
2005
1.04M
  // Elements have been rearranged, now update node sizes and stops.
2006
1.04M
  bool SplitRoot = false;
2007
1.04M
  unsigned Pos = 0;
2008
2.75M
  while (true) {
2009
2.75M
    KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
2010
2.75M
    if (NewNode && 
Pos == NewNode1.14M
) {
2011
360k
      SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
2012
360k
      Level += SplitRoot;
2013
2.39M
    } else {
2014
2.39M
      P.setSize(Level, NewSize[Pos]);
2015
2.39M
      setNodeStop(Level, Stop);
2016
2.39M
    }
2017
2.75M
    if (Pos + 1 == Nodes)
2018
1.04M
      break;
2019
1.71M
    P.moveRight(Level);
2020
1.71M
    ++Pos;
2021
1.71M
  }
2022
1.04M
2023
1.04M
  // Where was I? Find NewOffset.
2024
1.62M
  while(Pos != NewOffset.first) {
2025
581k
    P.moveLeft(Level);
2026
581k
    --Pos;
2027
581k
  }
2028
1.04M
  P.offset(Level) = NewOffset.second;
2029
1.04M
  return SplitRoot;
2030
1.04M
}
bool llvm::IntervalMap<llvm::SlotIndex, llvm::LiveInterval*, 8u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::overflow<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, llvm::LiveInterval*, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int)
Line
Count
Source
1956
22.5k
iterator::overflow(unsigned Level) {
1957
22.5k
  using namespace IntervalMapImpl;
1958
22.5k
  Path &P = this->path;
1959
22.5k
  unsigned CurSize[4];
1960
22.5k
  NodeT *Node[4];
1961
22.5k
  unsigned Nodes = 0;
1962
22.5k
  unsigned Elements = 0;
1963
22.5k
  unsigned Offset = P.offset(Level);
1964
22.5k
1965
22.5k
  // Do we have a left sibling?
1966
22.5k
  NodeRef LeftSib = P.getLeftSibling(Level);
1967
22.5k
  if (LeftSib) {
1968
15.5k
    Offset += Elements = CurSize[Nodes] = LeftSib.size();
1969
15.5k
    Node[Nodes++] = &LeftSib.get<NodeT>();
1970
15.5k
  }
1971
22.5k
1972
22.5k
  // Current node.
1973
22.5k
  Elements += CurSize[Nodes] = P.size(Level);
1974
22.5k
  Node[Nodes++] = &P.node<NodeT>(Level);
1975
22.5k
1976
22.5k
  // Do we have a right sibling?
1977
22.5k
  NodeRef RightSib = P.getRightSibling(Level);
1978
22.5k
  if (RightSib) {
1979
5.15k
    Elements += CurSize[Nodes] = RightSib.size();
1980
5.15k
    Node[Nodes++] = &RightSib.get<NodeT>();
1981
5.15k
  }
1982
22.5k
1983
22.5k
  // Do we need to allocate a new node?
1984
22.5k
  unsigned NewNode = 0;
1985
22.5k
  if (Elements + 1 > Nodes * NodeT::Capacity) {
1986
9.79k
    // Insert NewNode at the penultimate position, or after a single node.
1987
9.79k
    NewNode = Nodes == 1 ? 
14.40k
:
Nodes - 15.39k
;
1988
9.79k
    CurSize[Nodes] = CurSize[NewNode];
1989
9.79k
    Node[Nodes] = Node[NewNode];
1990
9.79k
    CurSize[NewNode] = 0;
1991
9.79k
    Node[NewNode] = this->map->template newNode<NodeT>();
1992
9.79k
    ++Nodes;
1993
9.79k
  }
1994
22.5k
1995
22.5k
  // Compute the new element distribution.
1996
22.5k
  unsigned NewSize[4];
1997
22.5k
  IdxPair NewOffset = distribute(Nodes, Elements, NodeT::Capacity,
1998
22.5k
                                 CurSize, NewSize, Offset, true);
1999
22.5k
  adjustSiblingSizes(Node, Nodes, CurSize, NewSize);
2000
22.5k
2001
22.5k
  // Move current location to the leftmost node.
2002
22.5k
  if (LeftSib)
2003
15.5k
    P.moveLeft(Level);
2004
22.5k
2005
22.5k
  // Elements have been rearranged, now update node sizes and stops.
2006
22.5k
  bool SplitRoot = false;
2007
22.5k
  unsigned Pos = 0;
2008
53.0k
  while (true) {
2009
53.0k
    KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
2010
53.0k
    if (NewNode && 
Pos == NewNode25.4k
) {
2011
9.79k
      SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
2012
9.79k
      Level += SplitRoot;
2013
43.2k
    } else {
2014
43.2k
      P.setSize(Level, NewSize[Pos]);
2015
43.2k
      setNodeStop(Level, Stop);
2016
43.2k
    }
2017
53.0k
    if (Pos + 1 == Nodes)
2018
22.5k
      break;
2019
30.5k
    P.moveRight(Level);
2020
30.5k
    ++Pos;
2021
30.5k
  }
2022
22.5k
2023
22.5k
  // Where was I? Find NewOffset.
2024
30.0k
  while(Pos != NewOffset.first) {
2025
7.52k
    P.moveLeft(Level);
2026
7.52k
    --Pos;
2027
7.52k
  }
2028
22.5k
  P.offset(Level) = NewOffset.second;
2029
22.5k
  return SplitRoot;
2030
22.5k
}
bool llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::overflow<llvm::IntervalMapImpl::LeafNode<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int)
Line
Count
Source
1956
25.2k
iterator::overflow(unsigned Level) {
1957
25.2k
  using namespace IntervalMapImpl;
1958
25.2k
  Path &P = this->path;
1959
25.2k
  unsigned CurSize[4];
1960
25.2k
  NodeT *Node[4];
1961
25.2k
  unsigned Nodes = 0;
1962
25.2k
  unsigned Elements = 0;
1963
25.2k
  unsigned Offset = P.offset(Level);
1964
25.2k
1965
25.2k
  // Do we have a left sibling?
1966
25.2k
  NodeRef LeftSib = P.getLeftSibling(Level);
1967
25.2k
  if (LeftSib) {
1968
20.5k
    Offset += Elements = CurSize[Nodes] = LeftSib.size();
1969
20.5k
    Node[Nodes++] = &LeftSib.get<NodeT>();
1970
20.5k
  }
1971
25.2k
1972
25.2k
  // Current node.
1973
25.2k
  Elements += CurSize[Nodes] = P.size(Level);
1974
25.2k
  Node[Nodes++] = &P.node<NodeT>(Level);
1975
25.2k
1976
25.2k
  // Do we have a right sibling?
1977
25.2k
  NodeRef RightSib = P.getRightSibling(Level);
1978
25.2k
  if (RightSib) {
1979
10.8k
    Elements += CurSize[Nodes] = RightSib.size();
1980
10.8k
    Node[Nodes++] = &RightSib.get<NodeT>();
1981
10.8k
  }
1982
25.2k
1983
25.2k
  // Do we need to allocate a new node?
1984
25.2k
  unsigned NewNode = 0;
1985
25.2k
  if (Elements + 1 > Nodes * NodeT::Capacity) {
1986
6.02k
    // Insert NewNode at the penultimate position, or after a single node.
1987
6.02k
    NewNode = Nodes == 1 ? 
123
:
Nodes - 16.00k
;
1988
6.02k
    CurSize[Nodes] = CurSize[NewNode];
1989
6.02k
    Node[Nodes] = Node[NewNode];
1990
6.02k
    CurSize[NewNode] = 0;
1991
6.02k
    Node[NewNode] = this->map->template newNode<NodeT>();
1992
6.02k
    ++Nodes;
1993
6.02k
  }
1994
25.2k
1995
25.2k
  // Compute the new element distribution.
1996
25.2k
  unsigned NewSize[4];
1997
25.2k
  IdxPair NewOffset = distribute(Nodes, Elements, NodeT::Capacity,
1998
25.2k
                                 CurSize, NewSize, Offset, true);
1999
25.2k
  adjustSiblingSizes(Node, Nodes, CurSize, NewSize);
2000
25.2k
2001
25.2k
  // Move current location to the leftmost node.
2002
25.2k
  if (LeftSib)
2003
20.5k
    P.moveLeft(Level);
2004
25.2k
2005
25.2k
  // Elements have been rearranged, now update node sizes and stops.
2006
25.2k
  bool SplitRoot = false;
2007
25.2k
  unsigned Pos = 0;
2008
62.6k
  while (true) {
2009
62.6k
    KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
2010
62.6k
    if (NewNode && 
Pos == NewNode18.8k
) {
2011
6.02k
      SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
2012
6.02k
      Level += SplitRoot;
2013
56.6k
    } else {
2014
56.6k
      P.setSize(Level, NewSize[Pos]);
2015
56.6k
      setNodeStop(Level, Stop);
2016
56.6k
    }
2017
62.6k
    if (Pos + 1 == Nodes)
2018
25.2k
      break;
2019
37.4k
    P.moveRight(Level);
2020
37.4k
    ++Pos;
2021
37.4k
  }
2022
25.2k
2023
25.2k
  // Where was I? Find NewOffset.
2024
39.3k
  while(Pos != NewOffset.first) {
2025
14.1k
    P.moveLeft(Level);
2026
14.1k
    --Pos;
2027
14.1k
  }
2028
25.2k
  P.offset(Level) = NewOffset.second;
2029
25.2k
  return SplitRoot;
2030
25.2k
}
bool llvm::IntervalMap<llvm::SlotIndex, unsigned int, 9u, llvm::IntervalMapInfo<llvm::SlotIndex> >::iterator::overflow<llvm::IntervalMapImpl::BranchNode<llvm::SlotIndex, unsigned int, 12u, llvm::IntervalMapInfo<llvm::SlotIndex> > >(unsigned int)
Line
Count
Source
1956
94
iterator::overflow(unsigned Level) {
1957
94
  using namespace IntervalMapImpl;
1958
94
  Path &P = this->path;
1959
94
  unsigned CurSize[4];
1960
94
  NodeT *Node[4];
1961
94
  unsigned Nodes = 0;
1962
94
  unsigned Elements = 0;
1963
94
  unsigned Offset = P.offset(Level);
1964
94
1965
94
  // Do we have a left sibling?
1966
94
  NodeRef LeftSib = P.getLeftSibling(Level);
1967
94
  if (LeftSib) {
1968
34
    Offset += Elements = CurSize[Nodes] = LeftSib.size();
1969
34
    Node[Nodes++] = &LeftSib.get<NodeT>();
1970
34
  }
1971
94
1972
94
  // Current node.
1973
94
  Elements += CurSize[Nodes] = P.size(Level);
1974
94
  Node[Nodes++] = &P.node<NodeT>(Level);
1975
94
1976
94
  // Do we have a right sibling?
1977
94
  NodeRef RightSib = P.getRightSibling(Level);
1978
94
  if (RightSib) {
1979
16
    Elements += CurSize[Nodes] = RightSib.size();
1980
16
    Node[Nodes++] = &RightSib.get<NodeT>();
1981
16
  }
1982
94
1983
94
  // Do we need to allocate a new node?
1984
94
  unsigned NewNode = 0;
1985
94
  if (Elements + 1 > Nodes * NodeT::Capacity) {
1986
58
    // Insert NewNode at the penultimate position, or after a single node.
1987
58
    NewNode = Nodes == 1 ? 
146
:
Nodes - 112
;
1988
58
    CurSize[Nodes] = CurSize[NewNode];
1989
58
    Node[Nodes] = Node[NewNode];
1990
58
    CurSize[NewNode] = 0;
1991
58
    Node[NewNode] = this->map->template newNode<NodeT>();
1992
58
    ++Nodes;
1993
58
  }
1994
94
1995
94
  // Compute the new element distribution.
1996
94
  unsigned NewSize[4];
1997
94
  IdxPair NewOffset = distribute(Nodes, Elements, NodeT::Capacity,
1998
94
                                 CurSize, NewSize, Offset, true);
1999
94
  adjustSiblingSizes(Node, Nodes, CurSize, NewSize);
2000
94
2001
94
  // Move current location to the leftmost node.
2002
94
  if (LeftSib)
2003
34
    P.moveLeft(Level);
2004
94
2005
94
  // Elements have been rearranged, now update node sizes and stops.
2006
94
  bool SplitRoot = false;
2007
94
  unsigned Pos = 0;
2008
202
  while (true) {
2009
202
    KeyT Stop = Node[Pos]->stop(NewSize[Pos]-1);
2010
202
    if (NewNode && 
Pos == NewNode129
) {
2011
58
      SplitRoot = insertNode(Level, NodeRef(Node[Pos], NewSize[Pos]), Stop);
2012
58
      Level += SplitRoot;
2013
144
    } else {
2014
144
      P.setSize(Level, NewSize[Pos]);
2015
144
      setNodeStop(Level, Stop);
2016
144
    }
2017
202
    if (Pos + 1 == Nodes)
2018
94
      break;
2019
108
    P.moveRight(Level);
2020
108
    ++Pos;
2021
108
  }
2022
94
2023
94
  // Where was I? Find NewOffset.
2024
130
  while(Pos != NewOffset.first) {
2025
36
    P.moveLeft(Level);
2026
36
    --Pos;
2027
36
  }
2028
94
  P.offset(Level) = NewOffset.second;
2029
94
  return SplitRoot;
2030
94
}
2031
2032
//===----------------------------------------------------------------------===//
2033
//---                       IntervalMapOverlaps                           ----//
2034
//===----------------------------------------------------------------------===//
2035
2036
/// IntervalMapOverlaps - Iterate over the overlaps of mapped intervals in two
2037
/// IntervalMaps. The maps may be different, but the KeyT and Traits types
2038
/// should be the same.
2039
///
2040
/// Typical uses:
2041
///
2042
/// 1. Test for overlap:
2043
///    bool overlap = IntervalMapOverlaps(a, b).valid();
2044
///
2045
/// 2. Enumerate overlaps:
2046
///    for (IntervalMapOverlaps I(a, b); I.valid() ; ++I) { ... }
2047
///
2048
template <typename MapA, typename MapB>
2049
class IntervalMapOverlaps {
2050
  using KeyType = typename MapA::KeyType;
2051
  using Traits = typename MapA::KeyTraits;
2052
2053
  typename MapA::const_iterator posA;
2054
  typename MapB::const_iterator posB;
2055
2056
  /// advance - Move posA and posB forward until reaching an overlap, or until
2057
  /// either meets end.
2058
  /// Don't move the iterators if they are already overlapping.
2059
  void advance() {
2060
    if (!valid())
2061
      return;
2062
2063
    if (Traits::stopLess(posA.stop(), posB.start())) {
2064
      // A ends before B begins. Catch up.
2065
      posA.advanceTo(posB.start());
2066
      if (!posA.valid() || !Traits::stopLess(posB.stop(), posA.start()))
2067
        return;
2068
    } else if (Traits::stopLess(posB.stop(), posA.start())) {
2069
      // B ends before A begins. Catch up.
2070
      posB.advanceTo(posA.start());