Disallow cond_br with identical destinations.

It avoids generation of llvm phi nodes with identical predecessors and differing values.
This change replaces my previous fix of this problem in r23580, where I handled it in IRGen.

There were some discussions about it with the conclusion that it's better to just disallow such cond_br instructions in SIL.
It makes the life easier for some SIL optimizations which can't deal with cond_br with identical destinations.

The original radar is <rdar://problem/18568272> Swift compiler fails with "PHI node has multiple entries for the same basic block with different incoming values!"



Swift SVN r23861
This commit is contained in:
Erik Eckstein
2014-12-11 15:03:49 +00:00
parent e75334036c
commit 3b9805b246
8 changed files with 26 additions and 42 deletions

View File

@@ -2118,6 +2118,8 @@ public:
require(CBI->getTrueArgs().size() == CBI->getTrueBB()->bbarg_size(),
"true branch has wrong number of arguments for dest bb");
require(CBI->getTrueBB() != CBI->getFalseBB(),
"identical destinations");
require(std::equal(CBI->getTrueArgs().begin(), CBI->getTrueArgs().end(),
CBI->getTrueBB()->bbarg_begin(),
[](SILValue branchArg, SILArgument *bbArg) {