[GVN] Invalidate MDA when deduplicating phi nodes
authorNikita Popov <npopov@redhat.com>
Thu, 17 Aug 2023 14:37:32 +0000 (16:37 +0200)
committerTobias Hieta <tobias@hieta.se>
Mon, 25 Sep 2023 11:04:45 +0000 (13:04 +0200)
commit9f77e96186be77a2bd07feb0b83681f452fc967d
tree5f6e73151a76704449839796f64feb18a812a8cf
parenta13a89402f530330880c92841cf551ddae00ead0
[GVN] Invalidate MDA when deduplicating phi nodes

Duplicate phi nodes were being directly removed, without
invalidating MDA. This could result in a new phi node being
allocated at the same address, incorrectly reusing a cache entry.

Fix this by optionally allowing EliminateDuplicatePHINodes() to
collect phi nodes to remove into a vector, which allows GVN to
handle removal itself.

Fixes https://github.com/llvm/llvm-project/issues/64598.

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

(cherry picked from commit 7c229f6e85478bb0626a5e598f47b7be94bb50b0)
llvm/include/llvm/Transforms/Utils/Local.h
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/GVN/pr64598.ll [new file with mode: 0644]