Coverage Report

Created: 2019-03-22 08:08

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines the SparseSet class derived from the version described in
10
// Briggs, Torczon, "An efficient representation for sparse sets", ACM Letters
11
// on Programming Languages and Systems, Volume 2 Issue 1-4, March-Dec.  1993.
12
//
13
// A sparse set holds a small number of objects identified by integer keys from
14
// a moderately sized universe. The sparse set uses more memory than other
15
// containers in order to provide faster operations.
16
//
17
//===----------------------------------------------------------------------===//
18
19
#ifndef LLVM_ADT_SPARSESET_H
20
#define LLVM_ADT_SPARSESET_H
21
22
#include "llvm/ADT/STLExtras.h"
23
#include "llvm/ADT/SmallVector.h"
24
#include "llvm/Support/Allocator.h"
25
#include <cassert>
26
#include <cstdint>
27
#include <cstdlib>
28
#include <limits>
29
#include <utility>
30
31
namespace llvm {
32
33
/// SparseSetValTraits - Objects in a SparseSet are identified by keys that can
34
/// be uniquely converted to a small integer less than the set's universe. This
35
/// class allows the set to hold values that differ from the set's key type as
36
/// long as an index can still be derived from the value. SparseSet never
37
/// directly compares ValueT, only their indices, so it can map keys to
38
/// arbitrary values. SparseSetValTraits computes the index from the value
39
/// object. To compute the index from a key, SparseSet uses a separate
40
/// KeyFunctorT template argument.
41
///
42
/// A simple type declaration, SparseSet<Type>, handles these cases:
43
/// - unsigned key, identity index, identity value
44
/// - unsigned key, identity index, fat value providing getSparseSetIndex()
45
///
46
/// The type declaration SparseSet<Type, UnaryFunction> handles:
47
/// - unsigned key, remapped index, identity value (virtual registers)
48
/// - pointer key, pointer-derived index, identity value (node+ID)
49
/// - pointer key, pointer-derived index, fat value with getSparseSetIndex()
50
///
51
/// Only other, unexpected cases require specializing SparseSetValTraits.
52
///
53
/// For best results, ValueT should not require a destructor.
54
///
55
template<typename ValueT>
56
struct SparseSetValTraits {
57
215M
  static unsigned getValIndex(const ValueT &Val) {
58
215M
    return Val.getSparseSetIndex();
59
215M
  }
llvm::SparseSetValTraits<llvm::LiveRegUnit>::getValIndex(llvm::LiveRegUnit const&)
Line
Count
Source
57
7.39M
  static unsigned getValIndex(const ValueT &Val) {
58
7.39M
    return Val.getSparseSetIndex();
59
7.39M
  }
llvm::SparseSetValTraits<llvm::VReg2SUnit>::getValIndex(llvm::VReg2SUnit const&)
Line
Count
Source
57
25.1M
  static unsigned getValIndex(const ValueT &Val) {
58
25.1M
    return Val.getSparseSetIndex();
59
25.1M
  }
RegAllocFast.cpp:llvm::SparseSetValTraits<(anonymous namespace)::RegAllocFast::LiveReg>::getValIndex((anonymous namespace)::RegAllocFast::LiveReg const&)
Line
Count
Source
57
455k
  static unsigned getValIndex(const ValueT &Val) {
58
455k
    return Val.getSparseSetIndex();
59
455k
  }
llvm::SparseSetValTraits<llvm::LiveRegSet::IndexMaskPair>::getValIndex(llvm::LiveRegSet::IndexMaskPair const&)
Line
Count
Source
57
48.0M
  static unsigned getValIndex(const ValueT &Val) {
58
48.0M
    return Val.getSparseSetIndex();
59
48.0M
  }
llvm::SparseSetValTraits<llvm::SchedDFSImpl::RootData>::getValIndex(llvm::SchedDFSImpl::RootData const&)
Line
Count
Source
57
1.02k
  static unsigned getValIndex(const ValueT &Val) {
58
1.02k
    return Val.getSparseSetIndex();
59
1.02k
  }
llvm::SparseSetValTraits<llvm::PhysRegSUOper>::getValIndex(llvm::PhysRegSUOper const&)
Line
Count
Source
57
99.3M
  static unsigned getValIndex(const ValueT &Val) {
58
99.3M
    return Val.getSparseSetIndex();
59
99.3M
  }
llvm::SparseSetValTraits<llvm::VReg2SUnitOperIdx>::getValIndex(llvm::VReg2SUnitOperIdx const&)
Line
Count
Source
57
35.4M
  static unsigned getValIndex(const ValueT &Val) {
58
35.4M
    return Val.getSparseSetIndex();
59
35.4M
  }
60
};
61
62
/// SparseSetValFunctor - Helper class for selecting SparseSetValTraits. The
63
/// generic implementation handles ValueT classes which either provide
64
/// getSparseSetIndex() or specialize SparseSetValTraits<>.
65
///
66
template<typename KeyT, typename ValueT, typename KeyFunctorT>
67
struct SparseSetValFunctor {
68
215M
  unsigned operator()(const ValueT &Val) const {
69
215M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
215M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::LiveRegUnit, llvm::identity<unsigned int> >::operator()(llvm::LiveRegUnit const&) const
Line
Count
Source
68
7.39M
  unsigned operator()(const ValueT &Val) const {
69
7.39M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
7.39M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::VReg2SUnit, llvm::VirtReg2IndexFunctor>::operator()(llvm::VReg2SUnit const&) const
Line
Count
Source
68
25.1M
  unsigned operator()(const ValueT &Val) const {
69
25.1M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
25.1M
  }
RegAllocFast.cpp:llvm::SparseSetValFunctor<unsigned int, (anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int> >::operator()((anonymous namespace)::RegAllocFast::LiveReg const&) const
Line
Count
Source
68
455k
  unsigned operator()(const ValueT &Val) const {
69
455k
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
455k
  }
llvm::SparseSetValFunctor<unsigned int, llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int> >::operator()(llvm::LiveRegSet::IndexMaskPair const&) const
Line
Count
Source
68
48.0M
  unsigned operator()(const ValueT &Val) const {
69
48.0M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
48.0M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int> >::operator()(llvm::SchedDFSImpl::RootData const&) const
Line
Count
Source
68
1.02k
  unsigned operator()(const ValueT &Val) const {
69
1.02k
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
1.02k
  }
llvm::SparseSetValFunctor<unsigned int, llvm::PhysRegSUOper, llvm::identity<unsigned int> >::operator()(llvm::PhysRegSUOper const&) const
Line
Count
Source
68
99.3M
  unsigned operator()(const ValueT &Val) const {
69
99.3M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
99.3M
  }
llvm::SparseSetValFunctor<unsigned int, llvm::VReg2SUnitOperIdx, llvm::VirtReg2IndexFunctor>::operator()(llvm::VReg2SUnitOperIdx const&) const
Line
Count
Source
68
35.4M
  unsigned operator()(const ValueT &Val) const {
69
35.4M
    return SparseSetValTraits<ValueT>::getValIndex(Val);
70
35.4M
  }
71
};
72
73
/// SparseSetValFunctor<KeyT, KeyT> - Helper class for the common case of
74
/// identity key/value sets.
75
template<typename KeyT, typename KeyFunctorT>
76
struct SparseSetValFunctor<KeyT, KeyT, KeyFunctorT> {
77
616M
  unsigned operator()(const KeyT &Key) const {
78
616M
    return KeyFunctorT()(Key);
79
616M
  }
llvm::SparseSetValFunctor<unsigned short, unsigned short, llvm::identity<unsigned short> >::operator()(unsigned short const&) const
Line
Count
Source
77
206M
  unsigned operator()(const KeyT &Key) const {
78
206M
    return KeyFunctorT()(Key);
79
206M
  }
llvm::SparseSetValFunctor<unsigned int, unsigned int, llvm::identity<unsigned int> >::operator()(unsigned int const&) const
Line
Count
Source
77
404M
  unsigned operator()(const KeyT &Key) const {
78
404M
    return KeyFunctorT()(Key);
79
404M
  }
llvm::SparseSetValFunctor<unsigned int, unsigned int, llvm::VirtReg2IndexFunctor>::operator()(unsigned int const&) const
Line
Count
Source
77
5.43M
  unsigned operator()(const KeyT &Key) const {
78
5.43M
    return KeyFunctorT()(Key);
79
5.43M
  }
80
};
81
82
/// SparseSet - Fast set implmentation for objects that can be identified by
83
/// small unsigned keys.
84
///
85
/// SparseSet allocates memory proportional to the size of the key universe, so
86
/// it is not recommended for building composite data structures.  It is useful
87
/// for algorithms that require a single set with fast operations.
88
///
89
/// Compared to DenseSet and DenseMap, SparseSet provides constant-time fast
90
/// clear() and iteration as fast as a vector.  The find(), insert(), and
91
/// erase() operations are all constant time, and typically faster than a hash
92
/// table.  The iteration order doesn't depend on numerical key values, it only
93
/// depends on the order of insert() and erase() operations.  When no elements
94
/// have been erased, the iteration order is the insertion order.
95
///
96
/// Compared to BitVector, SparseSet<unsigned> uses 8x-40x more memory, but
97
/// offers constant-time clear() and size() operations as well as fast
98
/// iteration independent on the size of the universe.
99
///
100
/// SparseSet contains a dense vector holding all the objects and a sparse
101
/// array holding indexes into the dense vector.  Most of the memory is used by
102
/// the sparse array which is the size of the key universe.  The SparseT
103
/// template parameter provides a space/speed tradeoff for sets holding many
104
/// elements.
105
///
106
/// When SparseT is uint32_t, find() only touches 2 cache lines, but the sparse
107
/// array uses 4 x Universe bytes.
108
///
109
/// When SparseT is uint8_t (the default), find() touches up to 2+[N/256] cache
110
/// lines, but the sparse array is 4x smaller.  N is the number of elements in
111
/// the set.
112
///
113
/// For sets that may grow to thousands of elements, SparseT should be set to
114
/// uint16_t or uint32_t.
115
///
116
/// @tparam ValueT      The type of objects in the set.
117
/// @tparam KeyFunctorT A functor that computes an unsigned index from KeyT.
118
/// @tparam SparseT     An unsigned integer type. See above.
119
///
120
template<typename ValueT,
121
         typename KeyFunctorT = identity<unsigned>,
122
         typename SparseT = uint8_t>
123
class SparseSet {
124
  static_assert(std::numeric_limits<SparseT>::is_integer &&
125
                !std::numeric_limits<SparseT>::is_signed,
126
                "SparseT must be an unsigned integer type");
127
128
  using KeyT = typename KeyFunctorT::argument_type;
129
  using DenseT = SmallVector<ValueT, 8>;
130
  using size_type = unsigned;
131
  DenseT Dense;
132
  SparseT *Sparse = nullptr;
133
  unsigned Universe = 0;
134
  KeyFunctorT KeyIndexOf;
135
  SparseSetValFunctor<KeyT, ValueT, KeyFunctorT> ValIndexOf;
136
137
public:
138
  using value_type = ValueT;
139
  using reference = ValueT &;
140
  using const_reference = const ValueT &;
141
  using pointer = ValueT *;
142
  using const_pointer = const ValueT *;
143
144
6.67M
  SparseSet() = default;
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::SparseSet()
Line
Count
Source
144
1.37M
  SparseSet() = default;
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
144
1.29M
  SparseSet() = default;
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::SparseSet()
Line
Count
Source
144
1.29M
  SparseSet() = default;
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
144
53.7k
  SparseSet() = default;
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
144
2.66M
  SparseSet() = default;
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
144
1.72k
  SparseSet() = default;
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::SparseSet()
Line
Count
Source
144
10
  SparseSet() = default;
145
  SparseSet(const SparseSet &) = delete;
146
  SparseSet &operator=(const SparseSet &) = delete;
147
6.67M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::~SparseSet()
Line
Count
Source
147
1.37M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::~SparseSet()
Line
Count
Source
147
1.29M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
147
1.29M
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
147
53.5k
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
147
2.66M
  ~SparseSet() { free(Sparse); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
147
1.71k
  ~SparseSet() { free(Sparse); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::~SparseSet()
Line
Count
Source
147
10
  ~SparseSet() { free(Sparse); }
148
149
  /// setUniverse - Set the universe size which determines the largest key the
150
  /// set can hold.  The universe must be sized before any elements can be
151
  /// added.
152
  ///
153
  /// @param U Universe size. All object keys must be less than U.
154
  ///
155
4.77M
  void setUniverse(unsigned U) {
156
4.77M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
4.77M
    // seem like a likely use case, so we can add that code when we need it.
158
4.77M
    assert(empty() && "Can only resize universe on an empty map");
159
4.77M
    // Hysteresis prevents needless reallocations.
160
4.77M
    if (U >= Universe/4 && 
U <= Universe4.75M
)
161
1.28M
      return;
162
3.48M
    free(Sparse);
163
3.48M
    // The Sparse array doesn't actually need to be initialized, so malloc
164
3.48M
    // would be enough here, but that will cause tools like valgrind to
165
3.48M
    // complain about branching on uninitialized data.
166
3.48M
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
3.48M
    Universe = U;
168
3.48M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
727k
  void setUniverse(unsigned U) {
156
727k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
727k
    // seem like a likely use case, so we can add that code when we need it.
158
727k
    assert(empty() && "Can only resize universe on an empty map");
159
727k
    // Hysteresis prevents needless reallocations.
160
727k
    if (U >= Universe/4 && U <= Universe)
161
438k
      return;
162
289k
    free(Sparse);
163
289k
    // The Sparse array doesn't actually need to be initialized, so malloc
164
289k
    // would be enough here, but that will cause tools like valgrind to
165
289k
    // complain about branching on uninitialized data.
166
289k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
289k
    Universe = U;
168
289k
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
737k
  void setUniverse(unsigned U) {
156
737k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
737k
    // seem like a likely use case, so we can add that code when we need it.
158
737k
    assert(empty() && "Can only resize universe on an empty map");
159
737k
    // Hysteresis prevents needless reallocations.
160
737k
    if (U >= Universe/4 && 
U <= Universe717k
)
161
634k
      return;
162
103k
    free(Sparse);
163
103k
    // The Sparse array doesn't actually need to be initialized, so malloc
164
103k
    // would be enough here, but that will cause tools like valgrind to
165
103k
    // complain about branching on uninitialized data.
166
103k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
103k
    Universe = U;
168
103k
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
2.66M
  void setUniverse(unsigned U) {
156
2.66M
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
2.66M
    // seem like a likely use case, so we can add that code when we need it.
158
2.66M
    assert(empty() && "Can only resize universe on an empty map");
159
2.66M
    // Hysteresis prevents needless reallocations.
160
2.66M
    if (U >= Universe/4 && U <= Universe)
161
0
      return;
162
2.66M
    free(Sparse);
163
2.66M
    // The Sparse array doesn't actually need to be initialized, so malloc
164
2.66M
    // would be enough here, but that will cause tools like valgrind to
165
2.66M
    // complain about branching on uninitialized data.
166
2.66M
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
2.66M
    Universe = U;
168
2.66M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
7.70k
  void setUniverse(unsigned U) {
156
7.70k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
7.70k
    // seem like a likely use case, so we can add that code when we need it.
158
7.70k
    assert(empty() && "Can only resize universe on an empty map");
159
7.70k
    // Hysteresis prevents needless reallocations.
160
7.70k
    if (U >= Universe/4 && 
U <= Universe7.54k
)
161
5.36k
      return;
162
2.33k
    free(Sparse);
163
2.33k
    // The Sparse array doesn't actually need to be initialized, so malloc
164
2.33k
    // would be enough here, but that will cause tools like valgrind to
165
2.33k
    // complain about branching on uninitialized data.
166
2.33k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
2.33k
    Universe = U;
168
2.33k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
477k
  void setUniverse(unsigned U) {
156
477k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
477k
    // seem like a likely use case, so we can add that code when we need it.
158
477k
    assert(empty() && "Can only resize universe on an empty map");
159
477k
    // Hysteresis prevents needless reallocations.
160
477k
    if (U >= Universe/4 && U <= Universe)
161
153k
      return;
162
324k
    free(Sparse);
163
324k
    // The Sparse array doesn't actually need to be initialized, so malloc
164
324k
    // would be enough here, but that will cause tools like valgrind to
165
324k
    // complain about branching on uninitialized data.
166
324k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
324k
    Universe = U;
168
324k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
159k
  void setUniverse(unsigned U) {
156
159k
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
159k
    // seem like a likely use case, so we can add that code when we need it.
158
159k
    assert(empty() && "Can only resize universe on an empty map");
159
159k
    // Hysteresis prevents needless reallocations.
160
159k
    if (U >= Universe/4 && U <= Universe)
161
51.2k
      return;
162
108k
    free(Sparse);
163
108k
    // The Sparse array doesn't actually need to be initialized, so malloc
164
108k
    // would be enough here, but that will cause tools like valgrind to
165
108k
    // complain about branching on uninitialized data.
166
108k
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
108k
    Universe = U;
168
108k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::setUniverse(unsigned int)
Line
Count
Source
155
10
  void setUniverse(unsigned U) {
156
10
    // It's not hard to resize the universe on a non-empty set, but it doesn't
157
10
    // seem like a likely use case, so we can add that code when we need it.
158
10
    assert(empty() && "Can only resize universe on an empty map");
159
10
    // Hysteresis prevents needless reallocations.
160
10
    if (U >= Universe/4 && U <= Universe)
161
0
      return;
162
10
    free(Sparse);
163
10
    // The Sparse array doesn't actually need to be initialized, so malloc
164
10
    // would be enough here, but that will cause tools like valgrind to
165
10
    // complain about branching on uninitialized data.
166
10
    Sparse = static_cast<SparseT*>(safe_calloc(U, sizeof(SparseT)));
167
10
    Universe = U;
168
10
  }
169
170
  // Import trivial vector stuff from DenseT.
171
  using iterator = typename DenseT::iterator;
172
  using const_iterator = typename DenseT::const_iterator;
173
174
988k
  const_iterator begin() const { return Dense.begin(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::begin() const
Line
Count
Source
174
351k
  const_iterator begin() const { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::begin() const
Line
Count
Source
174
637k
  const_iterator begin() const { return Dense.begin(); }
175
38.4M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::end() const
Line
Count
Source
175
15.1M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::end() const
Line
Count
Source
175
709k
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::end() const
Line
Count
Source
175
22.5M
  const_iterator end() const { return Dense.end(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::end() const
Line
Count
Source
175
146
  const_iterator end() const { return Dense.end(); }
176
197M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::begin()
Line
Count
Source
176
58.9M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
176
118M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
176
4.11M
  iterator begin() { return Dense.begin(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
176
171k
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::begin()
Line
Count
Source
176
555k
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
176
15.9M
  iterator begin() { return Dense.begin(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::begin()
Line
Count
Source
176
520
  iterator begin() { return Dense.begin(); }
177
910M
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::end()
Line
Count
Source
177
342M
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
177
507M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
177
10.7M
  iterator end() { return Dense.end(); }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
177
258k
  iterator end() { return Dense.end(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::end()
Line
Count
Source
177
6.71M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
177
42.3M
  iterator end() { return Dense.end(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::end()
Line
Count
Source
177
1.00k
  iterator end() { return Dense.end(); }
178
179
  /// empty - Returns true if the set is empty.
180
  ///
181
  /// This is not the same as BitVector::empty().
182
  ///
183
125M
  bool empty() const { return Dense.empty(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::empty() const
Line
Count
Source
183
124M
  bool empty() const { return Dense.empty(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::empty() const
Line
Count
Source
183
848k
  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
183
13.7k
  bool empty() const { return Dense.empty(); }
184
185
  /// size - Returns the number of elements in the set.
186
  ///
187
  /// This is not the same as BitVector::size() which returns the size of the
188
  /// universe.
189
  ///
190
645M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::size() const
Line
Count
Source
190
211M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
190
377M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
190
7.17M
  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
190
279k
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
190
43.7M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::size() const
Line
Count
Source
190
5.05M
  size_type size() const { return Dense.size(); }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::size() const
Line
Count
Source
190
814
  size_type size() const { return Dense.size(); }
191
192
  /// clear - Clears the set.  This is a very fast constant time operation.
193
  ///
194
18.6M
  void clear() {
195
18.6M
    // Sparse does not need to be cleared, see find().
196
18.6M
    Dense.clear();
197
18.6M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::clear()
Line
Count
Source
194
1.50M
  void clear() {
195
1.50M
    // Sparse does not need to be cleared, see find().
196
1.50M
    Dense.clear();
197
1.50M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
194
11.1M
  void clear() {
195
11.1M
    // Sparse does not need to be cleared, see find().
196
11.1M
    Dense.clear();
197
11.1M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
194
11.2k
  void clear() {
195
11.2k
    // Sparse does not need to be cleared, see find().
196
11.2k
    Dense.clear();
197
11.2k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::clear()
Line
Count
Source
194
3.00M
  void clear() {
195
3.00M
    // Sparse does not need to be cleared, see find().
196
3.00M
    Dense.clear();
197
3.00M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::clear()
Line
Count
Source
194
3.00M
  void clear() {
195
3.00M
    // Sparse does not need to be cleared, see find().
196
3.00M
    Dense.clear();
197
3.00M
  }
198
199
  /// findIndex - Find an element by its index.
200
  ///
201
  /// @param   Idx A valid index to find.
202
  /// @returns An iterator to the element identified by key, or end().
203
  ///
204
443M
  iterator findIndex(unsigned Idx) {
205
443M
    assert(Idx < Universe && "Key out of range");
206
443M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
582M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride139M
) {
208
315M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
315M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
315M
      if (Idx == FoundIdx)
211
176M
        return begin() + i;
212
139M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
139M
      if (!Stride)
214
0
        break;
215
139M
    }
216
443M
    
return end()267M
;
217
443M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
149M
  iterator findIndex(unsigned Idx) {
205
149M
    assert(Idx < Universe && "Key out of range");
206
149M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
224M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride75.3M
) {
208
113M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
113M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
113M
      if (Idx == FoundIdx)
211
37.7M
        return begin() + i;
212
75.3M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
75.3M
      if (!Stride)
214
0
        break;
215
75.3M
    }
216
149M
    
return end()111M
;
217
149M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
248M
  iterator findIndex(unsigned Idx) {
205
248M
    assert(Idx < Universe && "Key out of range");
206
248M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
286M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride37.9M
) {
208
156M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
156M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
156M
      if (Idx == FoundIdx)
211
118M
        return begin() + i;
212
37.9M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
37.9M
      if (!Stride)
214
0
        break;
215
37.9M
    }
216
248M
    
return end()129M
;
217
248M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
5.65M
  iterator findIndex(unsigned Idx) {
205
5.65M
    assert(Idx < Universe && "Key out of range");
206
5.65M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
6.70M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride1.04M
) {
208
4.50M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
4.50M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
4.50M
      if (Idx == FoundIdx)
211
3.45M
        return begin() + i;
212
1.04M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
1.04M
      if (!Stride)
214
0
        break;
215
1.04M
    }
216
5.65M
    
return end()2.20M
;
217
5.65M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
220k
  iterator findIndex(unsigned Idx) {
205
220k
    assert(Idx < Universe && "Key out of range");
206
220k
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
387k
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride167k
) {
208
327k
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
327k
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
327k
      if (Idx == FoundIdx)
211
160k
        return begin() + i;
212
167k
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
167k
      if (!Stride)
214
0
        break;
215
167k
    }
216
220k
    
return end()59.7k
;
217
220k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
2.92M
  iterator findIndex(unsigned Idx) {
205
2.92M
    assert(Idx < Universe && "Key out of range");
206
2.92M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
5.58M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride2.66M
) {
208
3.21M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
3.21M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
3.21M
      if (Idx == FoundIdx)
211
555k
        return begin() + i;
212
2.66M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
2.66M
      if (!Stride)
214
0
        break;
215
2.66M
    }
216
2.92M
    
return end()2.36M
;
217
2.92M
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
37.1M
  iterator findIndex(unsigned Idx) {
205
37.1M
    assert(Idx < Universe && "Key out of range");
206
37.1M
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
59.3M
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride22.2M
) {
208
38.1M
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
38.1M
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
38.1M
      if (Idx == FoundIdx)
211
15.9M
        return begin() + i;
212
22.2M
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
22.2M
      if (!Stride)
214
0
        break;
215
22.2M
    }
216
37.1M
    
return end()21.1M
;
217
37.1M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::findIndex(unsigned int)
Line
Count
Source
204
638
  iterator findIndex(unsigned Idx) {
205
638
    assert(Idx < Universe && "Key out of range");
206
638
    const unsigned Stride = std::numeric_limits<SparseT>::max() + 1u;
207
798
    for (unsigned i = Sparse[Idx], e = size(); i < e; 
i += Stride160
) {
208
614
      const unsigned FoundIdx = ValIndexOf(Dense[i]);
209
614
      assert(FoundIdx < Universe && "Invalid key in set. Did object mutate?");
210
614
      if (Idx == FoundIdx)
211
454
        return begin() + i;
212
160
      // Stride is 0 when SparseT >= unsigned.  We don't need to loop.
213
160
      if (!Stride)
214
0
        break;
215
160
    }
216
638
    
return end()184
;
217
638
  }
218
219
  /// find - Find an element by its key.
220
  ///
221
  /// @param   Key A valid key to find.
222
  /// @returns An iterator to the element identified by key, or end().
223
  ///
224
69.9M
  iterator find(const KeyT &Key) {
225
69.9M
    return findIndex(KeyIndexOf(Key));
226
69.9M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::find(unsigned short const&)
Line
Count
Source
224
61.7M
  iterator find(const KeyT &Key) {
225
61.7M
    return findIndex(KeyIndexOf(Key));
226
61.7M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
224
772
  iterator find(const KeyT &Key) {
225
772
    return findIndex(KeyIndexOf(Key));
226
772
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
224
2.93M
  iterator find(const KeyT &Key) {
225
2.93M
    return findIndex(KeyIndexOf(Key));
226
2.93M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
224
5.05k
  iterator find(const KeyT &Key) {
225
5.05k
    return findIndex(KeyIndexOf(Key));
226
5.05k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
224
5.27M
  iterator find(const KeyT &Key) {
225
5.27M
    return findIndex(KeyIndexOf(Key));
226
5.27M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&)
Line
Count
Source
224
138
  iterator find(const KeyT &Key) {
225
138
    return findIndex(KeyIndexOf(Key));
226
138
  }
227
228
37.5M
  const_iterator find(const KeyT &Key) const {
229
37.5M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
230
37.5M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::find(unsigned short const&) const
Line
Count
Source
228
14.8M
  const_iterator find(const KeyT &Key) const {
229
14.8M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
230
14.8M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
228
87.7k
  const_iterator find(const KeyT &Key) const {
229
87.7k
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
230
87.7k
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::find(unsigned int const&) const
Line
Count
Source
228
709k
  const_iterator find(const KeyT &Key) const {
229
709k
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
230
709k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
228
21.9M
  const_iterator find(const KeyT &Key) const {
229
21.9M
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
230
21.9M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::find(unsigned int const&) const
Line
Count
Source
228
146
  const_iterator find(const KeyT &Key) const {
229
146
    return const_cast<SparseSet*>(this)->findIndex(KeyIndexOf(Key));
230
146
  }
231
232
  /// count - Returns 1 if this set contains an element identified by Key,
233
  /// 0 otherwise.
234
  ///
235
15.5M
  size_type count(const KeyT &Key) const {
236
15.5M
    return find(Key) == end() ? 
011.1M
:
14.37M
;
237
15.5M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::count(unsigned short const&) const
Line
Count
Source
235
14.8M
  size_type count(const KeyT &Key) const {
236
14.8M
    return find(Key) == end() ? 
010.9M
:
13.90M
;
237
14.8M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::count(unsigned int const&) const
Line
Count
Source
235
709k
  size_type count(const KeyT &Key) const {
236
709k
    return find(Key) == end() ? 
0237k
:
1471k
;
237
709k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::count(unsigned int const&) const
Line
Count
Source
235
146
  size_type count(const KeyT &Key) const {
236
146
    return find(Key) == end() ? 
08
:
1138
;
237
146
  }
238
239
  /// insert - Attempts to insert a new element.
240
  ///
241
  /// If Val is successfully inserted, return (I, true), where I is an iterator
242
  /// pointing to the newly inserted element.
243
  ///
244
  /// If the set already contains an element with the same key as Val, return
245
  /// (I, false), where I is an iterator pointing to the existing element.
246
  ///
247
  /// Insertion invalidates all iterators.
248
  ///
249
335M
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
335M
    unsigned Idx = ValIndexOf(Val);
251
335M
    iterator I = findIndex(Idx);
252
335M
    if (I != end())
253
133M
      return std::make_pair(I, false);
254
201M
    Sparse[Idx] = size();
255
201M
    Dense.push_back(Val);
256
201M
    return std::make_pair(end() - 1, true);
257
201M
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::insert(unsigned short const&)
Line
Count
Source
249
72.5M
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
72.5M
    unsigned Idx = ValIndexOf(Val);
251
72.5M
    iterator I = findIndex(Idx);
252
72.5M
    if (I != end())
253
10.5M
      return std::make_pair(I, false);
254
62.0M
    Sparse[Idx] = size();
255
62.0M
    Dense.push_back(Val);
256
62.0M
    return std::make_pair(end() - 1, true);
257
62.0M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::insert(unsigned int const&)
Line
Count
Source
249
248M
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
248M
    unsigned Idx = ValIndexOf(Val);
251
248M
    iterator I = findIndex(Idx);
252
248M
    if (I != end())
253
118M
      return std::make_pair(I, false);
254
129M
    Sparse[Idx] = size();
255
129M
    Dense.push_back(Val);
256
129M
    return std::make_pair(end() - 1, true);
257
129M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::insert(llvm::LiveRegUnit const&)
Line
Count
Source
249
2.72M
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
2.72M
    unsigned Idx = ValIndexOf(Val);
251
2.72M
    iterator I = findIndex(Idx);
252
2.72M
    if (I != end())
253
1.20M
      return std::make_pair(I, false);
254
1.52M
    Sparse[Idx] = size();
255
1.52M
    Dense.push_back(Val);
256
1.52M
    return std::make_pair(end() - 1, true);
257
1.52M
  }
RegAllocFast.cpp:llvm::SparseSet<(anonymous namespace)::RegAllocFast::LiveReg, llvm::identity<unsigned int>, unsigned char>::insert((anonymous namespace)::RegAllocFast::LiveReg const&)
Line
Count
Source
249
127k
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
127k
    unsigned Idx = ValIndexOf(Val);
251
127k
    iterator I = findIndex(Idx);
252
127k
    if (I != end())
253
67.6k
      return std::make_pair(I, false);
254
59.7k
    Sparse[Idx] = size();
255
59.7k
    Dense.push_back(Val);
256
59.7k
    return std::make_pair(end() - 1, true);
257
59.7k
  }
llvm::SparseSet<llvm::LiveRegSet::IndexMaskPair, llvm::identity<unsigned int>, unsigned char>::insert(llvm::LiveRegSet::IndexMaskPair const&)
Line
Count
Source
249
9.88M
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
9.88M
    unsigned Idx = ValIndexOf(Val);
251
9.88M
    iterator I = findIndex(Idx);
252
9.88M
    if (I != end())
253
3.86M
      return std::make_pair(I, false);
254
6.02M
    Sparse[Idx] = size();
255
6.02M
    Dense.push_back(Val);
256
6.02M
    return std::make_pair(end() - 1, true);
257
6.02M
  }
llvm::SparseSet<unsigned int, llvm::VirtReg2IndexFunctor, unsigned char>::insert(unsigned int const&)
Line
Count
Source
249
2.21M
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
2.21M
    unsigned Idx = ValIndexOf(Val);
251
2.21M
    iterator I = findIndex(Idx);
252
2.21M
    if (I != end())
253
84.0k
      return std::make_pair(I, false);
254
2.13M
    Sparse[Idx] = size();
255
2.13M
    Dense.push_back(Val);
256
2.13M
    return std::make_pair(end() - 1, true);
257
2.13M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::insert(llvm::SchedDFSImpl::RootData const&)
Line
Count
Source
249
354
  std::pair<iterator, bool> insert(const ValueT &Val) {
250
354
    unsigned Idx = ValIndexOf(Val);
251
354
    iterator I = findIndex(Idx);
252
354
    if (I != end())
253
178
      return std::make_pair(I, false);
254
176
    Sparse[Idx] = size();
255
176
    Dense.push_back(Val);
256
176
    return std::make_pair(end() - 1, true);
257
176
  }
258
259
  /// array subscript - If an element already exists with this key, return it.
260
  /// Otherwise, automatically construct a new value from Key, insert it,
261
  /// and return the newly inserted element.
262
2.72M
  ValueT &operator[](const KeyT &Key) {
263
2.72M
    return *insert(ValueT(Key)).first;
264
2.72M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::operator[](unsigned int const&)
Line
Count
Source
262
2.72M
  ValueT &operator[](const KeyT &Key) {
263
2.72M
    return *insert(ValueT(Key)).first;
264
2.72M
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::operator[](unsigned int const&)
Line
Count
Source
262
354
  ValueT &operator[](const KeyT &Key) {
263
354
    return *insert(ValueT(Key)).first;
264
354
  }
265
266
109M
  ValueT pop_back_val() {
267
109M
    // Sparse does not need to be cleared, see find().
268
109M
    return Dense.pop_back_val();
269
109M
  }
270
271
  /// erase - Erases an existing element identified by a valid iterator.
272
  ///
273
  /// This invalidates all iterators, but erase() returns an iterator pointing
274
  /// to the next element.  This makes it possible to erase selected elements
275
  /// while iterating over the set:
276
  ///
277
  ///   for (SparseSet::iterator I = Set.begin(); I != Set.end();)
278
  ///     if (test(*I))
279
  ///       I = Set.erase(I);
280
  ///     else
281
  ///       ++I;
282
  ///
283
  /// Note that end() changes when elements are erased, unlike std::list.
284
  ///
285
25.3M
  iterator erase(iterator I) {
286
25.3M
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
287
25.3M
    if (I != end() - 1) {
288
21.0M
      *I = Dense.back();
289
21.0M
      unsigned BackIdx = ValIndexOf(Dense.back());
290
21.0M
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
291
21.0M
      Sparse[BackIdx] = I - begin();
292
21.0M
    }
293
25.3M
    // This depends on SmallVector::pop_back() not invalidating iterators.
294
25.3M
    // std::vector::pop_back() doesn't give that guarantee.
295
25.3M
    Dense.pop_back();
296
25.3M
    return I;
297
25.3M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int*)
Line
Count
Source
285
706
  iterator erase(iterator I) {
286
706
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
287
706
    if (I != end() - 1) {
288
7
      *I = Dense.back();
289
7
      unsigned BackIdx = ValIndexOf(Dense.back());
290
7
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
291
7
      Sparse[BackIdx] = I - begin();
292
7
    }
293
706
    // This depends on SmallVector::pop_back() not invalidating iterators.
294
706
    // std::vector::pop_back() doesn't give that guarantee.
295
706
    Dense.pop_back();
296
706
    return I;
297
706
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::erase(unsigned short*)
Line
Count
Source
285
24.4M
  iterator erase(iterator I) {
286
24.4M
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
287
24.4M
    if (I != end() - 1) {
288
20.8M
      *I = Dense.back();
289
20.8M
      unsigned BackIdx = ValIndexOf(Dense.back());
290
20.8M
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
291
20.8M
      Sparse[BackIdx] = I - begin();
292
20.8M
    }
293
24.4M
    // This depends on SmallVector::pop_back() not invalidating iterators.
294
24.4M
    // std::vector::pop_back() doesn't give that guarantee.
295
24.4M
    Dense.pop_back();
296
24.4M
    return I;
297
24.4M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::erase(llvm::LiveRegUnit*)
Line
Count
Source
285
911k
  iterator erase(iterator I) {
286
911k
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
287
911k
    if (I != end() - 1) {
288
166k
      *I = Dense.back();
289
166k
      unsigned BackIdx = ValIndexOf(Dense.back());
290
166k
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
291
166k
      Sparse[BackIdx] = I - begin();
292
166k
    }
293
911k
    // This depends on SmallVector::pop_back() not invalidating iterators.
294
911k
    // std::vector::pop_back() doesn't give that guarantee.
295
911k
    Dense.pop_back();
296
911k
    return I;
297
911k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::erase(llvm::SchedDFSImpl::RootData*)
Line
Count
Source
285
138
  iterator erase(iterator I) {
286
138
    assert(unsigned(I - begin()) < size() && "Invalid iterator");
287
138
    if (I != end() - 1) {
288
56
      *I = Dense.back();
289
56
      unsigned BackIdx = ValIndexOf(Dense.back());
290
56
      assert(BackIdx < Universe && "Invalid key in set. Did object mutate?");
291
56
      Sparse[BackIdx] = I - begin();
292
56
    }
293
138
    // This depends on SmallVector::pop_back() not invalidating iterators.
294
138
    // std::vector::pop_back() doesn't give that guarantee.
295
138
    Dense.pop_back();
296
138
    return I;
297
138
  }
298
299
  /// erase - Erases an element identified by Key, if it exists.
300
  ///
301
  /// @param   Key The key identifying the element to erase.
302
  /// @returns True when an element was erased, false if no element was found.
303
  ///
304
61.8M
  bool erase(const KeyT &Key) {
305
61.8M
    iterator I = find(Key);
306
61.8M
    if (I == end())
307
38.4M
      return false;
308
23.3M
    erase(I);
309
23.3M
    return true;
310
23.3M
  }
llvm::SparseSet<unsigned int, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
304
766
  bool erase(const KeyT &Key) {
305
766
    iterator I = find(Key);
306
766
    if (I == end())
307
63
      return false;
308
703
    erase(I);
309
703
    return true;
310
703
  }
llvm::SparseSet<unsigned short, llvm::identity<unsigned short>, unsigned char>::erase(unsigned short const&)
Line
Count
Source
304
61.7M
  bool erase(const KeyT &Key) {
305
61.7M
    iterator I = find(Key);
306
61.7M
    if (I == end())
307
38.4M
      return false;
308
23.3M
    erase(I);
309
23.3M
    return true;
310
23.3M
  }
llvm::SparseSet<llvm::LiveRegUnit, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
304
73.9k
  bool erase(const KeyT &Key) {
305
73.9k
    iterator I = find(Key);
306
73.9k
    if (I == end())
307
47.1k
      return false;
308
26.7k
    erase(I);
309
26.7k
    return true;
310
26.7k
  }
llvm::SparseSet<llvm::SchedDFSImpl::RootData, llvm::identity<unsigned int>, unsigned char>::erase(unsigned int const&)
Line
Count
Source
304
138
  bool erase(const KeyT &Key) {
305
138
    iterator I = find(Key);
306
138
    if (I == end())
307
0
      return false;
308
138
    erase(I);
309
138
    return true;
310
138
  }
311
};
312
313
} // end namespace llvm
314
315
#endif // LLVM_ADT_SPARSESET_H