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

Commit 59ea856

Browse files
committed
ARM64: Fix ZeroInit of Locals
When zero-initializing locals, JIT emits wrong instruction sequence -- e.g, 28 byte zero-intialization as shown below. The issue was JIT passed wrong arguments to emitIns_R_R_I. Before (Fail) ``` stp xzr, xzr, [x2],#16 str xzr, [x2,#2] --> just two byte offset (no x2 post-increment) str wzr, [x2] ``` After (Pass) ``` stp xzr, xzr, [x2],#16 str xzr, [x2],#8 str wzr, [x2] ```
1 parent 7fbb95d commit 59ea856

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/jit/codegencommon.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6727,7 +6727,14 @@ void CodeGen::genZeroInitFrame(int untrLclHi,
67276727
#ifdef _TARGET_ARM_
67286728
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, rZero1, rAddr, 0);
67296729
#else // _TARGET_ARM_
6730-
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, REG_ZR, rAddr, (uCntBytes - REGSIZE_BYTES) == 0 ? 0 : INS_OPTS_POST_INDEX);
6730+
if ((uCntBytes - REGSIZE_BYTES) == 0)
6731+
{
6732+
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, REG_ZR, rAddr, 0);
6733+
}
6734+
else
6735+
{
6736+
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, REG_ZR, rAddr, REGSIZE_BYTES, INS_OPTS_POST_INDEX);
6737+
}
67316738
#endif // !_TARGET_ARM_
67326739
uCntBytes -= REGSIZE_BYTES;
67336740
}

tests/arm64/Tests.lst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5415,7 +5415,7 @@ RelativePath=JIT\Directed\zeroinit\init_int32\init_int32.exe
54155415
WorkingDir=JIT\Directed\zeroinit\init_int32
54165416
Expected=100
54175417
MaxAllowedDurationSeconds=600
5418-
Categories=Pri0;JIT;EXPECTED_FAIL;ISSUE_3665
5418+
Categories=Pri0;JIT;EXPECTED_PASS
54195419
HostStyle=Any
54205420
[init_int64.exe_774]
54215421
RelativePath=JIT\Directed\zeroinit\init_int64\init_int64.exe
@@ -5436,7 +5436,7 @@ RelativePath=JIT\Directed\zeroinit\init_uint32\init_uint32.exe
54365436
WorkingDir=JIT\Directed\zeroinit\init_uint32
54375437
Expected=100
54385438
MaxAllowedDurationSeconds=600
5439-
Categories=Pri0;JIT;EXPECTED_FAIL;ISSUE_3665
5439+
Categories=Pri0;JIT;EXPECTED_PASS
54405440
HostStyle=Any
54415441
[init_uint64.exe_777]
54425442
RelativePath=JIT\Directed\zeroinit\init_uint64\init_uint64.exe

0 commit comments

Comments
 (0)