From 8462d0c8a5c7d0073ee2485354dec646f8c13a7f Mon Sep 17 00:00:00 2001 From: Petr Bred Date: Thu, 8 Feb 2018 15:04:44 +0300 Subject: [PATCH] [RyuJIT/ARM32] Fix crash while generating CFI unwind info Signed-off-by: Petr Bred --- src/jit/unwind.cpp | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/jit/unwind.cpp b/src/jit/unwind.cpp index 773339d..1f090b2 100644 --- a/src/jit/unwind.cpp +++ b/src/jit/unwind.cpp @@ -134,8 +134,7 @@ void Compiler::unwindPushPopCFI(regNumber reg) assert(compGeneratingProlog); #endif - FuncInfoDsc* func = funCurrentFunc(); - + FuncInfoDsc* func = funCurrentFunc(); unsigned int cbProlog = 0; if (compGeneratingProlog) { @@ -213,12 +212,18 @@ void Compiler::unwindPushPopMaskCFI(regMaskTP regMask, bool isFloat) void Compiler::unwindAllocStackCFI(unsigned size) { +#if defined(_TARGET_ARM_) + assert(compGeneratingEpilog); +#else assert(compGeneratingProlog); - - FuncInfoDsc* func = funCurrentFunc(); - - unsigned int cbProlog = unwindGetCurrentOffset(func); - noway_assert((BYTE)cbProlog == cbProlog); +#endif + FuncInfoDsc* func = funCurrentFunc(); + unsigned int cbProlog = 0; + if (compGeneratingProlog) + { + cbProlog = unwindGetCurrentOffset(func); + noway_assert((BYTE)cbProlog == cbProlog); + } createCfiCode(func, cbProlog, CFI_ADJUST_CFA_OFFSET, DWARF_REG_ILLEGAL, size); } @@ -231,11 +236,18 @@ void Compiler::unwindAllocStackCFI(unsigned size) // void Compiler::unwindSetFrameRegCFI(regNumber reg, unsigned offset) { +#if defined(_TARGET_ARM_) + assert(compGeneratingEpilog); +#else assert(compGeneratingProlog); - FuncInfoDsc* func = funCurrentFunc(); - - unsigned int cbProlog = unwindGetCurrentOffset(func); - noway_assert((BYTE)cbProlog == cbProlog); +#endif + FuncInfoDsc* func = funCurrentFunc(); + unsigned int cbProlog = 0; + if (compGeneratingProlog) + { + cbProlog = unwindGetCurrentOffset(func); + noway_assert((BYTE)cbProlog == cbProlog); + } createCfiCode(func, cbProlog, CFI_DEF_CFA_REGISTER, mapRegNumToDwarfReg(reg)); if (offset != 0) -- 2.7.4