Skip to content

Commit 02dd40f

Browse files
Merge pull request #80873 from swiftlang/mseaman/const-expr-bb-args
Fix assertion failure when performing constant-evaluation through basic blocks with non-constant arguments
2 parents 2381d39 + 14d9b05 commit 02dd40f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/SILOptimizer/Utils/ConstExpr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,8 +1785,8 @@ ConstExprFunctionState::evaluateInstructionAndGetNext(
17851785
// Set up basic block arguments.
17861786
for (unsigned i = 0, e = br->getNumArgs(); i != e; ++i) {
17871787
auto argument = getConstantValue(br->getArg(i));
1788-
if (!argument.isConstant())
1789-
return {std::nullopt, argument};
1788+
// Do not fail if an argument is not constant because we still know enough to know what the next instruction will be.
1789+
// Failure may occur later, however, if/when this unknown argument value is used by an instruction in the target basic block.
17901790
setValue(destBB->getArgument(i), argument);
17911791
}
17921792
// Set the instruction pointer to the first instruction of the block.

0 commit comments

Comments
 (0)