mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
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
This commit is contained in:
@@ -30,12 +30,11 @@ namespace llvm {
|
|||||||
|
|
||||||
template<typename KeyT, typename ValueT,
|
template<typename KeyT, typename ValueT,
|
||||||
typename KeyInfoT = DenseMapInfo<KeyT>,
|
typename KeyInfoT = DenseMapInfo<KeyT>,
|
||||||
typename ValueInfoT = DenseMapInfo<ValueT>, bool IsConst = false>
|
bool IsConst = false>
|
||||||
class DenseMapIterator;
|
class DenseMapIterator;
|
||||||
|
|
||||||
template<typename KeyT, typename ValueT,
|
template<typename KeyT, typename ValueT,
|
||||||
typename KeyInfoT = DenseMapInfo<KeyT>,
|
typename KeyInfoT = DenseMapInfo<KeyT> >
|
||||||
typename ValueInfoT = DenseMapInfo<ValueT> >
|
|
||||||
class DenseMap {
|
class DenseMap {
|
||||||
typedef std::pair<KeyT, ValueT> BucketT;
|
typedef std::pair<KeyT, ValueT> BucketT;
|
||||||
unsigned NumBuckets;
|
unsigned NumBuckets;
|
||||||
@@ -80,7 +79,7 @@ public:
|
|||||||
|
|
||||||
typedef DenseMapIterator<KeyT, ValueT, KeyInfoT> iterator;
|
typedef DenseMapIterator<KeyT, ValueT, KeyInfoT> iterator;
|
||||||
typedef DenseMapIterator<KeyT, ValueT,
|
typedef DenseMapIterator<KeyT, ValueT,
|
||||||
KeyInfoT, ValueInfoT, true> const_iterator;
|
KeyInfoT, true> const_iterator;
|
||||||
inline iterator begin() {
|
inline iterator begin() {
|
||||||
// When the map is empty, avoid the overhead of AdvancePastEmptyBuckets().
|
// When the map is empty, avoid the overhead of AdvancePastEmptyBuckets().
|
||||||
return empty() ? end() : iterator(Buckets, Buckets+NumBuckets);
|
return empty() ? end() : iterator(Buckets, Buckets+NumBuckets);
|
||||||
@@ -256,7 +255,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void CopyFrom(const DenseMap& other) {
|
void CopyFrom(const DenseMap& other) {
|
||||||
if (NumBuckets != 0 &&
|
if (NumBuckets != 0 &&
|
||||||
(!isPodLike<KeyInfoT>::value || !isPodLike<ValueInfoT>::value)) {
|
(!isPodLike<KeyT>::value || !isPodLike<ValueT>::value)) {
|
||||||
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
|
const KeyT EmptyKey = getEmptyKey(), TombstoneKey = getTombstoneKey();
|
||||||
for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
|
for (BucketT *P = Buckets, *E = Buckets+NumBuckets; P != E; ++P) {
|
||||||
if (!KeyInfoT::isEqual(P->first, EmptyKey) &&
|
if (!KeyInfoT::isEqual(P->first, EmptyKey) &&
|
||||||
@@ -285,7 +284,7 @@ private:
|
|||||||
|
|
||||||
Buckets = static_cast<BucketT*>(operator new(sizeof(BucketT) * NumBuckets));
|
Buckets = static_cast<BucketT*>(operator new(sizeof(BucketT) * NumBuckets));
|
||||||
|
|
||||||
if (isPodLike<KeyInfoT>::value && isPodLike<ValueInfoT>::value)
|
if (isPodLike<KeyT>::value && isPodLike<ValueT>::value)
|
||||||
memcpy(Buckets, other.Buckets, NumBuckets * sizeof(BucketT));
|
memcpy(Buckets, other.Buckets, NumBuckets * sizeof(BucketT));
|
||||||
else
|
else
|
||||||
for (size_t i = 0; i < NumBuckets; ++i) {
|
for (size_t i = 0; i < NumBuckets; ++i) {
|
||||||
@@ -502,12 +501,12 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename KeyT, typename ValueT,
|
template<typename KeyT, typename ValueT,
|
||||||
typename KeyInfoT, typename ValueInfoT, bool IsConst>
|
typename KeyInfoT, bool IsConst>
|
||||||
class DenseMapIterator {
|
class DenseMapIterator {
|
||||||
typedef std::pair<KeyT, ValueT> Bucket;
|
typedef std::pair<KeyT, ValueT> Bucket;
|
||||||
typedef DenseMapIterator<KeyT, ValueT,
|
typedef DenseMapIterator<KeyT, ValueT,
|
||||||
KeyInfoT, ValueInfoT, true> ConstIterator;
|
KeyInfoT, true> ConstIterator;
|
||||||
friend class DenseMapIterator<KeyT, ValueT, KeyInfoT, ValueInfoT, true>;
|
friend class DenseMapIterator<KeyT, ValueT, KeyInfoT, true>;
|
||||||
public:
|
public:
|
||||||
typedef ptrdiff_t difference_type;
|
typedef ptrdiff_t difference_type;
|
||||||
typedef typename conditional<IsConst, const Bucket, Bucket>::type value_type;
|
typedef typename conditional<IsConst, const Bucket, Bucket>::type value_type;
|
||||||
@@ -528,7 +527,7 @@ public:
|
|||||||
// const_iterator and the default copy constructor is used.
|
// const_iterator and the default copy constructor is used.
|
||||||
// Otherwise this is a copy constructor for iterator.
|
// Otherwise this is a copy constructor for iterator.
|
||||||
DenseMapIterator(const DenseMapIterator<KeyT, ValueT,
|
DenseMapIterator(const DenseMapIterator<KeyT, ValueT,
|
||||||
KeyInfoT, ValueInfoT, false>& I)
|
KeyInfoT, false>& I)
|
||||||
: Ptr(I.Ptr), End(I.End) {}
|
: Ptr(I.Ptr), End(I.End) {}
|
||||||
|
|
||||||
reference operator*() const {
|
reference operator*() const {
|
||||||
@@ -566,9 +565,9 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename KeyT, typename ValueT, typename KeyInfoT, typename ValueInfoT>
|
template<typename KeyT, typename ValueT, typename KeyInfoT>
|
||||||
static inline size_t
|
static inline size_t
|
||||||
capacity_in_bytes(const DenseMap<KeyT, ValueT, KeyInfoT, ValueInfoT> &X) {
|
capacity_in_bytes(const DenseMap<KeyT, ValueT, KeyInfoT> &X) {
|
||||||
return X.getMemorySize();
|
return X.getMemorySize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT>
|
template<typename KeyT, typename ValueT, typename Config>
|
||||||
class ValueMapCallbackVH;
|
class ValueMapCallbackVH;
|
||||||
|
|
||||||
template<typename DenseMapT, typename KeyT>
|
template<typename DenseMapT, typename KeyT>
|
||||||
@@ -72,13 +72,11 @@ struct ValueMapConfig {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/// See the file comment.
|
/// See the file comment.
|
||||||
template<typename KeyT, typename ValueT, typename Config = ValueMapConfig<KeyT>,
|
template<typename KeyT, typename ValueT, typename Config =ValueMapConfig<KeyT> >
|
||||||
typename ValueInfoT = DenseMapInfo<ValueT> >
|
|
||||||
class ValueMap {
|
class ValueMap {
|
||||||
friend class ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT>;
|
friend class ValueMapCallbackVH<KeyT, ValueT, Config>;
|
||||||
typedef ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> ValueMapCVH;
|
typedef ValueMapCallbackVH<KeyT, ValueT, Config> ValueMapCVH;
|
||||||
typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH>,
|
typedef DenseMap<ValueMapCVH, ValueT, DenseMapInfo<ValueMapCVH> > MapT;
|
||||||
ValueInfoT> MapT;
|
|
||||||
typedef typename Config::ExtraData ExtraData;
|
typedef typename Config::ExtraData ExtraData;
|
||||||
MapT Map;
|
MapT Map;
|
||||||
ExtraData Data;
|
ExtraData Data;
|
||||||
@@ -190,11 +188,11 @@ private:
|
|||||||
|
|
||||||
// This CallbackVH updates its ValueMap when the contained Value changes,
|
// This CallbackVH updates its ValueMap when the contained Value changes,
|
||||||
// according to the user's preferences expressed through the Config object.
|
// according to the user's preferences expressed through the Config object.
|
||||||
template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT>
|
template<typename KeyT, typename ValueT, typename Config>
|
||||||
class ValueMapCallbackVH : public CallbackVH {
|
class ValueMapCallbackVH : public CallbackVH {
|
||||||
friend class ValueMap<KeyT, ValueT, Config, ValueInfoT>;
|
friend class ValueMap<KeyT, ValueT, Config>;
|
||||||
friend struct DenseMapInfo<ValueMapCallbackVH>;
|
friend struct DenseMapInfo<ValueMapCallbackVH>;
|
||||||
typedef ValueMap<KeyT, ValueT, Config, ValueInfoT> ValueMapT;
|
typedef ValueMap<KeyT, ValueT, Config> ValueMapT;
|
||||||
typedef typename llvm::remove_pointer<KeyT>::type KeySansPointerT;
|
typedef typename llvm::remove_pointer<KeyT>::type KeySansPointerT;
|
||||||
|
|
||||||
ValueMapT *Map;
|
ValueMapT *Map;
|
||||||
@@ -244,9 +242,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename KeyT, typename ValueT, typename Config, typename ValueInfoT>
|
template<typename KeyT, typename ValueT, typename Config>
|
||||||
struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> > {
|
struct DenseMapInfo<ValueMapCallbackVH<KeyT, ValueT, Config> > {
|
||||||
typedef ValueMapCallbackVH<KeyT, ValueT, Config, ValueInfoT> VH;
|
typedef ValueMapCallbackVH<KeyT, ValueT, Config> VH;
|
||||||
typedef DenseMapInfo<KeyT> PointerInfo;
|
typedef DenseMapInfo<KeyT> PointerInfo;
|
||||||
|
|
||||||
static inline VH getEmptyKey() {
|
static inline VH getEmptyKey() {
|
||||||
|
@@ -30,8 +30,7 @@ class GVMaterializer;
|
|||||||
class LLVMContext;
|
class LLVMContext;
|
||||||
class StructType;
|
class StructType;
|
||||||
template<typename T> struct DenseMapInfo;
|
template<typename T> struct DenseMapInfo;
|
||||||
template<typename KeyT, typename ValueT,
|
template<typename KeyT, typename ValueT, typename KeyInfoT> class DenseMap;
|
||||||
typename KeyInfoT, typename ValueInfoT> class DenseMap;
|
|
||||||
|
|
||||||
template<> struct ilist_traits<Function>
|
template<> struct ilist_traits<Function>
|
||||||
: public SymbolTableListTraits<Function, Module> {
|
: public SymbolTableListTraits<Function, Module> {
|
||||||
@@ -299,8 +298,8 @@ public:
|
|||||||
void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
|
void getMDKindNames(SmallVectorImpl<StringRef> &Result) const;
|
||||||
|
|
||||||
|
|
||||||
typedef DenseMap<StructType*, unsigned, DenseMapInfo<StructType*>,
|
typedef DenseMap<StructType*, unsigned, DenseMapInfo<StructType*> >
|
||||||
DenseMapInfo<unsigned> > NumeredTypesMapTy;
|
NumeredTypesMapTy;
|
||||||
|
|
||||||
/// findUsedStructTypes - Walk the entire module and find all of the
|
/// findUsedStructTypes - Walk the entire module and find all of the
|
||||||
/// struct types that are in use, returning them in a vector.
|
/// struct types that are in use, returning them in a vector.
|
||||||
|
@@ -66,7 +66,7 @@ struct isPodLike {
|
|||||||
// std::pair's are pod-like if their elements are.
|
// std::pair's are pod-like if their elements are.
|
||||||
template<typename T, typename U>
|
template<typename T, typename U>
|
||||||
struct isPodLike<std::pair<T, U> > {
|
struct isPodLike<std::pair<T, U> > {
|
||||||
static const bool value = isPodLike<T>::value & isPodLike<U>::value;
|
static const bool value = isPodLike<T>::value && isPodLike<U>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user