Address the feedback.
authorMikhail Skvortcov <m.skvortcov@partner.samsung.com>
Wed, 8 Feb 2017 10:26:22 +0000 (13:26 +0300)
committerMikhail Skvortcov <m.skvortcov@partner.samsung.com>
Thu, 9 Feb 2017 08:21:12 +0000 (11:21 +0300)
Commit migrated from https://github.com/dotnet/coreclr/commit/a38f3351a8c01931f3f9dd18a3e7ec8ff788d1e3

src/coreclr/src/jit/codegen.h
src/coreclr/src/jit/codegenarm.cpp
src/coreclr/src/jit/codegencommon.cpp
src/coreclr/src/jit/codegenlegacy.cpp
src/coreclr/src/jit/codegenlinear.cpp
src/coreclr/src/jit/instr.cpp
src/coreclr/src/jit/jiteh.cpp

index 090283e..507970e 100755 (executable)
@@ -470,6 +470,9 @@ protected:
     void genSetPSPSym(regNumber initReg, bool* pInitRegZeroed);
 
     void genUpdateCurrentFunclet(BasicBlock* block);
+#if defined(_TARGET_ARM_)
+    void genInsertNopForUnwinder(BasicBlock* block);
+#endif
 
 #else // FEATURE_EH_FUNCLETS
 
@@ -479,6 +482,13 @@ protected:
         return;
     }
 
+#if defined(_TARGET_ARM_)
+    void genInsertNopForUnwinder(BasicBlock* block)
+    {
+        return;
+    }
+#endif
+
 #endif // FEATURE_EH_FUNCLETS
 
     void genGeneratePrologsAndEpilogs();
index 2e0183b..580cad5 100644 (file)
@@ -78,14 +78,9 @@ BasicBlock* CodeGen::genCallFinally(BasicBlock* block)
     // jump target using bbJumpDest - that is already used to point
     // to the finally block. So just skip past the BBJ_ALWAYS unless the
     // block is RETLESS.
-    if (!(block->bbFlags & BBF_RETLESS_CALL))
-    {
-        assert(block->isBBCallAlwaysPair());
-
-        lblk  = block;
-        block = block->bbNext;
-    }
-    return block;
+    assert(!(block->bbFlags & BBF_RETLESS_CALL));
+    assert(block->isBBCallAlwaysPair());
+    return block->bbNext;
 }
 
 //------------------------------------------------------------------------
index b1e474b..65cc6de 100644 (file)
@@ -2814,6 +2814,37 @@ void CodeGen::genUpdateCurrentFunclet(BasicBlock* block)
         }
     }
 }
