Update prebuilt Clang to r416183b from Android.
https://android.googlesource.com/platform/prebuilts/clang/host/
linux-x86/+/06a71ddac05c22edb2d10b590e1769b3f8619bef
clang 12.0.5 (based on r416183b) from build 7284624.
Change-Id: I277a316abcf47307562d8b748b84870f31a72866
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
diff --git a/linux-x64/clang/include/llvm/IR/ValueHandle.h b/linux-x64/clang/include/llvm/IR/ValueHandle.h
index 1135d79..a88b28a 100644
--- a/linux-x64/clang/include/llvm/IR/ValueHandle.h
+++ b/linux-x64/clang/include/llvm/IR/ValueHandle.h
@@ -89,7 +89,11 @@
}
Value *operator->() const { return getValPtr(); }
- Value &operator*() const { return *getValPtr(); }
+ Value &operator*() const {
+ Value *V = getValPtr();
+ assert(V && "Dereferencing deleted ValueHandle");
+ return *V;
+ }
protected:
Value *getValPtr() const { return Val; }
@@ -171,6 +175,25 @@
static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
};
+// Specialize DenseMapInfo to allow WeakVH to participate in DenseMap.
+template <> struct DenseMapInfo<WeakVH> {
+ static inline WeakVH getEmptyKey() {
+ return WeakVH(DenseMapInfo<Value *>::getEmptyKey());
+ }
+
+ static inline WeakVH getTombstoneKey() {
+ return WeakVH(DenseMapInfo<Value *>::getTombstoneKey());
+ }
+
+ static unsigned getHashValue(const WeakVH &Val) {
+ return DenseMapInfo<Value *>::getHashValue(Val);
+ }
+
+ static bool isEqual(const WeakVH &LHS, const WeakVH &RHS) {
+ return DenseMapInfo<Value *>::isEqual(LHS, RHS);
+ }
+};
+
/// Value handle that is nullable, but tries to track the Value.
///
/// This is a value handle that tries hard to point to a Value, even across
@@ -235,13 +258,13 @@
/// class turns into a trivial wrapper around a pointer.
template <typename ValueTy>
class AssertingVH
-#ifndef NDEBUG
- : public ValueHandleBase
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ : public ValueHandleBase
#endif
- {
+{
friend struct DenseMapInfo<AssertingVH<ValueTy>>;
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
Value *getRawValPtr() const { return ValueHandleBase::getValPtr(); }
void setRawValPtr(Value *P) { ValueHandleBase::operator=(P); }
#else
@@ -257,13 +280,14 @@
void setValPtr(ValueTy *P) { setRawValPtr(GetAsValue(P)); }
public:
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
AssertingVH() : ValueHandleBase(Assert) {}
AssertingVH(ValueTy *P) : ValueHandleBase(Assert, GetAsValue(P)) {}
AssertingVH(const AssertingVH &RHS) : ValueHandleBase(Assert, RHS) {}
#else
AssertingVH() : ThePtr(nullptr) {}
AssertingVH(ValueTy *P) : ThePtr(GetAsValue(P)) {}
+ AssertingVH(const AssertingVH<ValueTy> &) = default;
#endif
operator ValueTy*() const {
@@ -283,30 +307,10 @@
ValueTy &operator*() const { return *getValPtr(); }
};
-// Specialize DenseMapInfo to allow AssertingVH to participate in DenseMap.
+// Treat AssertingVH<T> like T* inside maps. This also allows using find_as()
+// to look up a value without constructing a value handle.
template<typename T>
-struct DenseMapInfo<AssertingVH<T>> {
- static inline AssertingVH<T> getEmptyKey() {
- AssertingVH<T> Res;
- Res.setRawValPtr(DenseMapInfo<Value *>::getEmptyKey());
- return Res;
- }
-
- static inline AssertingVH<T> getTombstoneKey() {
- AssertingVH<T> Res;
- Res.setRawValPtr(DenseMapInfo<Value *>::getTombstoneKey());
- return Res;
- }
-
- static unsigned getHashValue(const AssertingVH<T> &Val) {
- return DenseMapInfo<Value *>::getHashValue(Val.getRawValPtr());
- }
-
- static bool isEqual(const AssertingVH<T> &LHS, const AssertingVH<T> &RHS) {
- return DenseMapInfo<Value *>::isEqual(LHS.getRawValPtr(),
- RHS.getRawValPtr());
- }
-};
+struct DenseMapInfo<AssertingVH<T>> : DenseMapInfo<T *> {};
/// Value handle that tracks a Value across RAUW.
///
@@ -390,6 +394,7 @@
public:
CallbackVH() : ValueHandleBase(Callback) {}
CallbackVH(Value *P) : ValueHandleBase(Callback, P) {}
+ CallbackVH(const Value *P) : CallbackVH(const_cast<Value *>(P)) {}
operator Value*() const {
return getValPtr();
@@ -438,7 +443,7 @@
/// class turns into a trivial wrapper around a pointer.
template <typename ValueTy>
class PoisoningVH
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
final : public CallbackVH
#endif
{
@@ -448,7 +453,7 @@
static Value *GetAsValue(Value *V) { return V; }
static Value *GetAsValue(const Value *V) { return const_cast<Value *>(V); }
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
/// A flag tracking whether this value has been poisoned.
///
/// On delete and RAUW, we leave the value pointer alone so that as a raw
@@ -473,7 +478,7 @@
Poisoned = true;
RemoveFromUseList();
}
-#else // NDEBUG
+#else // LLVM_ENABLE_ABI_BREAKING_CHECKS
Value *ThePtr = nullptr;
Value *getRawValPtr() const { return ThePtr; }
@@ -481,14 +486,16 @@
#endif
ValueTy *getValPtr() const {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
assert(!Poisoned && "Accessed a poisoned value handle!");
+#endif
return static_cast<ValueTy *>(getRawValPtr());
}
void setValPtr(ValueTy *P) { setRawValPtr(GetAsValue(P)); }
public:
PoisoningVH() = default;
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
PoisoningVH(ValueTy *P) : CallbackVH(GetAsValue(P)) {}
PoisoningVH(const PoisoningVH &RHS)
: CallbackVH(RHS), Poisoned(RHS.Poisoned) {}
@@ -537,6 +544,17 @@
return DenseMapInfo<Value *>::isEqual(LHS.getRawValPtr(),
RHS.getRawValPtr());
}
+
+ // Allow lookup by T* via find_as(), without constructing a temporary
+ // value handle.
+
+ static unsigned getHashValue(const T *Val) {
+ return DenseMapInfo<Value *>::getHashValue(Val);
+ }
+
+ static bool isEqual(const T *LHS, const PoisoningVH<T> &RHS) {
+ return DenseMapInfo<Value *>::isEqual(LHS, RHS.getRawValPtr());
+ }
};
} // end namespace llvm