Skip to content

Commit

Permalink
ARM64: Fix ZeroInit of Locals
Browse files Browse the repository at this point in the history
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],dotnet/coreclr#16
 str     xzr, [x2,dotnet/coreclr#2]  --> just two byte offset (no x2 post-increment)
 str     wzr, [x2]
```

After (Pass)
```
 stp     xzr, xzr, [x2],dotnet/coreclr#16
 str     xzr, [x2],dotnet/coreclr#8
 str     wzr, [x2]
```


Commit migrated from dotnet/coreclr@59ea856
  • Loading branch information
kyulee1 committed Mar 14, 2016
1 parent be43993 commit a0357e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/coreclr/src/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6727,7 +6727,14 @@ void CodeGen::genZeroInitFrame(int untrLclHi,
#ifdef _TARGET_ARM_
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, rZero1, rAddr, 0);
#else // _TARGET_ARM_
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, REG_ZR, rAddr, (uCntBytes - REGSIZE_BYTES) == 0 ? 0 : INS_OPTS_POST_INDEX);
if ((uCntBytes - REGSIZE_BYTES) == 0)
{
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, REG_ZR, rAddr, 0);
}
else
{
getEmitter()->emitIns_R_R_I(INS_str, EA_PTRSIZE, REG_ZR, rAddr, REGSIZE_BYTES, INS_OPTS_POST_INDEX);
}
#endif // !_TARGET_ARM_
uCntBytes -= REGSIZE_BYTES;
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tests/arm64/Tests.lst
Original file line number Diff line number Diff line change
Expand Up @@ -5415,7 +5415,7 @@ RelativePath=JIT\Directed\zeroinit\init_int32\init_int32.exe
WorkingDir=JIT\Directed\zeroinit\init_int32
Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_FAIL;ISSUE_3665
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
[init_int64.exe_774]
RelativePath=JIT\Directed\zeroinit\init_int64\init_int64.exe
Expand All @@ -5436,7 +5436,7 @@ RelativePath=JIT\Directed\zeroinit\init_uint32\init_uint32.exe
WorkingDir=JIT\Directed\zeroinit\init_uint32
Expected=100
MaxAllowedDurationSeconds=600
Categories=Pri0;JIT;EXPECTED_FAIL;ISSUE_3665
Categories=Pri0;JIT;EXPECTED_PASS
HostStyle=Any
[init_uint64.exe_777]
RelativePath=JIT\Directed\zeroinit\init_uint64\init_uint64.exe
Expand Down

0 comments on commit a0357e5

Please sign in to comment.