[all-commits] [llvm/llvm-project] 61cfdf: [BasicAA] Model implicit trunc of GEP indices

Nikita Popov via All-commits all-commits at lists.llvm.org
Fri Oct 22 14:47:20 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 61cfdf636dc720c0af9d1ba42ead5aea8401d34b
      https://github.com/llvm/llvm-project/commit/61cfdf636dc720c0af9d1ba42ead5aea8401d34b
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-10-22 (Fri, 22 Oct 2021)

  Changed paths:
    M llvm/lib/Analysis/BasicAliasAnalysis.cpp
    M llvm/test/Analysis/BasicAA/gep-implicit-trunc-32-bit-pointers.ll

  Log Message:
  -----------
  [BasicAA] Model implicit trunc of GEP indices

GEP indices larger than the GEP index size are implicitly truncated
to the index size. BasicAA currently doesn't model this, resulting
in incorrect alias analysis results.

Fix this by explicitly modelling truncation in CastedValue in the
same way we do zext and sext. Additionally we need to disable a
number of optimizations for truncated values, in particular
"non-zero" and "non-equal" may no longer hold after truncation.
I believe the constant offset heuristic is also not necessarily
correct for truncated values, but wasn't able to come up with a
test for that one.

A possible followup here would be to use the new mechanism to
model explicit trunc as well (which should be much more common,
as it is the canonical form). This is straightforward, but omitted
here to separate the correctness fix from the analysis improvement.

(Side note: While I say "index size" above, BasicAA currently uses
the pointer size instead. Something for another day...)

Differential Revision: https://reviews.llvm.org/D110977




More information about the All-commits mailing list