Skip to content

Commit fda5dee

Browse files
Assert on invalid IR
1 parent 44bf913 commit fda5dee

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/coreclr/jit/earlyprop.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,13 @@ GenTree* Compiler::optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheck
388388
if ((checkConstVal >= 0) && (checkConstVal < actualConstVal))
389389
{
390390
GenTree* comma = check->gtGetParent(nullptr);
391+
392+
// We should never see cases other than these in the IR,
393+
// as the check node does not produce a value.
394+
assert(((comma != nullptr) && comma->OperIs(GT_COMMA) && (comma->gtGetOp1() == check)) ||
395+
(check == compCurStmt->GetRootNode()));
396+
397+
// Still, we guard here so that release builds do not try to optimize trees we don't understand.
391398
if (((comma != nullptr) && comma->OperIs(GT_COMMA) && (comma->gtGetOp1() == check)) ||
392399
(check == compCurStmt->GetRootNode()))
393400
{

0 commit comments

Comments
 (0)