xtensa: Enforce return address saving when -Og is specified
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Sat, 18 Feb 2023 04:54:10 +0000 (13:54 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Tue, 21 Feb 2023 01:32:31 +0000 (17:32 -0800)
Leaf function often omits saving its return address to the stack slot,
and this feature often makes debugging very confusing, especially for
stack dump analysis.

gcc/ChangeLog:

* config/xtensa/xtensa.cc (xtensa_call_save_reg): Change to return
true if register A0 (return address register) when -Og is specified.

gcc/config/xtensa/xtensa.cc

index 3e2e22d..d0320ef 100644 (file)
@@ -3223,8 +3223,11 @@ xtensa_call_save_reg (int regno)
     return false;
 
   if (regno == A0_REG)
-    return crtl->profile || !crtl->is_leaf || crtl->calls_eh_return ||
-      df_regs_ever_live_p (regno);
+    /* Ensure the return address to be saved to the stack slot in order
+       to assist stack dump analysis when -Og is specified.  */
+    return optimize_debug
+          || crtl->profile || !crtl->is_leaf || crtl->calls_eh_return
+          || df_regs_ever_live_p (regno);
 
   if (crtl->calls_eh_return && IN_RANGE (regno, 2, 3))
     return true;