Coverage Report

Created: 2018-12-11 00:00

/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
198M
  static unsigned getValIndex(const ValueT &Val) {
59
198M
    return Val.getSparseSetIndex();
60
198M
  }
llvm::SparseSetValTraits<llvm::LiveRegUnit>::getValIndex(llvm::LiveRegUnit const&)
Line
Count
Source
58
5.94M
  static unsigned getValIndex(const ValueT &Val) {
59
5.94M
    return Val.getSparseSetIndex();
60
5.94M
  }
llvm::SparseSetValTraits<llvm::VReg2SUnit>::getValIndex(llvm::VReg2SUnit const&)
Line
Count
Source
58
19.4M
  static unsigned getValIndex(const ValueT &Val) {
59
19.4M
    return Val.getSparseSetIndex();
60
19.4M
  }
RegAllocFast.cpp:llvm::SparseSetValTraits<(anonymous namespace)::RegAllocFast::LiveReg>::getValIndex((anonymous namespace)::RegAllocFast::LiveReg const&)
Line
Count
Source
58
363k
  static unsigned getValIndex(const ValueT &Val) {
59
363k
    return Val.getSparseSetIndex();
60
363k
  }
llvm::SparseSetValTraits<llvm::LiveRegSet::IndexMaskPair>::getValIndex(llvm::LiveRegSet::IndexMaskPair const&)
Line
Count
Source
58
33.8M
  static unsigned getValIndex(const ValueT &Val) {
59
33.8M
    return Val.getSparseSetIndex();
60
33.8M
  }
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
106M
  static unsigned getValIndex(const ValueT &Val) {
59
106M
    return Val.getSparseSetIndex();
60
106M
  }
