[PATCH] D17611: NFC. Introduce Value::isPointerDereferenceable

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 14:34:29 PDT 2016


sanjoy accepted this revision.
sanjoy added a reviewer: sanjoy.
sanjoy added a comment.
This revision is now accepted and ready to land.

In http://reviews.llvm.org/D17611#417343, @apilipenko wrote:

> @Sanjoy, it has nothing to do with pointer types. There are some "kinds" of pointers (e.g. allocas, some globals) which are inherently dereferenceable.


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

and

  %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.


http://reviews.llvm.org/D17611





More information about the llvm-commits mailing list