[PATCH] D73342: Fix EarlyCSE to intersect aliasing metadata.

Neil Henning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 07:07:47 PST 2020


sheredom added a comment.

In D73342#1839002 <https://reviews.llvm.org/D73342#1839002>, @hfinkel wrote:

> In D73342#1838953 <https://reviews.llvm.org/D73342#1838953>, @nikic wrote:
>
> > Can you explain in more detail why the current behavior is incorrect? Why is using the aliasing information in program order wrong? If the first load is noalias, then we should be able to deduplicate to that noalias load. If the second load is noalias, then generally we can't assume the first load is also noalias. Unless there is a must-exec relation between them, as @nlopes mentioned.
>
>
> We have two issues here;
>
> 1. For any pass, if it changes any instruction with metadata that it does not understand, it should drop that metadata. That's the contract that we need to maintain.
> 2. For this AA metadata in particular, we need to intersect the metadata, and this is true to preserve semantics for almost all other known metadata (AA, profiling, fp-precision, debug) although likely for it is not correct to keep only one, or the other, because of potential dynamic dependencies on the results.
>
>   For AA, as an example, we can have something like this:
>
>   int * restrict r = a; int x = should_alias ? *a : *r;
>
>   (essentially the same is true using casts as TBAA).
>
>   In any case, we should be calling the function llvm::combineMetadataForCSE here. Please update the patch to do that.


So when I use combineMetadataForCSE it breaks the invariant loads tests because the code there just says 'if one thing is invariant load and the other is not, throw the invariant load metadata away'.

What would be the correct fix for this? I don't know a ton about the intracacies of invariant loads.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73342/new/

https://reviews.llvm.org/D73342





More information about the llvm-commits mailing list