[PATCH] D69542: Full Restrict Support - single patch

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 22:32:44 PST 2020


barannikov88 added inline comments.
Herald added a subscriber: lxfind.


================
Comment at: llvm/lib/Analysis/BasicAliasAnalysis.cpp:1770-1771
+    // No noalias info - look through noalias intrinsics in a safe way
+    V1 = V1->stripPointerCastsAndInvariantGroupsAndNoAliasIntr();
+    V2 = V2->stripPointerCastsAndInvariantGroupsAndNoAliasIntr();
+    V1AAInfo.clearNoAliasInfo();
----------------
Suppose we have `V2` with valid noalias provenance, and `V1` without it.
`V1` is a long chain of GEPs (longer than `MaxLookupSearchDepth`), finished with `noalias.arg.guard`.

When `aliasCheck` is called the first time, we get into the "then" branch of the "if", strip nothing, and `getUnderlyingObject` finds some base for `V1` at the depth `MaxLookupSearchDepth`. This object will be passed to a recursive call of `aliasCheck` later as `O1`.

After that, `aliasCheck` is called recursively from `aliasGEP`, this time with `O1 != nullptr` and empty `V2AAInfo`. We get into the `else` branch of the `if` and strip out `noalias.arg.guard` from `V1` chain. This effectively decreases depth of the expression, and `DecomposeGEP` called later from `aliasGEP` will return _different_ base object from `O1`.

This leads to failed assertion in `aliasGEP` which checks that `DecomposeGEP` found the same base as `getUnderlyingObject`.



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

https://reviews.llvm.org/D69542



More information about the llvm-commits mailing list