Skip to content

Commit ca908f5

Browse files
authored
Assert if we find undefined use during interval validation (#56439)
* Assert if we find undefined use during interval validation * Include lastUse check
1 parent b25bd29 commit ca908f5

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/coreclr/jit/lsrabuild.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,8 @@ void LinearScan::validateIntervals()
26682668
}
26692669
Interval* interval = getIntervalForLocalVar(i);
26702670

2671-
bool defined = false;
2671+
bool defined = false;
2672+
unsigned lastUseBBNum = 0;
26722673
JITDUMP("-----------------\n");
26732674
for (RefPosition* ref = interval->firstRefPosition; ref != nullptr; ref = ref->nextRefPosition)
26742675
{
@@ -2677,13 +2678,17 @@ void LinearScan::validateIntervals()
26772678
ref->dump(this);
26782679
}
26792680
RefType refType = ref->refType;
2680-
if (!defined && RefTypeIsUse(refType))
2681+
if (!defined && RefTypeIsUse(refType) && (lastUseBBNum == ref->bbNum))
26812682
{
2682-
if (compiler->info.compMethodName != nullptr)
2683+
if (!ref->lastUse)
26832684
{
2684-
JITDUMP("%s: ", compiler->info.compMethodName);
2685+
if (compiler->info.compMethodName != nullptr)
2686+
{
2687+
JITDUMP("%s: ", compiler->info.compMethodName);
2688+
}
2689+
JITDUMP("LocalVar V%02u: undefined use at %u\n", interval->varNum, ref->nodeLocation);
2690+
assert(false);
26852691
}
2686-
JITDUMP("LocalVar V%02u: undefined use at %u\n", interval->varNum, ref->nodeLocation);
26872692
}
26882693

26892694
// For single-def intervals, the only the first refposition should be a RefTypeDef
@@ -2696,7 +2701,8 @@ void LinearScan::validateIntervals()
26962701
// so we can't really check the lastUse flag
26972702
if (ref->lastUse)
26982703
{
2699-
defined = false;
2704+
defined = false;
2705+
lastUseBBNum = ref->bbNum;
27002706
}
27012707
if (RefTypeIsDef(refType))
27022708
{

0 commit comments

Comments
 (0)