[Attributor] Introduce the `AA::isPotentiallyReachable` helper APIs
authorJohannes Doerfert <johannes@jdoerfert.de>
Mon, 31 Jan 2022 22:45:17 +0000 (16:45 -0600)
committerJohannes Doerfert <johannes@jdoerfert.de>
Tue, 1 Feb 2022 07:40:45 +0000 (01:40 -0600)
commita265cf22af5ec7d1319f690126b6479e356ef270
treeeffc6b81ca4678e84d1f828a2d80a75d305a9d5c
parentb51b83f68e4671a508021911a5b2cf124f493d25
[Attributor] Introduce the `AA::isPotentiallyReachable` helper APIs

To make usage easier (compared to the many reachability related AAs),
this patch introduces a helper API, `AA::isPotentiallyReachable`, which
performs all the necessary steps. It also does the "backwards"
reachability (see D106720) as that simplifies the AA a lot (backwards
queries were somewhat different from the other query resolvers), and
ensures we use cached values in every stage.

To test inter-procedural reachability in a reasonable way this patch
includes an extension to `AAPointerInfo::forallInterferingWrites`.
Basically, we can exclude writes if they cannot reach a load "during the
lifetime" of the allocation. That is, we need to go up the call graph to
determine reachability until we can determine the allocation would be
dead in the caller. This leads to new constant propagations (through
memory) in `value-simplify-pointer-info-gpu.ll`.

Note: The new code contains plenty debug output to determine how
reachability queries are resolved.

Parts extracted from D110078.

Differential Revision: https://reviews.llvm.org/D118673
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/ArgumentPromotion/X86/min-legal-vector-width.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/alignment.ll
llvm/test/Transforms/Attributor/ArgumentPromotion/basictest.ll
llvm/test/Transforms/Attributor/read_write_returned_arguments_scc.ll
llvm/test/Transforms/Attributor/value-simplify-gpu.ll