[SimplifyCFG] FoldBranchToCommonDest(): temporairly put back restrictions on liveout...
authorRoman Lebedev <lebedev.ri@gmail.com>
Mon, 14 Dec 2020 14:44:17 +0000 (17:44 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Mon, 14 Dec 2020 17:14:31 +0000 (20:14 +0300)
commit59560e85897afc50090b6c3d920bacfd28b49d06
tree1b2511aafa518192393003a1af89ac88cd0dc79c
parente8360a8e1e78edded1f6e95a7fdbac55fe42285f
[SimplifyCFG] FoldBranchToCommonDest(): temporairly put back restrictions on liveout uses of bonus instructions (PR48450)

Even though d38205144febf4dc42c9270c6aa3d978f1ef65e1 was mostly a correct
fix for the external non-PHI users, it's not a *generally* correct fix,
because the 'placeholder' values in those trivial PHI's we create
shouldn't be *always* 'undef', but the PHI itself for the backedges,
else we end up with wrong value, as the `@pr48450_2` test shows.

But we can't just do that, because we can't check that the PHI
can be it's own incoming value when coming from certain predecessor,
because we don't have a dominator tree.

So until we can address this correctness problem properly,
ensure that we don't perform the transformation
if there are such problematic external uses.

Making dominator tree available there is going to be involved,
since `-simplifycfg` pass currently does not preserve/update domtree...
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/LoopUnroll/peel-loop-inner.ll
llvm/test/Transforms/SimplifyCFG/fold-branch-to-common-dest.ll