[PATCH] D40670: Let Alloca treated as nonnull for any alloca addr space value

Nuno Lopes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 07:27:54 PST 2017


nlopes added a comment.

In https://reviews.llvm.org/D40670#947019, @yaxunl wrote:

> How about introduce nullptr value for each addr space in data layout? E.g., assume alloca addr space is 3 and nullptr value of addr space 3 is -1. alloca of addr space 3 could return 0, but never return -1.
>
> Then this code
>
>   if (isa<AllocaInst>(V) && Q.DL.getAllocaAddrSpace() == 0)
>
>
> can be changed as
>
>   if (isa<AllocaInst>(V) && Q.DL.getAllocaNullPointerValue() == 0)
>
>
> This assumes that alloca never returns nullptr value.
>
> Nuno, Sean, will this work for you?
>
> Thanks.


Sorry for the delay.
What if a target doesn't have an invalid pointer? This is not uncommon in embedded ISAs.

I don't particularly like the idea of mixing null pointers (which we define as having the value zero ATM), alloca not being able to return a null pointer, and the possibility of changing the value of null pointers to a non-zero value.


https://reviews.llvm.org/D40670





More information about the llvm-commits mailing list