[PATCH] D18738: Add new !unconditionally_dereferenceable load instruction metadata

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 15 15:02:20 PST 2017


sanjoy added a comment.

Hi @whitequark,

In https://reviews.llvm.org/D18738#592799, @whitequark wrote:

> @sanjoy OK, I understand now. In a nutshell, our disagreement was in whether dead code in IR can affect semantics of live code. This doesn't strike me as particularly bad (even after looking at your examples--clearly they shouldn't use !unconditionally_dereferenceable, but that doesn't mean it's not useful elsewhere), but you clearly have more experience here, so I won't argue that my approach is viable for upstream.
>
> Do you have any suggestions for implementing this functionality in a cleaner way?


Sorry for the late reply!

The way I'd go about this is to mark the pointers being loaded from as being dereferenceable up to a certain size at the source of the pointer itself.  That is, instead of:

  i8* ptr = x->field;
  val = load i8, i8* (ptr + 32), !unconditionally_dereferenceable

do

  i8* ptr = x->field, !dereferenceable(32 + 1);
  val = load i8, i8* ptr

For return values and incoming arguments, you can use the `dereferenceable` attribute etc.


Repository:
  rL LLVM

https://reviews.llvm.org/D18738





More information about the llvm-commits mailing list