diff mbox series

[ARC] Fix stack usage info for naked functions.

Message ID 20180406160229.11692-1-abrodkin@synopsys.com
State New
Headers show
Series [ARC] Fix stack usage info for naked functions. | expand

Commit Message

Alexey Brodkin April 6, 2018, 4:02 p.m. UTC
When code containing "naked" function gets compiled with '-fstack-usage'
compiler prints the following warning:
---------------------------------->8-----------------------------
board/synopsys/hsdk/hsdk.c: In function 'hsdk_core_init_f':
board/synopsys/hsdk/hsdk.c:345:1: warning: stack usage computation not supported for this target
 }
 ^
---------------------------------->8-----------------------------

Even though stack calculation makes no sense for "naked" function
we still need to correctly report stack size back to make compiler
happy.

This problem was caught in U-Boot here:
https://lists.denx.de/pipermail/u-boot/2018-March/324325.html

The same fix was done earlier for ARM, see:
"config/arm/arm.c (arm_expand_prologue): Set the stack usage to 0 "
https://github.com/gcc-mirror/gcc/commit/023a7c5dd37

gcc/
2018-04-06  Alexey Brodkin <abrodkin@synopsys.com>

	* config/arc/arc.c (arc_expand_prologue): Set stack usage info
	also for naked functions.
---
 gcc/config/arc/arc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Claudiu Zissulescu April 9, 2018, 3:07 p.m. UTC | #1
Accepted & committed, thank you for your contribution,
Claudiu

> -----Original Message-----
> From: Alexey Brodkin [mailto:abrodkin@synopsys.com]
> Sent: Friday, April 06, 2018 6:02 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Claudiu Zissulescu <claziss@synopsys.com>; Alexey Brodkin
> <abrodkin@synopsys.com>
> Subject: [PATCH] [ARC] Fix stack usage info for naked functions.
> 
> When code containing "naked" function gets compiled with '-fstack-usage'
> compiler prints the following warning:
> ---------------------------------->8-----------------------------
> board/synopsys/hsdk/hsdk.c: In function 'hsdk_core_init_f':
> board/synopsys/hsdk/hsdk.c:345:1: warning: stack usage computation not
> supported for this target
>  }
>  ^
> ---------------------------------->8-----------------------------
> 
> Even though stack calculation makes no sense for "naked" function
> we still need to correctly report stack size back to make compiler
> happy.
> 
> This problem was caught in U-Boot here:
> https://lists.denx.de/pipermail/u-boot/2018-March/324325.html
> 
> The same fix was done earlier for ARM, see:
> "config/arm/arm.c (arm_expand_prologue): Set the stack usage to 0 "
> https://github.com/gcc-mirror/gcc/commit/023a7c5dd37
> 
> gcc/
> 2018-04-06  Alexey Brodkin <abrodkin@synopsys.com>
> 
> 	* config/arc/arc.c (arc_expand_prologue): Set stack usage info
> 	also for naked functions.
> ---
>  gcc/config/arc/arc.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 32fcb81880a2..3cb4ba5b4dd7 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -3149,7 +3149,11 @@ arc_expand_prologue (void)
> 
>    /* Naked functions don't have prologue.  */
>    if (ARC_NAKED_P (fn_type))
> -    return;
> +    {
> +      if (flag_stack_usage_info)
> +	current_function_static_stack_size = 0;
> +      return;
> +    }
> 
>    /* Compute total frame size.  */
>    size = arc_compute_frame_size ();
> --
> 2.14.3
diff mbox series

Patch

diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 32fcb81880a2..3cb4ba5b4dd7 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -3149,7 +3149,11 @@  arc_expand_prologue (void)
 
   /* Naked functions don't have prologue.  */
   if (ARC_NAKED_P (fn_type))
-    return;
+    {
+      if (flag_stack_usage_info)
+	current_function_static_stack_size = 0;
+      return;
+    }
 
   /* Compute total frame size.  */
   size = arc_compute_frame_size ();