[ARM32/Linux] Fix register allocation for null check in call instruction
authorHyeongseok Oh <hseok82.oh@samsung.com>
Mon, 20 Mar 2017 06:26:33 +0000 (15:26 +0900)
committerHyeongseok Oh <hseok82.oh@samsung.com>
Mon, 20 Mar 2017 07:43:47 +0000 (16:43 +0900)
Fix assertion when two temporary registers are reserved in call instruction

src/jit/codegenarm.cpp

index e276b71..b5e3313 100644 (file)
@@ -1952,8 +1952,13 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
     // Insert a null check on "this" pointer if asked.
     if (call->NeedsNullCheck())
     {
-        const regNumber regThis = genGetThisArgReg(call);
-        const regNumber tmpReg  = genRegNumFromMask(call->gtRsvdRegs);
+        const regNumber regThis  = genGetThisArgReg(call);
+        regMaskTP       tempMask = genFindLowestBit(call->gtRsvdRegs);
+        const regNumber tmpReg   = genRegNumFromMask(tempMask);
+        if (genCountBits(call->gtRsvdRegs) > 1)
+        {
+            call->gtRsvdRegs &= ~tempMask;
+        }
         getEmitter()->emitIns_R_R_I(INS_ldr, EA_4BYTE, tmpReg, regThis, 0);
     }