Skip to content

Commit 1be948c

Browse files
authored
Prevent incorrect constant folding (#98561)
* Prevent incorrect constant folding of binary operations involving handle and integer * Fix the conditions for null nodes * Fix the last commit for non-GT/GE/LT/LE * Make JIT format happy * More conservative approach. Limit only arithmetic operations involving handles in a relocatable code.
1 parent 5e1caf1 commit 1be948c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/coreclr/jit/valuenum.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4421,6 +4421,11 @@ bool ValueNumStore::VNEvalCanFoldBinaryFunc(var_types type, VNFunc func, ValueNu
44214421
case GT_RSZ:
44224422
case GT_ROL:
44234423
case GT_ROR:
4424+
if (m_pComp->opts.compReloc && (IsVNHandle(arg0VN) || IsVNHandle(arg1VN)))
4425+
{
4426+
return false;
4427+
}
4428+
break;
44244429

44254430
case GT_EQ:
44264431
case GT_NE:
@@ -4449,6 +4454,11 @@ bool ValueNumStore::VNEvalCanFoldBinaryFunc(var_types type, VNFunc func, ValueNu
44494454
case VNF_ADD_UN_OVF:
44504455
case VNF_SUB_UN_OVF:
44514456
case VNF_MUL_UN_OVF:
4457+
if (m_pComp->opts.compReloc && (IsVNHandle(arg0VN) || IsVNHandle(arg1VN)))
4458+
{
4459+
return false;
4460+
}
4461+
break;
44524462

44534463
case VNF_Cast:
44544464
case VNF_CastOvf:

0 commit comments

Comments
 (0)