[Attributor] Improve use of dominating writes during reasoning
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 14 Dec 2022 01:51:21 +0000 (17:51 -0800)
committerJohannes Doerfert <johannes@jdoerfert.de>
Tue, 10 Jan 2023 22:21:53 +0000 (14:21 -0800)
commitb84ea7a4758690f7c7b327f5d47bd3013a3b1619
tree7afd09bfc42c9165b0194600cda3340d53de6733
parent1f0c237a249a3304f4b80e6e611611d32aef7369
[Attributor] Improve use of dominating writes during reasoning

This resolves a recent regression introduced by a bug fix and allows us
to use dominating write information (formerly HasBeenWrittenTo
information) to skip potential interfering accesses.

Generally, there are two changes here:
1) If we have dominating writes they form a chain and we can look at the
   least one to minimize the distance between the write and the (read)
   access in question.
2) If such a least dominating write exists, we can ignore writes in
   other functions as long as they cannot be reached from code between
   this write and the (read) access in question.

We have all the tools available to make such queries and the positive
tests show the result. Note that the negative test from the bug fix is
still in tree and not affected.

As a side-effect, we can remove the (arbitrary) treshold now on the
number of interfering accesses since we do not iterate over dominating
ones anymore.
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/IPConstantProp/2009-09-24-byval-ptr.ll
llvm/test/Transforms/Attributor/value-simplify-assume.ll
llvm/test/Transforms/Attributor/value-simplify-dominance.ll [new file with mode: 0644]
llvm/test/Transforms/Attributor/value-simplify-pointer-info-struct.ll
llvm/test/Transforms/Attributor/value-simplify-reachability.ll