Coverage Report

Created: 2018-09-25 00:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/ADT/SparseSet.h
Line
Count
Source (jump to first uncovered line)
1
//===- llvm/ADT/SparseSet.h - Sparse set ------------------------*- 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 defines the SparseSet class derived from the version described in
11
// Briggs, Torczon, "An efficient representation for sparse sets", ACM Letters
12
// on Programming Languages and Systems, Volume 2 Issue 1-4, March-Dec.  1993.
13
//
14
// A sparse set holds a small number of objects identified by integer keys from
15
// a moderately sized universe. The sparse set uses more memory than other
16
// containers in order to provide faster operations.
17
//
18
//===----------------------------------------------------------------------===//
19
20
#ifndef LLVM_ADT_SPARSESET_H
21
#define LLVM_ADT_SPARSESET_H
22
23
#include "llvm/ADT/STLExtras.h"
24
#include "llvm/ADT/SmallVector.h"
25
#include "llvm/Support/Allocator.h"
26
#include <cassert>
27
#include <cstdint>
28
#include <cstdlib>
29
#include <limits>
30
#include <utility>
31
32
namespace llvm {
33
34
/// SparseSetValTraits - Objects in a SparseSet are identified by keys that can
35
/// be uniquely converted to a small integer less than the set's universe. This
36
/// class allows the set to hold values that differ from the set's key type as
37
/// long as an index can still be derived from the value. SparseSet never
38
/// directly compares ValueT, only their indices, so it can map keys to
39
/// arbitrary values. SparseSetValTraits computes the index from the value
40
/// object. To compute the index from a key, SparseSet uses a separate
41
/// KeyFunctorT template argument.
42
///
43
/// A simple type declaration, SparseSet<Type>, handles these cases:
44
/// - unsigned key, identity index, identity value
45
/// - unsigned key, identity index, fat value providing getSparseSetIndex()
46
///
47
/// The type declaration SparseSet<Type, UnaryFunction> handles:
48
/// - unsigned key, remapped index, identity value (virtual registers)
49
/// - pointer key, pointer-derived index, identity value (node+ID)
50
/// - pointer key, pointer-derived index, fat value with getSparseSetIndex()
51
///
52
/// Only other, unexpected cases require specializing SparseSetValTraits.
53
///
54
/// For best results, ValueT should not require a destructor.
55
///
56
template<typename ValueT>
57
struct SparseSetValTraits {
58
195M
  static unsigned getValIndex(const ValueT &Val) {
59
195M
    return Val.getSparseSetIndex();
60
195M
  }
llvm::SparseSetValTraits<llvm::LiveRegUnit>::getValIndex(llvm::LiveRegUnit const&)
Line
Count
Source
58
5.96M
  static unsigned getValIndex(const ValueT &Val) {
59
5.96M
    return Val.getSparseSetIndex();
60
5.96M
  }
llvm::SparseSetValTraits<llvm::VReg2SUnit>::getValIndex(llvm::VReg2SUnit const&)
Line
Count
Source
58
19.2M
  static unsigned getValIndex(const ValueT &Val) {
59
19.2M
    return Val.getSparseSetIndex();
60
19.2M
  }
RegAllocFast.cpp:llvm::SparseSetValTraits<(anonymous namespace)::RegAllocFast::LiveReg>::getValIndex((anonymous namespace)::RegAllocFast::LiveReg const&)
Line
Count
Source
58
322k
  static unsigned getValIndex(const ValueT &Val) {
59
322k
    return Val.getSparseSetIndex();
60
322k
  }
llvm::SparseSetValTraits<llvm::LiveRegSet::IndexMaskPair>::getValIndex(llvm::LiveRegSet::IndexMaskPair const&)
Line
Count
Source
58
33.1M
  static unsigned getValIndex(const ValueT &Val) {
59
33.1M
    return Val.getSparseSetIndex();
60
33.1M
  }
llvm::SparseSetValTraits<llvm::SchedDFSImpl::RootData>::getValIndex(llvm::SchedDFSImpl::RootData const&)
Line
Count
Source
58
1.02k
  static unsigned getValIndex(const ValueT &Val) {
59
1.02k
    return Val.getSparseSetIndex();
60
1.02k
  }
llvm::SparseSetValTraits<llvm::PhysRegSUOper>::getValIndex(llvm::PhysRegSUOper const&)
Line
Count
Source
58
104M
  static unsigned getValIndex(const ValueT &Val) {
59
104M
    return Val.getSparseSetIndex();
60
104M
  }
llvm::SparseSetValTraits<llvm::VReg2SUnitOperIdx>::getValIndex(llvm::VReg2SUnitOperIdx const&)
Line
Count
Source
58
32.0M
  static unsigned getValIndex(const ValueT &Val) {
59
32.0M
    return Val.getSparseSetIndex();
60
32.0M
  }
61
};
62
63
/// SparseSetValFunctor - Helper class for selecting SparseSetValTraits. The
64
/// generic implementation handles ValueT classes which either provide
65
/// getSparseSetIndex() or specialize SparseSetValTraits<>.
66
///
67
template<typename KeyT, typename ValueT, typename KeyFunctorT>
68
struct SparseSetValFunctor {
69
195M
  unsigned operator()(const ValueT &Val) const {
70
195M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
195M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::LiveRegUnit, llvm::identity<unsigned int> >::operator()(llvm::LiveRegUnit const&) const
Line
Count
Source
69
5.96M
  unsigned operator()(const ValueT &Val) const {
70
5.96M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
5.96M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::VReg2SUnit, llvm::VirtReg2IndexFunctor>::operator()(llvm::VReg2SUnit const&) const
Line
Count
Source
69
19.2M
  unsigned operator()(const ValueT &Val) const {
70
19.2M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
19.2M
  }
RegAllocFast.cpp:llvm::SparseSetValFunctor<unsigned int, (anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int> >::operator()((anonymous namespace)::RegAllocFast::LiveReg const&) const
Line
Count
Source
69
322k
  unsigned operator()(const ValueT &Val) const {
70
322k
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
322k
  }
llvm::SparseSetValFunctor<unsigned int, llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int> >::operator()(llvm::LiveRegSet::IndexMaskPair const&) const
Line
Count
Source
69
33.1M
  unsigned operator()(const ValueT &Val) const {
70
33.1M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
33.1M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int> >::operator()(llvm::SchedDFSImpl::RootData const&) const
Line
Count
Source
69
1.02k
  unsigned operator()(const ValueT &Val) const {
70
1.02k
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
1.02k
  }
llvm::SparseSetValFunctor<unsigned int, llvm::PhysRegSUOper, llvm::identity<unsigned int> >::operator()(llvm::PhysRegSUOper const&) const
Line
Count
Source
69
104M
  unsigned operator()(const ValueT &Val) const {
70
104M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
104M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::VReg2SUnitOperIdx, llvm::VirtReg2IndexFunctor>::operator()(llvm::VReg2SUnitOperIdx const&) const
Line
Count
Source
69
32.0M
  unsigned operator()(const ValueT &Val) const {
70
32.0M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
32.0M
  }
72
};
73
74
/// SparseSetValFunctor<KeyT, KeyT> - Helper class for the common case of
75
/// identity key/value sets.
76
template<typename KeyT, typename KeyFunctorT>
77
struct SparseSetValFunctor<KeyT, KeyT, KeyFunctorT> {
78
573M
  unsigned operator()(const KeyT &Key) const {
79
573M
    return KeyFunctorT()(Key);
80
573M
  }
llvm::SparseSetValFunctor<unsigned int, unsigned int, llvm::identity<unsigned int> >::operator()(unsigned int const&) const
Line
Count
Source
78
569M
  unsigned operator()(const KeyT &Key) const {
79
569M
    return KeyFunctorT()(Key);
80
569M
  }
llvm::SparseSetValFunctor<unsigned int, unsigned int, llvm::VirtReg2IndexFunctor>::operator()(unsigned int const&) const
Line
Count
Source
78
4.23M
  unsigned operator()(const KeyT &Key) const {
79
4.23M
    return KeyFunctorT()(Key);
80
4.23M
  }
81
};
82
83
/// SparseSet - Fast set implmentation for objects that can be identified by
84
/// small unsigned keys.
85
///
86
/// SparseSet allocates memory proportional to the size of the key universe, so
87
/// it is not recommended for building composite data structures.  It is useful
88
/// for algorithms that require a single set with fast operations.
89
///
90
/// Compared to DenseSet and DenseMap, SparseSet provides constant-time fast
91
/// clear() and iteration as fast as a vector.  The find(), insert(), and
92
/// erase() operations are all constant time, and typically faster than a hash
93
/// table.  The iteration order doesn't depend on numerical key values, it only
94
/// depends on the order of insert() and erase() operations.  When no elements
95
/// have been erased, the iteration order is the insertion order.
96
///
97
/// Compared to BitVector, SparseSet<unsigned> uses 8x-40x more memory, but
98
/// offers constant-time clear() and size() operations as well as fast
99
/// iteration independent on the size of the universe.
100
///
101
/// SparseSet contains a dense vector holding all the objects and a sparse
102
/// array holding indexes into the dense vector.  Most of the memory is used by
103
/// the sparse array which is the size of the key universe.  The SparseT
104
/// template parameter provides a space/speed tradeoff for sets holding many
105
/// elements.
106
///
107
/// When SparseT is uint32_t, find() only touches 2 cache lines, but the sparse
108
/// array uses 4 x Universe bytes.
109
///
110
/// When SparseT is uint8_t (the default), find() touches up to 2+[N/256] cache
111
/// lines, but the sparse array is 4x smaller.  N is the number of elements in
112
/// the set.
113
///
114
/// For sets that may grow to thousands of elements, SparseT should be set to
115
/// uint16_t or uint32_t.
116
///
117
/// @tparam ValueT      The type of objects in the set.
118
/// @tparam KeyFunctorT A functor that computes an unsigned index from KeyT.
119
/// @tparam SparseT     An unsigned integer type. See above.
120
///
121
template<typename ValueT,
122
         typename KeyFunctorT = identity<unsigned>,
123
         typename SparseT = uint8_t>
124
class SparseSet {
125
  static_assert(std::numeric_limits<SparseT>::is_integer &&
126
                !std::numeric_limits<SparseT>::is_signed,
127
                "SparseT must be an unsigned integer type");
128
129
  using KeyT = typename KeyFunctorT::argument_type;
130
  using DenseT = SmallVector<ValueT, 8>;
131
  using size_type = unsigned;
132
  DenseT Dense;
133
  SparseT *Sparse = nullptr;
134
  unsigned Universe = 0;
135
  KeyFunctorT KeyIndexOf;
136
  SparseSetValFunctor<KeyT, ValueT, KeyFunctorT> ValIndexOf;
137
138
public:
139
  using value_type = ValueT;
140
  using reference = ValueT &;
141
  using const_reference = const ValueT &;
142
  using pointer = ValueT *;
143
  using const_pointer = const ValueT *;
144
145
6.64M
  SparseSet() = default;
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
1.40M
  SparseSet() = default;
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
1.27M
  SparseSet() = default;
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::SparseSet()
Line
Count
Source
145
1.27M
  SparseSet() = default;
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
2.69M
  SparseSet() = default;
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
1.60k
  SparseSet() = default;
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
10
  SparseSet() = default;
146
  SparseSet(const SparseSet &) = delete;
147
  SparseSet &operator=(const SparseSet &) = delete;
148
6.64M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
1.40M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::~SparseSet()
Line
Count
Source
148
1.27M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
1.27M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
2.69M
  ~SparseSet() { free(Sparse); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
1.60k
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
10
  ~SparseSet() { free(Sparse); }
149
150
  /// setUniverse - Set the universe size which determines the largest key the
151
  /// set can hold.  The universe must be sized before any elements can be
152
  /// added.
153
  ///
154
  /// @param U Universe size. All object keys must be less than U.
155
  ///
156
4.72M
  void setUniverse(unsigned U) {
157
4.72M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
4.72M
    // seem like a likely use case, so we can add that code when we need it.
159
4.72M
    assert(empty() && "Can only resize universe on an empty map");
160
4.72M
    // Hysteresis prevents needless reallocations.
161
4.72M
    if (U >= Universe/4 && 
U <= Universe4.70M
)
162
1.24M
      return;
163
3.48M
    free(Sparse);
164
3.48M
    // The Sparse array doesn't actually need to be initialized, so malloc
165
3.48M
    // would be enough here, but that will cause tools like valgrind to
166
3.48M
    // complain about branching on uninitialized data.
167
3.48M
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
3.48M
    Universe = U;
169
3.48M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
1.43M
  void setUniverse(unsigned U) {
157
1.43M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
1.43M
    // seem like a likely use case, so we can add that code when we need it.
159
1.43M
    assert(empty() && "Can only resize universe on an empty map");
160
1.43M
    // Hysteresis prevents needless reallocations.
161
1.43M
    if (U >= Universe/4 && 
U <= Universe1.41M
)
162
1.04M
      return;
163
387k
    free(Sparse);
164
387k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
387k
    // would be enough here, but that will cause tools like valgrind to
166
387k
    // complain about branching on uninitialized data.
167
387k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
387k
    Universe = U;
169
387k
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
2.69M
  void setUniverse(unsigned U) {
157
2.69M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
2.69M
    // seem like a likely use case, so we can add that code when we need it.
159
2.69M
    assert(empty() && "Can only resize universe on an empty map");
160
2.69M
    // Hysteresis prevents needless reallocations.
161
2.69M
    if (
U >= Universe/42.69M
&& U <= Universe)
162
0
      return;
163
2.69M
    free(Sparse);
164
2.69M
    // The Sparse array doesn't actually need to be initialized, so malloc
165
2.69M
    // would be enough here, but that will cause tools like valgrind to
166
2.69M
    // complain about branching on uninitialized data.
167
2.69M
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
2.69M
    Universe = U;
169
2.69M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
7.27k
  void setUniverse(unsigned U) {
157
7.27k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
7.27k
    // seem like a likely use case, so we can add that code when we need it.
159
7.27k
    assert(empty() && "Can only resize universe on an empty map");
160
7.27k
    // Hysteresis prevents needless reallocations.
161
7.27k
    if (U >= Universe/4 && 
U <= Universe7.11k
)
162
5.04k
      return;
163
2.23k
    free(Sparse);
164
2.23k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
2.23k
    // would be enough here, but that will cause tools like valgrind to
166
2.23k
    // complain about branching on uninitialized data.
167
2.23k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
2.23k
    Universe = U;
169
2.23k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
445k
  void setUniverse(unsigned U) {
157
445k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
445k
    // seem like a likely use case, so we can add that code when we need it.
159
445k
    assert(empty() && "Can only resize universe on an empty map");
160
445k
    // Hysteresis prevents needless reallocations.
161
445k
    if (U >= Universe/4 && U <= Universe)
162
149k
      return;
163
296k
    free(Sparse);
164
296k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
296k
    // would be enough here, but that will cause tools like valgrind to
166
296k
    // complain about branching on uninitialized data.
167
296k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
296k
    Universe = U;
169
296k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
148k
  void setUniverse(unsigned U) {
157
148k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
148k
    // seem like a likely use case, so we can add that code when we need it.
159
148k
    assert(empty() && "Can only resize universe on an empty map");
160
148k
    // Hysteresis prevents needless reallocations.
161
148k
    if (U >= Universe/4 && U <= Universe)
162
49.8k
      return;
163
98.8k
    free(Sparse);
164
98.8k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
98.8k
    // would be enough here, but that will cause tools like valgrind to
166
98.8k
    // complain about branching on uninitialized data.
167
98.8k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
98.8k
    Universe = U;
169
98.8k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
10
  void setUniverse(unsigned U) {
157
10
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
10
    // seem like a likely use case, so we can add that code when we need it.
159
10
    assert(empty() && "Can only resize universe on an empty map");
160
10
    // Hysteresis prevents needless reallocations.
161
10
    if (U >= Universe/4 && U <= Universe)
162
0
      return;
163
10
    free(Sparse);
164
10
    // The Sparse array doesn't actually need to be initialized, so malloc
165
10
    // would be enough here, but that will cause tools like valgrind to
166
10
    // complain about branching on uninitialized data.
167
10
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
10
    Universe = U;
169
10
  }
170
171
  // Import trivial vector stuff from DenseT.
172
  using iterator = typename DenseT::iterator;
173
  using const_iterator = typename DenseT::const_iterator;
174
175
922k
  const_iterator begin() const { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::begin() const
Line
Count
Source
175
328k
  const_iterator begin() const { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::begin() const
Line
Count
Source
175
594k
  const_iterator begin() const { return Dense.begin(); }
176
28.6M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::end() const
Line
Count
Source
176
14.3M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::end() const
Line
Count
Source
176
564k
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::end() const
Line
Count
Source
176
13.7M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::end() const
Line
Count
Source
176
146
  const_iterator end() const { return Dense.end(); }
177
179M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
162M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
3.16M
  iterator begin() { return Dense.begin(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
173k
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::begin()
Line
Count
Source
177
455k
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
13.4M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
520
  iterator begin() { return Dense.begin(); }
178
849M
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
803M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
9.93M
  iterator end() { return Dense.end(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
294k
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::end()
Line
Count
Source
178
5.52M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
30.1M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
1.00k
  iterator end() { return Dense.end(); }
179
180
  /// empty - Returns true if the set is empty.
181
  ///
182
  /// This is not the same as BitVector::empty().
183
  ///
184
111M
  bool empty() const { return Dense.empty(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::empty() const
Line
Count
Source
184
111M
  bool empty() const { return Dense.empty(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::empty() const
Line
Count
Source
184
13.0k
  bool empty() const { return Dense.empty(); }
185
186
  /// size - Returns the number of elements in the set.
187
  ///
188
  /// This is not the same as BitVector::size() which returns the size of the
189
  /// universe.
190
  ///
191
592M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
550M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
6.27M
  size_type size() const { return Dense.size(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
266k
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
31.5M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::size() const
Line
Count
Source
191
4.14M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
814
  size_type size() const { return Dense.size(); }
192
193
  /// clear - Clears the set.  This is a very fast constant time operation.
194
  ///
195
16.2M
  void clear() {
196
16.2M
    // Sparse does not need to be cleared, see find().
197
16.2M
    Dense.clear();
198
16.2M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
195
10.2M
  void clear() {
196
10.2M
    // Sparse does not need to be cleared, see find().
197
10.2M
    Dense.clear();
198
10.2M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
195
4.54k
  void clear() {
196
4.54k
    // Sparse does not need to be cleared, see find().
197
4.54k
    Dense.clear();
198
4.54k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
195
2.97M
  void clear() {
196
2.97M
    // Sparse does not need to be cleared, see find().
197
2.97M
    Dense.clear();
198
2.97M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::clear()
Line
Count
Source
195
2.97M
  void clear() {
196
2.97M
    // Sparse does not need to be cleared, see find().
197
2.97M
    Dense.clear();
198
2.97M
  }
199
200
  /// findIndex - Find an element by its index.
201
  ///
202
  /// @param   Idx A valid index to find.
203
  /// @returns An iterator to the element identified by key, or end().
204
  ///
205
406M
  iterator findIndex(unsigned Idx) {
206
406M
    assert(Idx < Universe && "Key out of range");
207
406M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
536M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride129M
) {
209
287M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
287M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
287M
      if (Idx == FoundIdx)
212
158M
        return begin() + i;
213
129M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
129M
      if (!Stride)
215
0
        break;
216
129M
    }
217
406M
    
return end()248M
;
218
406M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
373M
  iterator findIndex(unsigned Idx) {
206
373M
    assert(Idx < Universe && "Key out of range");
207
373M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
488M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride115M
) {
209
256M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
256M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
256M
      if (Idx == FoundIdx)
212
141M
        return begin() + i;
213
115M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
115M
      if (!Stride)
215
0
        break;
216
115M
    }
217
373M
    
return end()231M
;
218
373M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
4.87M
  iterator findIndex(unsigned Idx) {
206
4.87M
    assert(Idx < Universe && "Key out of range");
207
4.87M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
5.95M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride1.07M
) {
209
3.64M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
3.64M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
3.64M
      if (Idx == FoundIdx)
212
2.56M
        return begin() + i;
213
1.07M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
1.07M
      if (!Stride)
215
0
        break;
216
1.07M
    }
217
4.87M
    
return end()2.31M
;
218
4.87M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
207k
  iterator findIndex(unsigned Idx) {
206
207k
    assert(Idx < Universe && "Key out of range");
207
207k
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
239k
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride31.6k
) {
209
180k
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
180k
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
180k
      if (Idx == FoundIdx)
212
148k
        return begin() + i;
213
31.6k
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
31.6k
      if (!Stride)
215
0
        break;
216
31.6k
    }
217
207k
    
return end()58.6k
;
218
207k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
2.39M
  iterator findIndex(unsigned Idx) {
206
2.39M
    assert(Idx < Universe && "Key out of range");
207
2.39M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
4.34M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride1.94M
) {
209
2.39M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
2.39M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
2.39M
      if (Idx == FoundIdx)
212
455k
        return begin() + i;
213
1.94M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
1.94M
      if (!Stride)
215
0
        break;
216
1.94M
    }
217
2.39M
    
return end()1.94M
;
218
2.39M
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
25.8M
  iterator findIndex(unsigned Idx) {
206
25.8M
    assert(Idx < Universe && "Key out of range");
207
25.8M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
37.3M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride11.4M
) {
209
24.9M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
24.9M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
24.9M
      if (Idx == FoundIdx)
212
13.4M
        return begin() + i;
213
11.4M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
11.4M
      if (!Stride)
215
0
        break;
216
11.4M
    }
217
25.8M
    
return end()12.3M
;
218
25.8M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
638
  iterator findIndex(unsigned Idx) {
206
638
    assert(Idx < Universe && "Key out of range");
207
638
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
798
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride160
) {
209
614
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
614
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
614
      if (Idx == FoundIdx)
212
454
        return begin() + i;
213
160
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
160
      if (!Stride)
215
0
        break;
216
160
    }
217
638
    
return end()184
;
218
638
  }
219
220
  /// find - Find an element by its key.
221
  ///
222
  /// @param   Key A valid key to find.
223
  /// @returns An iterator to the element identified by key, or end().
224
  ///
225
74.4M
  iterator find(const KeyT &Key) {
226
74.4M
    return findIndex(KeyIndexOf(Key));
227
74.4M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
67.2M
  iterator find(const KeyT &Key) {
226
67.2M
    return findIndex(KeyIndexOf(Key));
227
67.2M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
2.68M
  iterator find(const KeyT &Key) {
226
2.68M
    return findIndex(KeyIndexOf(Key));
227
2.68M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
32.5k
  iterator find(const KeyT &Key) {
226
32.5k
    return findIndex(KeyIndexOf(Key));
227
32.5k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
4.45M
  iterator find(const KeyT &Key) {
226
4.45M
    return findIndex(KeyIndexOf(Key));
227
4.45M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
138
  iterator find(const KeyT &Key) {
226
138
    return findIndex(KeyIndexOf(Key));
227
138
  }
228
229
27.8M
  const_iterator find(const KeyT &Key) const {
230
27.8M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
27.8M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
14.0M
  const_iterator find(const KeyT &Key) const {
230
14.0M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
14.0M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
53.6k
  const_iterator find(const KeyT &Key) const {
230
53.6k
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
53.6k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
564k
  const_iterator find(const KeyT &Key) const {
230
564k
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
564k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
13.1M
  const_iterator find(const KeyT &Key) const {
230
13.1M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
13.1M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
146
  const_iterator find(const KeyT &Key) const {
230
146
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
146
  }
232
233
  /// count - Returns 1 if this set contains an element identified by Key,
234
  /// 0 otherwise.
235
  ///
236
14.6M
  size_type count(const KeyT &Key) const {
237
14.6M
    return find(Key) == end() ? 
010.7M
:
13.84M
;
238
14.6M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::count(unsigned int const&) const
Line
Count
Source
236
14.0M
  size_type count(const KeyT &Key) const {
237
14.0M
    return find(Key) == end() ? 
010.5M
:
13.46M
;
238
14.0M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::count(unsigned int const&) const
Line
Count
Source
236
564k
  size_type count(const KeyT &Key) const {
237
564k
    return find(Key) == end() ? 
0187k
:
1377k
;
238
564k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::count(unsigned int const&) const
Line
Count
Source
236
146
  size_type count(const KeyT &Key) const {
237
146
    return find(Key) == end() ? 
08
:
1138
;
238
146
  }
239
240
  /// insert - Attempts to insert a new element.
241
  ///
242
  /// If Val is successfully inserted, return (I, true), where I is an iterator
243
  /// pointing to the newly inserted element.
244
  ///
245
  /// If the set already contains an element with the same key as Val, return
246
  /// (I, false), where I is an iterator pointing to the existing element.
247
  ///
248
  /// Insertion invalidates all iterators.
249
  ///
250
304M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
304M
    unsigned Idx = ValIndexOf(Val);
252
304M
    iterator I = findIndex(Idx);
253
304M
    if (I != end())
254
119M
      return std::make_pair(I, false);
255
185M
    Sparse[Idx] = size();
256
185M
    Dense.push_back(Val);
257
185M
    return std::make_pair(end() - 1, true);
258
185M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::insert(unsigned int const&)
Line
Count
Source
250
291M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
291M
    unsigned Idx = ValIndexOf(Val);
252
291M
    iterator I = findIndex(Idx);
253
291M
    if (I != end())
254
115M
      return std::make_pair(I, false);
255
176M
    Sparse[Idx] = size();
256
176M
    Dense.push_back(Val);
257
176M
    return std::make_pair(end() - 1, true);
258
176M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::insert(llvm::LiveRegUnit const&)
Line
Count
Source
250
2.19M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
2.19M
    unsigned Idx = ValIndexOf(Val);
252
2.19M
    iterator I = findIndex(Idx);
253
2.19M
    if (I != end())
254
796k
      return std::make_pair(I, false);
255
1.39M
    Sparse[Idx] = size();
256
1.39M
    Dense.push_back(Val);
257
1.39M
    return std::make_pair(end() - 1, true);
258
1.39M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::insert((anonymous namespace)::RegAllocFast::LiveReg const&)
Line
Count
Source
250
121k
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
121k
    unsigned Idx = ValIndexOf(Val);
252
121k
    iterator I = findIndex(Idx);
253
121k
    if (I != end())
254
62.7k
      return std::make_pair(I, false);
255
58.6k
    Sparse[Idx] = size();
256
58.6k
    Dense.push_back(Val);
257
58.6k
    return std::make_pair(end() - 1, true);
258
58.6k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::insert(llvm::LiveRegSet::IndexMaskPair const&)
Line
Count
Source
250
8.23M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
8.23M
    unsigned Idx = ValIndexOf(Val);
252
8.23M
    iterator I = findIndex(Idx);
253
8.23M
    if (I != end())
254
3.15M
      return std::make_pair(I, false);
255
5.07M
    Sparse[Idx] = size();
256
5.07M
    Dense.push_back(Val);
257
5.07M
    return std::make_pair(end() - 1, true);
258
5.07M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::insert(unsigned int const&)
Line
Count
Source
250
1.83M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
1.83M
    unsigned Idx = ValIndexOf(Val);
252
1.83M
    iterator I = findIndex(Idx);
253
1.83M
    if (I != end())
254
78.4k
      return std::make_pair(I, false);
255
1.75M
    Sparse[Idx] = size();
256
1.75M
    Dense.push_back(Val);
257
1.75M
    return std::make_pair(end() - 1, true);
258
1.75M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::insert(llvm::SchedDFSImpl::RootData const&)
Line
Count
Source
250
354
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
354
    unsigned Idx = ValIndexOf(Val);
252
354
    iterator I = findIndex(Idx);
253
354
    if (I != end())
254
178
      return std::make_pair(I, false);
255
176
    Sparse[Idx] = size();
256
176
    Dense.push_back(Val);
257
176
    return std::make_pair(end() - 1, true);
258
176
  }
259
260
  /// array subscript - If an element already exists with this key, return it.
261
  /// Otherwise, automatically construct a new value from Key, insert it,
262
  /// and return the newly inserted element.
263
2.19M
  ValueT &operator[](const KeyT &Key) {
264
2.19M
    return *insert(ValueT(Key)).first;
265
2.19M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::operator[](unsigned int const&)
Line
Count
Source
263
2.19M
  ValueT &operator[](const KeyT &Key) {
264
2.19M
    return *insert(ValueT(Key)).first;
265
2.19M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::operator[](unsigned int const&)
Line
Count
Source
263
354
  ValueT &operator[](const KeyT &Key) {
264
354
    return *insert(ValueT(Key)).first;
265
354
  }
266
267
97.7M
  ValueT pop_back_val() {
268
97.7M
    // Sparse does not need to be cleared, see find().
269
97.7M
    return Dense.pop_back_val();
270
97.7M
  }
271
272
  /// erase - Erases an existing element identified by a valid iterator.
273
  ///
274
  /// This invalidates all iterators, but erase() returns an iterator pointing
275
  /// to the next element.  This makes it possible to erase selected elements
276
  /// while iterating over the set:
277
  ///
278
  ///   for (SparseSet::iterator I = Set.begin(); I != Set.end();)
279
  ///     if (test(*I))
280
  ///       I = Set.erase(I);
281
  ///     else
282
  ///       ++I;
283
  ///
284
  /// Note that end() changes when elements are erased, unlike std::list.
285
  ///
286
25.1M
  iterator erase(iterator I) {
287
25.1M
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
25.1M
    if (I != end() - 1) {
289
20.8M
      *I = Dense.back();
290
20.8M
      unsigned BackIdx = ValIndexOf(Dense.back());
291
20.8M
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
20.8M
      Sparse[BackIdx] = I - begin();
293
20.8M
    }
294
25.1M
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
25.1M
    // std::vector::pop_back() doesn't give that guarantee.
296
25.1M
    Dense.pop_back();
297
25.1M
    return I;
298
25.1M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int*)
Line
Count
Source
286
24.2M
  iterator erase(iterator I) {
287
24.2M
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
24.2M
    if (I != end() - 1) {
289
20.7M
      *I = Dense.back();
290
20.7M
      unsigned BackIdx = ValIndexOf(Dense.back());
291
20.7M
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
20.7M
      Sparse[BackIdx] = I - begin();
293
20.7M
    }
294
24.2M
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
24.2M
    // std::vector::pop_back() doesn't give that guarantee.
296
24.2M
    Dense.pop_back();
297
24.2M
    return I;
298
24.2M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::erase(llvm::LiveRegUnit*)
Line
Count
Source
286
873k
  iterator erase(iterator I) {
287
873k
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
873k
    if (I != end() - 1) {
289
121k
      *I = Dense.back();
290
121k
      unsigned BackIdx = ValIndexOf(Dense.back());
291
121k
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
121k
      Sparse[BackIdx] = I - begin();
293
121k
    }
294
873k
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
873k
    // std::vector::pop_back() doesn't give that guarantee.
296
873k
    Dense.pop_back();
297
873k
    return I;
298
873k
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::erase((anonymous namespace)::RegAllocFast::LiveReg*)
Line
Count
Source
286
50.4k
  iterator erase(iterator I) {
287
50.4k
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
50.4k
    if (I != end() - 1) {
289
20.1k
      *I = Dense.back();
290
20.1k
      unsigned BackIdx = ValIndexOf(Dense.back());
291
20.1k
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
20.1k
      Sparse[BackIdx] = I - begin();
293
20.1k
    }
294
50.4k
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
50.4k
    // std::vector::pop_back() doesn't give that guarantee.
296
50.4k
    Dense.pop_back();
297
50.4k
    return I;
298
50.4k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::erase(llvm::SchedDFSImpl::RootData*)
Line
Count
Source
286
138
  iterator erase(iterator I) {
287
138
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
138
    if (I != end() - 1) {
289
56
      *I = Dense.back();
290
56
      unsigned BackIdx = ValIndexOf(Dense.back());
291
56
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
56
      Sparse[BackIdx] = I - begin();
293
56
    }
294
138
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
138
    // std::vector::pop_back() doesn't give that guarantee.
296
138
    Dense.pop_back();
297
138
    return I;
298
138
  }
299
300
  /// erase - Erases an element identified by Key, if it exists.
301
  ///
302
  /// @param   Key The key identifying the element to erase.
303
  /// @returns True when an element was erased, false if no element was found.
304
  ///
305
67.4M
  bool erase(const KeyT &Key) {
306
67.4M
    iterator I = find(Key);
307
67.4M
    if (I == end())
308
44.3M
      return false;
309
23.0M
    erase(I);
310
23.0M
    return true;
311
23.0M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
305
67.2M
  bool erase(const KeyT &Key) {
306
67.2M
    iterator I = find(Key);
307
67.2M
    if (I == end())
308
44.2M
      return false;
309
23.0M
    erase(I);
310
23.0M
    return true;
311
23.0M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
305
228k
  bool erase(const KeyT &Key) {
306
228k
    iterator I = find(Key);
307
228k
    if (I == end())
308
153k
      return false;
309
74.6k
    erase(I);
310
74.6k
    return true;
311
74.6k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
305
138
  bool erase(const KeyT &Key) {
306
138
    iterator I = find(Key);
307
138
    if (I == end())
308
0
      return false;
309
138
    erase(I);
310
138
    return true;
311
138
  }
312
};
313
314
} // end namespace llvm
315
316
#endif // LLVM_ADT_SPARSESET_H