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

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 08:59:02 PST 2020


hfinkel added a comment.

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.


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