+
+#if defined(_TARGET_ARM_)
+void CodeGen::genInsertNopForUnwinder(BasicBlock* block)
+{
+    // If this block is the target of a finally return, we need to add a preceding NOP, in the same EH region,
+    // so the unwinder doesn't get confused by our "movw lr, xxx; movt lr, xxx; b Lyyy" calling convention that
+    // calls the funclet during non-exceptional control flow.
+    if (block->bbFlags & BBF_FINALLY_TARGET)
+    {
+        assert(block->bbFlags & BBF_JMP_TARGET);
+
+#ifdef DEBUG
+        if (compiler->verbose)
+        {
+            printf("\nEmitting finally target NOP predecessor for BB%02u\n", block->bbNum);
+        }
+#endif
+        // Create a label that we'll use for computing the start of an EH region, if this block is
+        // at the beginning of such a region. If we used the existing bbEmitCookie as is for
+        // determining the EH regions, then this NOP would end up outside of the region, if this
+        // block starts an EH region. If we pointed the existing bbEmitCookie here, then the NOP
+        // would be executed, which we would prefer not to do.
+
+        block->bbUnwindNopEmitCookie =
+            getEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur);
+
+        instGen(INS_nop);
+    }
+}
+#endif
+
 #endif // FEATURE_EH_FUNCLETS
 
 /*****************************************************************************
index 0530863..c616546 100644 (file)
@@ -12680,30 +12680,7 @@ void CodeGen::genCodeForBBlist()
 
 #if FEATURE_EH_FUNCLETS
 #if defined(_TARGET_ARM_)
-        // If this block is the target of a finally return, we need to add a preceding NOP, in the same EH region,
-        // so the unwinder doesn't get confused by our "movw lr, xxx; movt lr, xxx; b Lyyy" calling convention that
-        // calls the funclet during non-exceptional control flow.
-        if (block->bbFlags & BBF_FINALLY_TARGET)
-        {
-            assert(block->bbFlags & BBF_JMP_TARGET);
-
-#ifdef DEBUG
-            if (compiler->verbose)
-            {
-                printf("\nEmitting finally target NOP predecessor for BB%02u\n", block->bbNum);
-            }
-#endif
-            // Create a label that we'll use for computing the start of an EH region, if this block is
-            // at the beginning of such a region. If we used the existing bbEmitCookie as is for
-            // determining the EH regions, then this NOP would end up outside of the region, if this
-            // block starts an EH region. If we pointed the existing bbEmitCookie here, then the NOP
-            // would be executed, which we would prefer not to do.
-
-            block->bbUnwindNopEmitCookie =
-                getEmitter()->emitAddLabel(gcInfo.gcVarPtrSetCur, gcInfo.gcRegGCrefSetCur, gcInfo.gcRegByrefSetCur);
-
-            instGen(INS_nop);
-        }
+        genInsertNopForUnwinder(block);
 #endif // defined(_TARGET_ARM_)
 
         genUpdateCurrentFunclet(block);
index 329c4a7..001048e 100644 (file)
@@ -246,6 +246,10 @@ void CodeGen::genCodeForBBlist()
             }
         }
 
+#if FEATURE_EH_FUNCLETS && defined(_TARGET_ARM_)
+        genInsertNopForUnwinder(block);
+#endif
+
         /* Start a new code output block */
 
         genUpdateCurrentFunclet(block);
index 5cb2ccd..09cdcca 100644 (file)
@@ -2577,7 +2577,6 @@ AGAIN:
             inst_RV_IV(ins, reg, tree->gtIntCon.gtIconVal, emitActualTypeSize(tree->TypeGet()), flags);
             break;
 
-#if CPU_LONG_USES_REGPAIR
         case GT_CNS_LNG:
 
             assert(size == EA_4BYTE || size == EA_8BYTE);
@@ -2598,8 +2597,7 @@ AGAIN:
                 constVal = (ssize_t)(tree->gtLngCon.gtLconVal >> 32);
                 size     = EA_4BYTE;
             }
-#ifndef LEGACY_BACKEND
-#ifdef _TARGET_ARM_
+#if defined(_TARGET_ARM_) && CPU_LONG_USES_REGPAIR
             if ((ins != INS_mov) && !arm_Valid_Imm_For_Instr(ins, constVal, flags))
             {
                 regNumber constReg = (offs == 0) ? genRegPairLo(tree->gtRegPair) : genRegPairHi(tree->gtRegPair);
@@ -2607,12 +2605,10 @@ AGAIN:
                 getEmitter()->emitIns_R_R(ins, size, reg, constReg, flags);
                 break;
             }
-#endif // _TARGET_ARM_
-#endif // !LEGACY_BACKEND
+#endif // _TARGET_ARM_ && CPU_LONG_USES_REGPAIR
 
             inst_RV_IV(ins, reg, constVal, size, flags);
             break;
-#endif // CPU_LONG_USES_REGPAIR
 
         case GT_COMMA:
             tree = tree->gtOp.gtOp2;
index 4eded3e..2d0eee3 100644 (file)
@@ -1075,7 +1075,7 @@ void* Compiler::ehEmitCookie(BasicBlock* block)
 
     void* cookie;
 
-#if FEATURE_EH_FUNCLETS && defined(_TARGET_ARM_) && defined(LEGACY_BACKEND)
+#if FEATURE_EH_FUNCLETS && defined(_TARGET_ARM_)
     if (block->bbFlags & BBF_FINALLY_TARGET)
     {
         // Use the offset of the beginning of the NOP padding, not the main block.