llvm.org GIT mirror llvm / 4e58263
DenseMap: Perform the pod-like object optimization when the value type is POD-like, not the DenseMapInfo for it. Purge now unused template arguments. This has been broken since r91421. Patch by Lubos Lunak! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154170 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 8 years ago
4 changed file(s) with 26 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
2929
3030 template
3131 typename KeyInfoT = DenseMapInfo,
32 typename ValueInfoT = DenseMapInfo, bool IsConst = false>
32 bool IsConst = false>
3333 class DenseMapIterator;
3434
3535 template
36 typename KeyInfoT = DenseMapInfo,
37 typename ValueInfoT = DenseMapInfoT> >
36 typename KeyInfoT = DenseMapInfoT> >
3837 class DenseMap {
3938 typedef std::pair BucketT;
4039 unsigned NumBuckets;
7978
8079 typedef DenseMapIterator iterator;
8180 typedef DenseMapIterator
82 KeyInfoT, ValueInfoT, true> const_iterator;
81 KeyInfoT, true> const_iterator;
8382 inline iterator begin() {
8483 // When the map is empty, avoid the overhead of AdvancePastEmptyBuckets().
8584 return empty() ? end() : iterator(Buckets, Buckets+NumBuckets);
255254 private:
256255 void CopyFrom(const DenseMap& other) {
257256 if (NumBuckets != 0 &&
258 (!isPodLikeInfoT>::value || !isPodLikeT>::value)) {
257 (!isPodLikeT>::value || !isPodLikeT>::value)) {
259258 const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
260259 for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
261260 if (!KeyInfoT::isEqual(P->first, EmptyKey) &&
284283
285284 Buckets = static_cast(operator new(sizeof(BucketT) * NumBuckets));
286285
287 if (isPodLikeInfoT>::value && isPodLikeT>::value)
286 if (isPodLikeT>::value && isPodLikeT>::value)
288287 memcpy(Buckets, other.Buckets, NumBuckets * sizeof(BucketT));
289288 else
290289 for (size_t i = 0; i < NumBuckets; ++i) {
501500 };
502501
503502 template
504 typename KeyInfoT, typename ValueInfoT, bool IsConst>
503 typename KeyInfoT, bool IsConst>
505504 class DenseMapIterator {
506505 typedef std::pair Bucket;
507506 typedef DenseMapIterator
508 KeyInfoT, ValueInfoT, true> ConstIterator;
509 friend class DenseMapIterator;
507 KeyInfoT, true> ConstIterator;
508 friend class DenseMapIterator;
510509 public:
511510 typedef ptrdiff_t difference_type;
512511 typedef typename conditional::type value_type;
527526 // const_iterator and the default copy constructor is used.
528527 // Otherwise this is a copy constructor for iterator.
529528 DenseMapIterator(const DenseMapIterator
530 KeyInfoT, ValueInfoT, false>& I)
529 KeyInfoT, false>& I)
531530 : Ptr(I.Ptr), End(I.End) {}
532531
533532 reference operator*() const {
565564 }
566565 };
567566
568 template, typename ValueInfoT>
567 template>
569568 static inline size_t
570 capacity_in_bytes(const DenseMap, ValueInfoT> &X) {
569 capacity_in_bytes(const DenseMap> &X) {
571570 return X.getMemorySize();
572571 }
573572
3434
3535 namespace llvm {
3636
37 template, typename ValueInfoT>
37 template>
3838 class ValueMapCallbackVH;
3939
4040 template
7171 };
7272
7373 /// See the file comment.
74 template,
75 typename ValueInfoT = DenseMapInfoT> >
74 templateT> >
7675 class ValueMap {
77 friend class ValueMapCallbackVH;
78 typedef ValueMapCallbackVH ValueMapCVH;
79 typedef DenseMap,
80 ValueInfoT> MapT;
76 friend class ValueMapCallbackVH;
77 typedef ValueMapCallbackVH ValueMapCVH;
78 typedef DenseMap > MapT;
8179 typedef typename Config::ExtraData ExtraData;
8280 MapT Map;
8381 ExtraData Data;
189187
190188 // This CallbackVH updates its ValueMap when the contained Value changes,
191189 // according to the user's preferences expressed through the Config object.
192 template, typename ValueInfoT>
190 template>
193191 class ValueMapCallbackVH : public CallbackVH {
194 friend class ValueMap, ValueInfoT>;
192 friend class ValueMap>;
195193 friend struct DenseMapInfo;
196 typedef ValueMap, ValueInfoT> ValueMapT;
194 typedef ValueMap> ValueMapT;
197195 typedef typename llvm::remove_pointer::type KeySansPointerT;
198196
199197 ValueMapT *Map;
243241 }
244242 };
245243
246 template
247 struct DenseMapInfo > {
248 typedef ValueMapCallbackVH VH;
244 template
245 struct DenseMapInfo > {
246 typedef ValueMapCallbackVH VH;
249247 typedef DenseMapInfo PointerInfo;
250248
251249 static inline VH getEmptyKey() {
2929 class LLVMContext;
3030 class StructType;
3131 template struct DenseMapInfo;
32 template
33 typename KeyInfoT, typename ValueInfoT> class DenseMap;
32 templateInfoT> class DenseMap;
3433
3534 template<> struct ilist_traits
3635 : public SymbolTableListTraits {
298297 void getMDKindNames(SmallVectorImpl &Result) const;
299298
300299
301 typedef DenseMap,
302 DenseMapInfo > NumeredTypesMapTy;
300 typedef DenseMap >
301 NumeredTypesMapTy;
303302
304303 /// findUsedStructTypes - Walk the entire module and find all of the
305304 /// struct types that are in use, returning them in a vector.
6565 // std::pair's are pod-like if their elements are.
6666 template
6767 struct isPodLike > {
68 static const bool value = isPodLike::value & isPodLike::value;
68 static const bool value = isPodLike::value && isPodLike::value;
6969 };
7070
7171