HomePhabricator

Handle successor's PHI node correctly when flattening CFG merges two if-regions

Authored by kuhar on Sep 26 2019, 8:20 AM.

Description

Handle successor's PHI node correctly when flattening CFG merges two if-regions

Summary:
FlattenCFG merges two 'if' basicblocks by inserting one basicblock
to another basicblock. The inserted basicblock can have a successor
that contains a PHI node whoes incoming basicblock is the inserted
basicblock. Since the existing code does not handle it, it becomes
a badref.

if (cond1)

statement

if (cond2)

statement

successor - contains PHI node whose predecessor is cond2

-->
if (cond1 || cond2)

statement

(BB for cond2 was deleted)
successor - contains PHI node whose predecessor is cond2 --> bad ref!

Author: Jaebaek Seo

Reviewers: asbirlea, kuhar, tstellar, chandlerc, davide, dexonsmith

Reviewed By: kuhar

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 372989

Details

Committed
kuharSep 26 2019, 8:20 AM
Reviewer
kuhar
Differential Revision
D68032: Handle successor's PHI node correctly when flattening CFG merges two if-regions
Parents
rGdf3af00421a5: Fix typo
Branches
Unknown
Tags
Unknown