[all-commits] [llvm/llvm-project] 728803: [BasicAA] Use index difference to detect GEPs with...

Nikita Popov via All-commits all-commits at lists.llvm.org
Sun Feb 14 08:25:26 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 728803ed74e26b370600002dcffe4994ce3ec37a
      https://github.com/llvm/llvm-project/commit/728803ed74e26b370600002dcffe4994ce3ec37a
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-02-14 (Sun, 14 Feb 2021)

  Changed paths:
    M llvm/include/llvm/Analysis/BasicAliasAnalysis.h
    M llvm/lib/Analysis/BasicAliasAnalysis.cpp

  Log Message:
  -----------
  [BasicAA] Use index difference to detect GEPs with identical indexes

We currently detect GEPs that have exactly the same indexes by
comparing the Offsets and VarIndices. However, the latter implicitly
performs equality comparisons between two values, which is not
generally legal inside BasicAA, due to the possibility of comparisons
across phi cycles.

I believe that in this particular instance this actually ends up being
unproblematic, at least I wasn't able to come up with any cases that
could result in an incorrect root query result.

In the interest of being defensive, compute GetIndexDifference earlier
(which knows how to handle phi cycles properly) and use the result of
that to determine whether the offsets are identical.


  Commit: 53ae96d4bb4976c458b5c50e00782980efba9ded
      https://github.com/llvm/llvm-project/commit/53ae96d4bb4976c458b5c50e00782980efba9ded
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-02-14 (Sun, 14 Feb 2021)

  Changed paths:
    M llvm/lib/Analysis/BasicAliasAnalysis.cpp

  Log Message:
  -----------
  [BasicAA] Avoid duplicate query for GEPs with identical offsets (NFCI)

For two GEPs with identical offsets, we currently first perform
a base address query without size information, and then if it is
MayAlias, perform another with size information. This is pointless,
as the latter query should produce strictly better results.

This was not quite true historically due to the way that NoAlias
assumptions were handled, but that issue has since been resolved.


Compare: https://github.com/llvm/llvm-project/compare/428bc6feed08...53ae96d4bb49


More information about the All-commits mailing list