[InstCombine] Handle PHI nodes in PtrReplacer
authorAnshil Gandhi <gandhi21299@gmail.com>
Tue, 17 Jan 2023 17:36:05 +0000 (10:36 -0700)
committerAnshil Gandhi <gandhi21299@gmail.com>
Tue, 17 Jan 2023 17:56:03 +0000 (10:56 -0700)
commit2449cbabddc73668abf60357d476a78692193286
tree7692644e5c9b49efab5a75e150f25bc437607b79
parent9a479008d466bbab885e4f7be03a50a1ee547dba
[InstCombine] Handle PHI nodes in PtrReplacer

This patch adds on to the functionality implemented
in rG42ab5dc5a5dd6c79476104bdc921afa2a18559cf,
where PHI nodes are supported in the use-def traversal
algorithm to determine if an alloca ever overwritten
in addition to a memmove/memcpy. This patch implements
the support needed by the PointerReplacer to collect
all (indirect) users of the alloca in cases where a PHI
is involved. Finally, a new PHI is defined in the replace
method which takes in replaced incoming values and
updates the WorkMap accordingly.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D136201
llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
llvm/test/Transforms/InstCombine/replace-alloca-phi.ll