[CodeExtractor] Split PHI nodes with incoming values from outlined region (PR39433)
authorVedant Kumar <vsk@apple.com>
Mon, 3 Dec 2018 22:40:21 +0000 (22:40 +0000)
committerVedant Kumar <vsk@apple.com>
Mon, 3 Dec 2018 22:40:21 +0000 (22:40 +0000)
commitd129569e348a65252ed1d88e0edce997462ecc24
tree4d31c920e9f7138c03f7eb5d3989dbc8ead3bb70
parent748f59caefe8e133a38db0381285229a3673f227
[CodeExtractor] Split PHI nodes with incoming values from outlined region (PR39433)

If a PHI node out of extracted region has multiple incoming values from it,
split this PHI on two parts. First PHI has incomings only from region and
extracts with it (they are placed to the separate basic block that added to the
list of outlined), and incoming values in original PHI are replaced by first
PHI. Similar solution is already used in CodeExtractor for PHIs in entry block
(severSplitPHINodes method). It covers PR39433 bug.

Patch by Sergei Kachkov!

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

llvm-svn: 348205
llvm/include/llvm/Transforms/Utils/CodeExtractor.h
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Transforms/HotColdSplit/duplicate-phi-preds-crash.ll
llvm/unittests/Transforms/Utils/CodeExtractorTest.cpp