llvm::SparseSetValTraits<llvm::VReg2SUnitOperIdx>::getValIndex(llvm::VReg2SUnitOperIdx const&)
Line
Count
Source
58
32.2M
  static unsigned getValIndex(const ValueT &Val) {
59
32.2M
    return Val.getSparseSetIndex();
60
32.2M
  }
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
198M
  unsigned operator()(const ValueT &Val) const {
70
198M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
198M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::LiveRegUnit, llvm::identity<unsigned int> >::operator()(llvm::LiveRegUnit const&) const
Line
Count
Source
69
5.94M
  unsigned operator()(const ValueT &Val) const {
70
5.94M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
5.94M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::VReg2SUnit, llvm::VirtReg2IndexFunctor>::operator()(llvm::VReg2SUnit const&) const
Line
Count
Source
69
19.4M
  unsigned operator()(const ValueT &Val) const {
70
19.4M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
19.4M
  }
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
363k
  unsigned operator()(const ValueT &Val) const {
70
363k
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
363k
  }
llvm::SparseSetValFunctor<unsigned int, llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int> >::operator()(llvm::LiveRegSet::IndexMaskPair const&) const
Line
Count
Source
69
33.8M
  unsigned operator()(const ValueT &Val) const {
70
33.8M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
33.8M
  }
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
106M
  unsigned operator()(const ValueT &Val) const {
70
106M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
106M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::VReg2SUnitOperIdx, llvm::VirtReg2IndexFunctor>::operator()(llvm::VReg2SUnitOperIdx const&) const
Line
Count
Source
69
32.2M
  unsigned operator()(const ValueT &Val) const {
70
32.2M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
71
32.2M
  }
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
539M
  unsigned operator()(const KeyT &Key) const {
79
539M
    return KeyFunctorT()(Key);
80
539M
  }
llvm::SparseSetValFunctor<unsigned short, unsigned short, llvm::identity<unsigned short> >::operator()(unsigned short const&) const
Line
Count
Source
78
204M
  unsigned operator()(const KeyT &Key) const {
79
204M
    return KeyFunctorT()(Key);
80
204M
  }
llvm::SparseSetValFunctor<unsigned int, unsigned int, llvm::identity<unsigned int> >::operator()(unsigned int const&) const
Line
Count
Source
78
330M
  unsigned operator()(const KeyT &Key) const {
79
330M
    return KeyFunctorT()(Key);
80
330M
  }
llvm::SparseSetValFunctor<unsigned int, unsigned int, llvm::VirtReg2IndexFunctor>::operator()(unsigned int const&) const
Line
Count
Source
78
4.29M
  unsigned operator()(const KeyT &Key) const {
79
4.29M
    return KeyFunctorT()(Key);
80
4.29M
  }
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.72M
  SparseSet() = default;
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::SparseSet()
Line
Count
Source
145
1.38M
  SparseSet() = default;
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
1.30M
  SparseSet() = default;
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::SparseSet()
Line
Count
Source
145
1.30M
  SparseSet() = default;
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
52.9k
  SparseSet() = default;
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
2.68M
  SparseSet() = default;
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
145
1.66k
  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.72M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::~SparseSet()
Line
Count
Source
148
1.38M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::~SparseSet()
Line
Count
Source
148
1.30M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
1.30M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
52.7k
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
2.68M
  ~SparseSet() { free(Sparse); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
148
1.66k
  ~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.74M
  void setUniverse(unsigned U) {
157
4.74M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
4.74M
    // seem like a likely use case, so we can add that code when we need it.
159
4.74M
    assert(empty() && "Can only resize universe on an empty map");
160
4.74M
    // Hysteresis prevents needless reallocations.
161
4.74M
    if (U >= Universe/4 && 
U <= Universe4.72M
)
162
1.25M
      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 short, llvm::identity<unsigned short>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
717k
  void setUniverse(unsigned U) {
157
717k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
717k
    // seem like a likely use case, so we can add that code when we need it.
159
717k
    assert(empty() && "Can only resize universe on an empty map");
160
717k
    // Hysteresis prevents needless reallocations.
161
717k
    if (U >= Universe/4 && U <= Universe)
162
429k
      return;
163
287k
    free(Sparse);
164
287k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
287k
    // would be enough here, but that will cause tools like valgrind to
166
287k
    // complain about branching on uninitialized data.
167
287k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
287k
    Universe = U;
169
287k
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
739k
  void setUniverse(unsigned U) {
157
739k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
739k
    // seem like a likely use case, so we can add that code when we need it.
159
739k
    assert(empty() && "Can only resize universe on an empty map");
160
739k
    // Hysteresis prevents needless reallocations.
161
739k
    if (U >= Universe/4 && 
U <= Universe719k
)
162
636k
      return;
163
102k
    free(Sparse);
164
102k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
102k
    // would be enough here, but that will cause tools like valgrind to
166
102k
    // complain about branching on uninitialized data.
167
102k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
102k
    Universe = U;
169
102k
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
2.68M
  void setUniverse(unsigned U) {
157
2.68M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
2.68M
    // seem like a likely use case, so we can add that code when we need it.
159
2.68M
    assert(empty() && "Can only resize universe on an empty map");
160
2.68M
    // Hysteresis prevents needless reallocations.
161
2.68M
    if (U >= Universe/4 && U <= Universe)
162
0
      return;
163
2.68M
    free(Sparse);
164
2.68M
    // The Sparse array doesn't actually need to be initialized, so malloc
165
2.68M
    // would be enough here, but that will cause tools like valgrind to
166
2.68M
    // complain about branching on uninitialized data.
167
2.68M
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
2.68M
    Universe = U;
169
2.68M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
156
7.36k
  void setUniverse(unsigned U) {
157
7.36k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
158
7.36k
    // seem like a likely use case, so we can add that code when we need it.
159
7.36k
    assert(empty() && "Can only resize universe on an empty map");
160
7.36k
    // Hysteresis prevents needless reallocations.
161
7.36k
    if (U >= Universe/4 && 
U <= Universe7.20k
)
162
5.09k
      return;
163
2.26k
    free(Sparse);
164
2.26k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
2.26k
    // would be enough here, but that will cause tools like valgrind to
166
2.26k
    // complain about branching on uninitialized data.
167
2.26k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
2.26k
    Universe = U;
169
2.26k
  }
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
137k
      return;
163
308k
    free(Sparse);
164
308k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
308k
    // would be enough here, but that will cause tools like valgrind to
166
308k
    // complain about branching on uninitialized data.
167
308k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
308k
    Universe = U;
169
308k
  }
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
45.8k
      return;
163
102k
    free(Sparse);
164
102k
    // The Sparse array doesn't actually need to be initialized, so malloc
165
102k
    // would be enough here, but that will cause tools like valgrind to
166
102k
    // complain about branching on uninitialized data.
167
102k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
168
102k
    Universe = U;
169
102k
  }
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
921k
  const_iterator begin() const { return Dense.begin(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::begin() const
Line
Count
Source
175
326k
  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
29.3M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::end() const
Line
Count
Source
176
14.6M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::end() const
Line
Count
Source
176
545k
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::end() const
Line
Count
Source
176
14.0M
  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
168M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::begin()
Line
Count
Source
177
55.9M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
95.3M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
3.15M
  iterator begin() { return Dense.begin(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
134k
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::begin()
Line
Count
Source
177
446k
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
177
13.8M
  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
806M
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::end()
Line
Count
Source
178
343M
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
416M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
9.89M
  iterator end() { return Dense.end(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
248k
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::end()
Line
Count
Source
178
5.63M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
178
30.6M
  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
103M
  bool empty() const { return Dense.empty(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::empty() const
Line
Count
Source
184
102M
  bool empty() const { return Dense.empty(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::empty() const
Line
Count
Source
184
839k
  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.1k
  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
561M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::size() const
Line
Count
Source
191
209M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
309M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
6.25M
  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
238k
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
191
32.1M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::size() const
Line
Count
Source
191
4.21M
  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
15.9M
  void clear() {
196
15.9M
    // Sparse does not need to be cleared, see find().
197
15.9M
    Dense.clear();
198
15.9M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::clear()
Line
Count
Source
195
1.47M
  void clear() {
196
1.47M
    // Sparse does not need to be cleared, see find().
197
1.47M
    Dense.clear();
198
1.47M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
195
8.52M
  void clear() {
196
8.52M
    // Sparse does not need to be cleared, see find().
197
8.52M
    Dense.clear();
198
8.52M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
195
10.8k
  void clear() {
196
10.8k
    // Sparse does not need to be cleared, see find().
197
10.8k
    Dense.clear();
198
10.8k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
195
2.96M
  void clear() {
196
2.96M
    // Sparse does not need to be cleared, see find().
197
2.96M
    Dense.clear();
198
2.96M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::clear()
Line
Count
Source
195
2.96M
  void clear() {
196
2.96M
    // Sparse does not need to be cleared, see find().
197
2.96M
    Dense.clear();
198
2.96M
  }
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
385M
  iterator findIndex(unsigned Idx) {
206
385M
    assert(Idx < Universe && "Key out of range");
207
385M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
512M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride126M
) {
209
274M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
274M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
274M
      if (Idx == FoundIdx)
212
148M
        return begin() + i;
213
126M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
126M
      if (!Stride)
215
0
        break;
216
126M
    }
217
385M
    
return end()237M
;
218
385M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
149M
  iterator findIndex(unsigned Idx) {
206
149M
    assert(Idx < Universe && "Key out of range");
207
149M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
228M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride78.2M
) {
209
114M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
114M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
114M
      if (Idx == FoundIdx)
212
35.8M
        return begin() + i;
213
78.2M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
78.2M
      if (!Stride)
215
0
        break;
216
78.2M
    }
217
149M
    
return end()113M
;
218
149M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
202M
  iterator findIndex(unsigned Idx) {
206
202M
    assert(Idx < Universe && "Key out of range");
207
202M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
235M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride33.1M
) {
209
128M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
128M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
128M
      if (Idx == FoundIdx)
212
95.3M
        return begin() + i;
213
33.1M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
33.1M
      if (!Stride)
215
0
        break;
216
33.1M
    }
217
202M
    
return end()107M
;
218
202M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
4.86M
  iterator findIndex(unsigned Idx) {
206
4.86M
    assert(Idx < Universe && "Key out of range");
207
4.86M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
5.93M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride1.07M
) {
209
3.63M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
3.63M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
3.63M
      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.86M
    
return end()2.29M
;
218
4.86M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
181k
  iterator findIndex(unsigned Idx) {
206
181k
    assert(Idx < Universe && "Key out of range");
207
181k
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
299k
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride117k
) {
209
241k
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
241k
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
241k
      if (Idx == FoundIdx)
212
123k
        return begin() + i;
213
117k
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
117k
      if (!Stride)
215
0
        break;
216
117k
    }
217
181k
    
return end()57.4k
;
218
181k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
2.41M
  iterator findIndex(unsigned Idx) {
206
2.41M
    assert(Idx < Universe && "Key out of range");
207
2.41M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
4.39M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride1.97M
) {
209
2.42M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
2.42M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
2.42M
      if (Idx == FoundIdx)
212
446k
        return begin() + i;
213
1.97M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
1.97M
      if (!Stride)
215
0
        break;
216
1.97M
    }
217
2.41M
    
return end()1.97M
;
218
2.41M
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
205
26.4M
  iterator findIndex(unsigned Idx) {
206
26.4M
    assert(Idx < Universe && "Key out of range");
207
26.4M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
208
38.1M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride11.7M
) {
209
25.5M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
210
25.5M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
211
25.5M
      if (Idx == FoundIdx)
212
13.8M
        return begin() + i;
213
11.7M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
214
11.7M
      if (!Stride)
215
0
        break;
216
11.7M
    }
217
26.4M
    
return end()12.5M
;
218
26.4M
  }
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
72.4M
  iterator find(const KeyT &Key) {
226
72.4M
    return findIndex(KeyIndexOf(Key));
227
72.4M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::find(unsigned short const&)
Line
Count
Source
225
65.2M
  iterator find(const KeyT &Key) {
226
65.2M
    return findIndex(KeyIndexOf(Key));
227
65.2M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
2.48k
  iterator find(const KeyT &Key) {
226
2.48k
    return findIndex(KeyIndexOf(Key));
227
2.48k
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
2.67M
  iterator find(const KeyT &Key) {
226
2.67M
    return findIndex(KeyIndexOf(Key));
227
2.67M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
4.92k
  iterator find(const KeyT &Key) {
226
4.92k
    return findIndex(KeyIndexOf(Key));
227
4.92k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
225
4.56M
  iterator find(const KeyT &Key) {
226
4.56M
    return findIndex(KeyIndexOf(Key));
227
4.56M
  }
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
28.4M
  const_iterator find(const KeyT &Key) const {
230
28.4M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
28.4M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::find(unsigned short const&) const
Line
Count
Source
229
14.3M
  const_iterator find(const KeyT &Key) const {
230
14.3M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
14.3M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
54.3k
  const_iterator find(const KeyT &Key) const {
230
54.3k
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
54.3k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
545k
  const_iterator find(const KeyT &Key) const {
230
545k
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
545k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
229
13.4M
  const_iterator find(const KeyT &Key) const {
230
13.4M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
231
13.4M
  }
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.9M
  size_type count(const KeyT &Key) const {
237
14.9M
    return find(Key) == end() ? 
011.1M
:
13.80M
;
238
14.9M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::count(unsigned short const&) const
Line
Count
Source
236
14.3M
  size_type count(const KeyT &Key) const {
237
14.3M
    return find(Key) == end() ? 
010.9M
:
13.44M
;
238
14.3M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::count(unsigned int const&) const
Line
Count
Source
236
545k
  size_type count(const KeyT &Key) const {
237
545k
    return find(Key) == end() ? 
0179k
:
1365k
;
238
545k
  }
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
285M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
285M
    unsigned Idx = ValIndexOf(Val);
252
285M
    iterator I = findIndex(Idx);
253
285M
    if (I != end())
254
109M
      return std::make_pair(I, false);
255
175M
    Sparse[Idx] = size();
256
175M
    Dense.push_back(Val);
257
175M
    return std::make_pair(end() - 1, true);
258
175M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::insert(unsigned short const&)
Line
Count
Source
250
70.2M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
70.2M
    unsigned Idx = ValIndexOf(Val);
252
70.2M
    iterator I = findIndex(Idx);
253
70.2M
    if (I != end())
254
10.2M
      return std::make_pair(I, false);
255
59.9M
    Sparse[Idx] = size();
256
59.9M
    Dense.push_back(Val);
257
59.9M
    return std::make_pair(end() - 1, true);
258
59.9M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::insert(unsigned int const&)
Line
Count
Source
250
202M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
202M
    unsigned Idx = ValIndexOf(Val);
252
202M
    iterator I = findIndex(Idx);
253
202M
    if (I != end())
254
95.3M
      return std::make_pair(I, false);
255
107M
    Sparse[Idx] = size();
256
107M
    Dense.push_back(Val);
257
107M
    return std::make_pair(end() - 1, true);
258
107M
  }
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
797k
      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
122k
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
122k
    unsigned Idx = ValIndexOf(Val);
252
122k
    iterator I = findIndex(Idx);
253
122k
    if (I != end())
254
64.6k
      return std::make_pair(I, false);
255
57.3k
    Sparse[Idx] = size();
256
57.3k
    Dense.push_back(Val);
257
57.3k
    return std::make_pair(end() - 1, true);
258
57.3k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::insert(llvm::LiveRegSet::IndexMaskPair const&)
Line
Count
Source
250
8.34M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
8.34M
    unsigned Idx = ValIndexOf(Val);
252
8.34M
    iterator I = findIndex(Idx);
253
8.34M
    if (I != end())
254
3.17M
      return std::make_pair(I, false);
255
5.16M
    Sparse[Idx] = size();
256
5.16M
    Dense.push_back(Val);
257
5.16M
    return std::make_pair(end() - 1, true);
258
5.16M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::insert(unsigned int const&)
Line
Count
Source
250
1.87M
  std::pair<iterator, bool> insert(const ValueT &Val) {
251
1.87M
    unsigned Idx = ValIndexOf(Val);
252
1.87M
    iterator I = findIndex(Idx);
253
1.87M
    if (I != end())
254
80.6k
      return std::make_pair(I, false);
255
1.79M
    Sparse[Idx] = size();
256
1.79M
    Dense.push_back(Val);
257
1.79M
    return std::make_pair(end() - 1, true);
258
1.79M
  }
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
90.9M
  ValueT pop_back_val() {
268
90.9M
    // Sparse does not need to be cleared, see find().
269
90.9M
    return Dense.pop_back_val();
270
90.9M
  }
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
24.1M
  iterator erase(iterator I) {
287
24.1M
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
24.1M
    if (I != end() - 1) {
289
19.9M
      *I = Dense.back();
290
19.9M
      unsigned BackIdx = ValIndexOf(Dense.back());
291
19.9M
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
19.9M
      Sparse[BackIdx] = I - begin();
293
19.9M
    }
294
24.1M
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
24.1M
    // std::vector::pop_back() doesn't give that guarantee.
296
24.1M
    Dense.pop_back();
297
24.1M
    return I;
298
24.1M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int*)
Line
Count
Source
286
2.42k
  iterator erase(iterator I) {
287
2.42k
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
2.42k
    if (I != end() - 1) {
289
5
      *I = Dense.back();
290
5
      unsigned BackIdx = ValIndexOf(Dense.back());
291
5
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
5
      Sparse[BackIdx] = I - begin();
293
5
    }
294
2.42k
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
2.42k
    // std::vector::pop_back() doesn't give that guarantee.
296
2.42k
    Dense.pop_back();
297
2.42k
    return I;
298
2.42k
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::erase(unsigned short*)
Line
Count
Source
286
23.2M
  iterator erase(iterator I) {
287
23.2M
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
23.2M
    if (I != end() - 1) {
289
19.8M
      *I = Dense.back();
290
19.8M
      unsigned BackIdx = ValIndexOf(Dense.back());
291
19.8M
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
292
19.8M
      Sparse[BackIdx] = I - begin();
293
19.8M
    }
294
23.2M
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
23.2M
    // std::vector::pop_back() doesn't give that guarantee.
296
23.2M
    Dense.pop_back();
297
23.2M
    return I;
298
23.2M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::erase(llvm::LiveRegUnit*)
Line
Count
Source
286
869k
  iterator erase(iterator I) {
287
869k
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
288
869k
    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
869k
    // This depends on SmallVector::pop_back() not invalidating iterators.
295
869k
    // std::vector::pop_back() doesn't give that guarantee.
296
869k
    Dense.pop_back();
297
869k
    return I;
298
869k
  }
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
65.4M
  bool erase(const KeyT &Key) {
306
65.4M
    iterator I = find(Key);
307
65.4M
    if (I == end())
308
43.2M
      return false;
309
22.1M
    erase(I);
310
22.1M
    return true;
311
22.1M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
305
2.47k
  bool erase(const KeyT &Key) {
306
2.47k
    iterator I = find(Key);
307
2.47k
    if (I == end())
308
60
      return false;
309
2.41k
    erase(I);
310
2.41k
    return true;
311
2.41k
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::erase(unsigned short const&)
Line
Count
Source
305
65.2M
  bool erase(const KeyT &Key) {
306
65.2M
    iterator I = find(Key);
307
65.2M
    if (I == end())
308
43.1M
      return false;
309
22.0M
    erase(I);
310
22.0M
    return true;
311
22.0M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
305
220k
  bool erase(const KeyT &Key) {
306
220k
    iterator I = find(Key);
307
220k
    if (I == end())
308
148k
      return false;
309
71.9k
    erase(I);
310
71.9k
    return true;
311
71.9k
  }
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