[RyuJIT/ARM32] Assert failure on "Instruction cannot be encoded"
$ COMPlus_JitDump=* \
COMPlus_AltJit=conv_ovf:u4_u1 \
gdb --args \
clr-checked/corerun tests-release/JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.exe
dotnet/coreclr#7 0xb15d9500 in assertAbort (why=0xb17ad968 "!\"Instruction cannot be encoded\"", file=0xb17ad1b2 "/home/mskvortsov/git/coreclr/src/jit/emitarm.cpp", line=1902) at /home/mskvortsov/git/coreclr/src/jit/error.cpp:287
dotnet/coreclr#8 0xb16a9016 in emitter::emitIns_R_I (this=0x8f824, ins=instruction::INS_tst, attr=emitAttr::EA_4BYTE, reg=_regNumber_enum::REG_R0, imm=-256, flags=<optimized out>) at /home/mskvortsov/git/coreclr/src/jit/emitarm.cpp:1902
dotnet/coreclr#9 0xb16a111c in CodeGen::genIntToIntCast (this=<optimized out>, treeNode=0x90558) at /home/mskvortsov/git/coreclr/src/jit/codegenarm.cpp:2918
dotnet/coreclr#10 0xb15c0122 in CodeGen::genCodeForBBlist (this=<optimized out>) at /home/mskvortsov/git/coreclr/src/jit/codegenlinear.cpp:385
FAILED - JIT/Directed/zeroinit/init_int32/init_int32.sh
FAILED - JIT/Directed/zeroinit/init_uint32/init_uint32.sh
FAILED - JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/add_ovf_u1/add_ovf_u1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/add_ovf_u2/add_ovf_u2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/conv_ovf_i4_i1/conv_ovf_i4_i1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/conv_ovf_i4_i2/conv_ovf_i4_i2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/conv_ovf_u4_u1/conv_ovf_u4_u1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/conv_ovf_u4_u2/conv_ovf_u4_u2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_i4_i1/ldc_conv_ovf_i4_i1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_i4_i2/ldc_conv_ovf_i4_i2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_u4_u1/ldc_conv_ovf_u4_u1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/ldc_conv_ovf_u4_u2/ldc_conv_ovf_u4_u2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/ldc_sub_ovf_u1/ldc_sub_ovf_u1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/ldc_sub_ovf_u2/ldc_sub_ovf_u2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/mul_ovf_u1/mul_ovf_u1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/mul_ovf_u2/mul_ovf_u2.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/sub_ovf_u1/sub_ovf_u1.sh
FAILED - JIT/IL_Conformance/Old/Conformance_Base/sub_ovf_u2/sub_ovf_u2.sh
FAILED - JIT/jit64/opt/regress/vswhidbey/223862/conv_dbg/conv_dbg.sh
FAILED - JIT/jit64/opt/regress/vswhidbey/228572/conv_dbg/conv_dbg.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b31273/b31273/b31273.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M09.5-PDC/b31448/b31448/b31448.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M11-Beta1/b33888/b33888/b33888.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b37238/b37238/b37238.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b53878/b53878/b53878.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b55923/b55923/b55923.sh
FAILED - JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b73079/b73079/b73079.sh
...
@sjsinju Could you please take a look?
@mskvortsov OK. Let me check.
@mskvortsov I checked the result same case of you. and I've fixed with dotnet/coreclr#10789.
@sjsinju The test still fails with that fix applied:
FAILED - JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.sh
BEGIN EXECUTION
/home/mskvortsov/clr-checked/corerun conv_ovf.exe
Expected: 100
Actual: 0
END EXECUTION - FAILED
And other tests mentioned in the issue description are failing too...
@mskvortsov On my RPi3 tests, The test had finished successfully. (Debug/Checked/Release) @hqueue Would you please do cross check this issue after applied dotnet/coreclr#10789?
Updated.
$ COMPlus_AltJit=conv_ovf:u4_u1 ../coreoverlays/coreoverlay.test20170410sjsinju/corerun ../../../tests/Windows_NT.x86.Release.170302/JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.exe
$ echo ?
0
And I've got same result with @mskvortsov when running the test through runtest.sh
Preparing JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.sh
The tests have been prepared
Starting JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.sh
FAILED - [ 0][ 7s]JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.sh
BEGIN EXECUTION
/mnt/albireo/mywork/device/rpi3/unittests/coreoverlays/coreoverlay.test20170410sjsinju/corerun conv_ovf.exe
Expected: 100
Actual: 0
END EXECUTION - FAILED
=======================
Test Results
=======================
# CoreCLR Bin Dir :
# Tests Discovered : 1
# Passed : 0
# Failed : 1
# Skipped : 0
=======================
0 minutes and 16 seconds taken to run CoreCLR tests.
+ exit 1
@hqueue @mskvortsov I've got following results
$ COMPlus_AltJit=conv_ovf:u4_u1 /home/sjsujinkim/works/dotnet/Windows_NT.x64.Release/Tests/coreoverlay/corerun conv_ovf.exe
$ echo $?
0
It seems to need to check more.
I figured out the issue for this is from overflow checks.
ldc.i4 0x00000100
call int32 conv_ovf::u4_u1(int32)
brfalse FAIL
In this, uint->ubyte 0x00000100 is overflow case. but now, it can't catch overflow.
I missed overflow check logics when using a temp register. And then I added it. The result is
$ /home/sjsujinkim/works/dotnet/Windows_NT.x64.Release/Tests/coreoverlay/corerun conv_ovf.exe
$ echo $?
100
he tests have been prepared
- JIT/IL_Conformance/Old/Base/conv_ovf/conv_ovf.sh
=======================
Test Results
=======================
# CoreCLR Bin Dir : /home/sjsujinkim/works/dotnet/coreclr/bin/Product/Linux.arm.Debug
# Tests Discovered : 1
# Passed : 1
# Failed : 0
# Skipped : 0
=======================
@sjsinju We are not quite there yet. If you run the test with our "standard" options COMPlus_AltJitAssertOnNYI=0 COMPlus_AltJit=*, you'll see the next failure:
dotnet/coreclr#7 0xb16c64b4 in DbgAssertDialog (szFile=0xb175acfe "/home/mskvortsov/git/coreclr/src/inc/bitposition.h", iLine=27, szExpr=0x6 <error: Cannot access memory at address 0x6>) at /home/mskvortsov/git/coreclr/src/utilcode/debug.cpp:706
dotnet/coreclr#8 0xb15be8d8 in BitPosition (value=12) at /home/mskvortsov/git/coreclr/src/inc/bitposition.h:27
dotnet/coreclr#9 0xb15bcd3c in genRegNumFromMask (mask=12) at /home/mskvortsov/git/coreclr/src/jit/compiler.hpp:494
dotnet/coreclr#10 0xb16a0d36 in CodeGen::genIntToIntCast (this=0x8ec1c, treeNode=0x90598) at /home/mskvortsov/git/coreclr/src/jit/codegenarm.cpp:2886
Which probably means that you need to revise the lsraarm.cpp part of your fix too.
@mskvortsov OK. I met the assertion that you said too. I could check same issue in dotnet/runtime#7663. I would check that. Thank you.
@mskvortsov I fixed the assertion of bitpostion by dotnet/coreclr#10789. Thanks for your comments.
merged dotnet/coreclr#10789