Skip to content

Commit

Permalink
Fixing the operand evaluation order for NI_SRCS_UNSAFE_ByteOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed May 2, 2022
1 parent a933fec commit fff8ddc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4925,6 +4925,13 @@ GenTree* Compiler::impSRCSUnsafeIntrinsic(NamedIntrinsic intrinsic,
GenTree* op1 = impPopStack().val;
impBashVarAddrsToI(op1, op2);

unsigned temp = lvaGrabTemp(true DEBUGARG("Evaluate op1 to a local so side-effects can be preserved"));

impAssignTempGen(temp, op1, NO_CLASS_HANDLE, (unsigned)CHECK_SPILL_ALL, nullptr, impCurStmtDI);
var_types type = genActualType(lvaTable[temp].TypeGet());

op1 = gtNewLclvNode(temp, type);

var_types type = impGetByRefResultType(GT_SUB, /* uns */ false, &op2, &op1);
return gtNewOperNode(GT_SUB, type, op2, op1);
}
Expand Down

0 comments on commit fff8ddc

Please sign in to comment.