mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
When forming sentinels for empty/tombstone, make sure to respect the
pointer's expected number of zero low-bits. This should fix the breakage I introduced recently. llvm-svn: 67990
This commit is contained in:
parent
696742399a
commit
f3d562df05
@ -14,7 +14,7 @@
|
|||||||
#ifndef LLVM_ADT_DENSEMAP_H
|
#ifndef LLVM_ADT_DENSEMAP_H
|
||||||
#define LLVM_ADT_DENSEMAP_H
|
#define LLVM_ADT_DENSEMAP_H
|
||||||
|
|
||||||
#include "llvm/Support/DataTypes.h"
|
#include "llvm/Support/PointerLikeTypeTraits.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@ -33,8 +33,16 @@ struct DenseMapInfo {
|
|||||||
// Provide DenseMapInfo for all pointers.
|
// Provide DenseMapInfo for all pointers.
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct DenseMapInfo<T*> {
|
struct DenseMapInfo<T*> {
|
||||||
static inline T* getEmptyKey() { return reinterpret_cast<T*>(-1); }
|
static inline T* getEmptyKey() {
|
||||||
static inline T* getTombstoneKey() { return reinterpret_cast<T*>(-2); }
|
intptr_t Val = -1;
|
||||||
|
Val <<= PointerLikeTypeTraits<T*>::NumLowBitsAvailable;
|
||||||
|
return reinterpret_cast<T*>(Val);
|
||||||
|
}
|
||||||
|
static inline T* getTombstoneKey() {
|
||||||
|
intptr_t Val = -2;
|
||||||
|
Val <<= PointerLikeTypeTraits<T*>::NumLowBitsAvailable;
|
||||||
|
return reinterpret_cast<T*>(Val);
|
||||||
|
}
|
||||||
static unsigned getHashValue(const T *PtrVal) {
|
static unsigned getHashValue(const T *PtrVal) {
|
||||||
return (unsigned((uintptr_t)PtrVal) >> 4) ^
|
return (unsigned((uintptr_t)PtrVal) >> 4) ^
|
||||||
(unsigned((uintptr_t)PtrVal) >> 9);
|
(unsigned((uintptr_t)PtrVal) >> 9);
|
||||||
|
@ -107,11 +107,14 @@ template<typename PointerTy, unsigned IntBits, typename IntType>
|
|||||||
struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
|
struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType> > {
|
||||||
typedef PointerIntPair<PointerTy, IntBits, IntType> Ty;
|
typedef PointerIntPair<PointerTy, IntBits, IntType> Ty;
|
||||||
static Ty getEmptyKey() {
|
static Ty getEmptyKey() {
|
||||||
return Ty(reinterpret_cast<PointerTy>(-1 << IntBits),
|
intptr_t Val = -1;
|
||||||
IntType((1 << IntBits)-1));
|
Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
|
||||||
|
return Ty(reinterpret_cast<PointerTy>(Val), IntType((1 << IntBits)-1));
|
||||||
}
|
}
|
||||||
static Ty getTombstoneKey() {
|
static Ty getTombstoneKey() {
|
||||||
return Ty(reinterpret_cast<PointerTy>(-2 << IntBits), IntType(0));
|
intptr_t Val = -2;
|
||||||
|
Val <<= PointerLikeTypeTraits<PointerTy>::NumLowBitsAvailable;
|
||||||
|
return Ty(reinterpret_cast<PointerTy>(Val), IntType(0));
|
||||||
}
|
}
|
||||||
static unsigned getHashValue(Ty V) {
|
static unsigned getHashValue(Ty V) {
|
||||||
uintptr_t IV = reinterpret_cast<uintptr_t>(V.getOpaqueValue());
|
uintptr_t IV = reinterpret_cast<uintptr_t>(V.getOpaqueValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user