This is analogous to D17572 (and the diff is based upon it). Extract a part of isDereferenceableAndAlignedPointer functionality to Value::isPointerDereferenceable. The difference between those function is that isPointerDereferenceable can be used for opaque types.
|96 ↗||(On Diff #49073)|
Leaving CheckForNull unimplemented seems prone to confusion, and this assert text does not say that this is not yet implemented. Do you just need to call isKnownNonNull? If so, do that.
I should've been clearer: this is in context of removing pointee types
from LLVM, and having only on pointer type per address space. In that
world, the current trick of "remembering" the number of bytes we want
dereferenceable implicitly via the type of the pointer won't work.
Perhaps a slightly more future proof API would be:
bool isPointerDereferenceable(bool &CanBeNull, unsigned SizeInBytes) const;
so that it can work with (made up syntax):
%ptr = alloca i32 ... ;; ptr is of type pointer addrspace(1), no i32 involved %val = select <cond>, ..., %ptr load i16, %val ;; dereferenceable
%ptr = alloca i32 ... ;; ptr is of type pointer addrspace(1), no i32 involved %val = select <cond>, ..., %ptr load i64, %val ;; not dereferenceable
However, your patch does not make things any worse, so this is a minor
nit at best, fix at your own discretion.