Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 78fedeb

Browse files
Fix off-by-one error
The code in loop hoisting visiting a comma for a static init helper call and static field access tried to clear the childrenHoistable bit for the field, but had an off-by-one error and was instead clearing the bit for the helper call, which could lead to missed legal helper call hoists. Update that code to simply assert that the flag is already set for the field (using the correct index), which must be true since the check is guarded by a check that childIsCctorDependent is true for it.
1 parent 1e9a45e commit 78fedeb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/jit/optimizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,9 +6178,9 @@ bool Compiler::optHoistLoopExprsForTree(GenTreePtr tree,
61786178
// with the static field reference.
61796179
treeIsCctorDependent = false;
61806180
// Hoisting the static field without hoisting the initialization would be
6181-
// incorrect; unset childrenHoistable for the field to ensure this doesn't
6182-
// happen.
6183-
childrenHoistable[0] = false;
6181+
// incorrect, make sure we consider the field (which we flagged as
6182+
// cctor-dependent) non-hoistable.
6183+
noway_assert(!childrenHoistable[childNum]);
61846184
}
61856185
}
61866186
}

0 commit comments

Comments
 (0)