Provide a comment clarifying why there could be an infinite loop and how it is prevented

This commit is contained in:
Roman Levenstein
2017-09-25 08:34:52 -07:00
parent fc9a7b72ee
commit 59f7bfe502

View File

@@ -416,6 +416,12 @@ void SILBuilder::addOpenedArchetypeOperands(SILInstruction *I) {
I->getNumTypeDependentOperands() == 0) {
// All the open instructions are single-value instructions.
auto SVI = dyn_cast<SingleValueInstruction>(I->getOperand(0));
// Within SimplifyCFG this function may be called for an instruction
// within unreachable code. And within an unreachable block it can happen
// that defs do not dominate uses (because there is no dominance defined).
// To avoid the infinite loop when following the chain of instructions via
// their operands, bail if the operand is not an instruction or this
// instruction was seen already.
if (!SVI || !Visited.insert(SVI).second)
return;
// If it is a definition of an opened archetype,