[IROutliner] Ensure that phi values that are passed in as arguments are remapped...
authorAndrew Litteken <andrew.litteken@gmail.com>
Mon, 21 Mar 2022 20:56:50 +0000 (15:56 -0500)
committerAndrew Litteken <andrew.litteken@gmail.com>
Thu, 14 Apr 2022 17:16:23 +0000 (12:16 -0500)
commitd6eb480afbc038871570fa053d772c913cd77a61
tree09496641d3539cbf849a06d9d4cbea43aad1c4f0
parent7ef9dd3c61fd85b430bcd74f7ce2c075d93fe4fa
[IROutliner] Ensure that phi values that are passed in as arguments are remapped as arguments

Issue: https://github.com/llvm/llvm-project/issues/54430

For incoming values of phi nodes added to an outlined function to accommodate different exit paths in the function, when a value is a constant that is passed into the outlined function as an argument, we find the corresponding value in the first extracted function used to fill the overall outlined function. When this value is an argument, the corresponding value used will be the old value, prior to outlining. This patch maintains a mapping from these values to arguments, and uses this mapping to update the added phi node accordingly.

Reviewers: paquette

Differential Revision: https://reviews.llvm.org/D122206
llvm/include/llvm/Transforms/IPO/IROutliner.h
llvm/lib/Transforms/IPO/IROutliner.cpp
llvm/test/Transforms/IROutliner/exit-phi-nodes-incoming-value-constant-argument.ll [new file with mode: 0644]