SimplifyCFG: fix crash if a branch argument is replaced with a SILValue with result number != 0

Fixes https://bugs.swift.org/browse/SR-329
rdar://problem/23969954
This commit is contained in:
Erik Eckstein
2015-12-21 10:01:29 -08:00
parent ae6b41dc37
commit b3691c83a6
2 changed files with 25 additions and 1 deletions

View File

@@ -966,7 +966,7 @@ bool SimplifyCFG::simplifyBranchOperands(OperandValueArrayRef Operands) {
for (auto O = Operands.begin(), E = Operands.end(); O != E; ++O)
if (auto *I = dyn_cast<SILInstruction>(*O))
if (SILValue Result = simplifyInstruction(I)) {
SILValue(I, 0).replaceAllUsesWith(Result.getDef());
SILValue(I, 0).replaceAllUsesWith(Result);
if (isInstructionTriviallyDead(I)) {
eraseFromParentWithDebugInsts(I);
Simplified = true;