[armel tizen] Fixed CoreRT issue #4626 unwinding support (#15913)
authorsergey ignatov <sergign60@mail.ru>
Fri, 19 Jan 2018 14:28:38 +0000 (17:28 +0300)
committerJan Kotas <jkotas@microsoft.com>
Fri, 19 Jan 2018 14:28:38 +0000 (06:28 -0800)
src/jit/compiler.h
src/jit/unwind.cpp
src/jit/unwindamd64.cpp
src/jit/unwindarm.cpp

index 7f2f3b8..bc039df 100644 (file)
@@ -7377,9 +7377,9 @@ private:
 #if defined(_TARGET_UNIX_)
     int mapRegNumToDwarfReg(regNumber reg);
     void createCfiCode(FuncInfoDsc* func, UCHAR codeOffset, UCHAR opcode, USHORT dwarfReg, INT offset = 0);
-    void unwindPushCFI(regNumber reg);
+    void unwindPushPopCFI(regNumber reg);
     void unwindBegPrologCFI();
-    void unwindPushMaskCFI(regMaskTP regMask, bool isFloat);
+    void unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat);
     void unwindAllocStackCFI(unsigned size);
     void unwindSetFrameRegCFI(regNumber reg, unsigned offset);
     void unwindEmitFuncCFI(FuncInfoDsc* func, void* pHotCode, void* pColdCode);
index 643f15a..773339d 100644 (file)
@@ -126,16 +126,25 @@ void Compiler::createCfiCode(FuncInfoDsc* func, UCHAR codeOffset, UCHAR cfiOpcod
     func->cfiCodes->push_back(cfiEntry);
 }
 
-void Compiler::unwindPushCFI(regNumber reg)
+void Compiler::unwindPushPopCFI(regNumber reg)
 {
+#if defined(_TARGET_ARM_)
+    assert(compGeneratingEpilog);
+#else
     assert(compGeneratingProlog);
+#endif
 
     FuncInfoDsc* func = funCurrentFunc();
 
-    unsigned int cbProlog = unwindGetCurrentOffset(func);
-    noway_assert((BYTE)cbProlog == cbProlog);
+    unsigned int cbProlog = 0;
+    if (compGeneratingProlog)
+    {
+        cbProlog = unwindGetCurrentOffset(func);
+        noway_assert((BYTE)cbProlog == cbProlog);
+
+        createCfiCode(func, cbProlog, CFI_ADJUST_CFA_OFFSET, DWARF_REG_ILLEGAL, REGSIZE_BYTES == 8 ? 8 : 4);
+    }
 
-    createCfiCode(func, cbProlog, CFI_ADJUST_CFA_OFFSET, DWARF_REG_ILLEGAL, REGSIZE_BYTES == 8 ? 8 : 4);
     if ((RBM_CALLEE_SAVED & genRegMask(reg))
 #if defined(UNIX_AMD64_ABI)
 #if ETW_EBP_FRAMED
@@ -183,7 +192,7 @@ void Compiler::unwindBegPrologCFI()
 #endif // FEATURE_EH_FUNCLETS
 }
 
-void Compiler::unwindPushMaskCFI(regMaskTP regMask, bool isFloat)
+void Compiler::unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat)
 {
     regMaskTP regBit = isFloat ? genRegMask(REG_FP_FIRST) : 1;
 
@@ -197,7 +206,7 @@ void Compiler::unwindPushMaskCFI(regMaskTP regMask, bool isFloat)
 
         if (regBit & regMask)
         {
-            unwindPushCFI(regNum);
+            unwindPushPopCFI(regNum);
         }
     }
 }
index d4c077e..a0cbfb1 100644 (file)
@@ -209,7 +209,7 @@ void Compiler::unwindPush(regNumber reg)
 #ifdef UNIX_AMD64_ABI
     if (generateCFIUnwindCodes())
     {
-        unwindPushCFI(reg);
+        unwindPushPopCFI(reg);
     }
     else
 #endif // UNIX_AMD64_ABI
index 8c01648..9bb07ec 100644 (file)
@@ -371,7 +371,6 @@ void Compiler::unwindPushMaskInt(regMaskTP maskInt)
 #if defined(_TARGET_UNIX_)
     if (generateCFIUnwindCodes())
     {
-        unwindPushMaskCFI(maskInt, false);
         return;
     }
 #endif // _TARGET_UNIX_
@@ -388,7 +387,6 @@ void Compiler::unwindPushMaskFloat(regMaskTP maskFloat)
 #if defined(_TARGET_UNIX_)
     if (generateCFIUnwindCodes())
     {
-        unwindPushMaskCFI(maskFloat, true);
         return;
     }
 #endif // _TARGET_UNIX_
@@ -401,6 +399,7 @@ void Compiler::unwindPopMaskInt(regMaskTP maskInt)
 #if defined(_TARGET_UNIX_)
     if (generateCFIUnwindCodes())
     {
+        unwindPushPopMaskCFI(maskInt, false);
         return;
     }
 #endif // _TARGET_UNIX_
@@ -429,6 +428,7 @@ void Compiler::unwindPopMaskFloat(regMaskTP maskFloat)
 #if defined(_TARGET_UNIX_)
     if (generateCFIUnwindCodes())
     {
+        unwindPushPopMaskCFI(maskFloat, true);
         return;
     }
 #endif // _TARGET_UNIX_
@@ -443,7 +443,7 @@ void Compiler::unwindAllocStack(unsigned size)
 #if defined(_TARGET_UNIX_)
     if (generateCFIUnwindCodes())
     {
-        if (compGeneratingProlog)
+        if (compGeneratingEpilog)
         {
             unwindAllocStackCFI(size);
         }
@@ -497,7 +497,7 @@ void Compiler::unwindSetFrameReg(regNumber reg, unsigned offset)
 #if defined(_TARGET_UNIX_)
     if (generateCFIUnwindCodes())
     {
-        if (compGeneratingProlog)
+        if (compGeneratingEpilog)
         {
             unwindSetFrameRegCFI(reg, offset);
         }