Skip to content

Commit 04b89d5

Browse files
author
Emanuel Zephir
committed
[SIL] Add tests for 'undef' values & code fixes
This change validates that 'undef' can appear in most places where values are expected by the SIL parser. Fixes are also included for the 'select_value' instruction. This resolves SR-304.
1 parent 20d68bc commit 04b89d5

File tree

2 files changed

+374
-17
lines changed

2 files changed

+374
-17
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,15 +2546,18 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
25462546
SILValue casevalue;
25472547
SILValue result;
25482548
std::tie(casevalue, result) = I->getCase(i);
2549-
auto *il = dyn_cast<IntegerLiteralInst>(casevalue);
2550-
require(il,
2551-
"select_value case operands should refer to integer literals");
2552-
APInt elt = il->getValue();
2549+
2550+
if (!isa<SILUndef>(casevalue)) {
2551+
auto *il = dyn_cast<IntegerLiteralInst>(casevalue);
2552+
require(il,
2553+
"select_value case operands should refer to integer literals");
2554+
APInt elt = il->getValue();
25532555

2554-
require(!seenCaseValues.count(elt),
2555-
"select_value dispatches on same case value more than once");
2556+
require(!seenCaseValues.count(elt),
2557+
"select_value dispatches on same case value more than once");
25562558

2557-
seenCaseValues.insert(elt);
2559+
seenCaseValues.insert(elt);
2560+
}
25582561

25592562
requireSameType(I->getOperand()->getType(), casevalue->getType(),
25602563
"select_value case value must match type of operand");

0 commit comments

Comments
 (0)