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

Yaxun Liu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 14:46:06 PST 2017


yaxunl added a comment.

In https://reviews.llvm.org/D40670#952389, @nlopes wrote:

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


How about adding a hook TargetTransformInfo::isAllocaPtrValueNonZero  which returns true if alloca inst value is always non-zero.

The drawback is that some ValueTracking functions will depend on TargetTransformInfo. As a result, those passes using ValueTrackign will require TargetTransformInfo.

What do you think?

Thanks.


https://reviews.llvm.org/D40670





More information about the llvm-commits mailing list