[PATCH] D27114: Preserve nonnull metadata on Loads through SROA & mem2reg.

Luqman Aden via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 29 12:53:09 PST 2016


luqmana added a comment.

In https://reviews.llvm.org/D27114#629295, @chandlerc wrote:

> In https://reviews.llvm.org/D27114#628901, @efriedma wrote:
>
> > > The problem wasn't that. We do have llvm.assume which InstCombine turns assume( (load addr) != null ) to a load addr !nonnull. Then, SROA/mem2reg end up eating the !nonnull metadata.
> >
> > You can do the reverse transform in mem2reg: load addr !nonnull -> assume( (load addr) != null ), then when the load gets erased the nonnull assumption is preserved.
>
>
> Or we could stop instcombine from doing this in the first place.
>
> I think we should canonicalize on the assume formulation as it is strictly more general than the nonnull metadata formulation.


For this change I just implemented @efriedma's suggestion. I think changing how nonnull-ness is canonicalized is outside the scope of this.


https://reviews.llvm.org/D27114





More information about the llvm-commits mailing list