[ArgPromotion] Replace all md uses of promoted values with undef.
authorFlorian Hahn <flo@fhahn.com>
Mon, 3 Aug 2020 18:18:13 +0000 (19:18 +0100)
committerFlorian Hahn <flo@fhahn.com>
Mon, 3 Aug 2020 18:31:53 +0000 (19:31 +0100)
commit1e392fc44584a4909b4dced02b8386b48963002b
tree56df383879e9c840c828bc06a770f52cd77e503f
parentc12bd8dac91adac81cd9721fe34daf473ebd5e10
[ArgPromotion] Replace all md uses of promoted values with undef.

Currently, ArgPromotion may leave metadata uses of promoted values,
which will end up in the wrong function, creating invalid IR.

PR33641 fixed this for dead arguments, but it can be also be triggered
arguments with users that are promoted (see the updated test case).

We also have to drop uses to them after promoting them. We need to do
this after dealing with the non-metadata uses, so I also moved the empty
use case to the loop that deals with updating the arguments of the new
function.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D85127
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/test/Transforms/ArgumentPromotion/pr33641_remove_arg_dbgvalue.ll