diff mbox series

Committed: cris: support -fstack-usage

Message ID 20210224174020.DFFBA203E4@pchp3.se.axis.com
State New
Headers show
Series Committed: cris: support -fstack-usage | expand

Commit Message

Hans-Peter Nilsson Feb. 24, 2021, 5:40 p.m. UTC
All the bits were there, used with a pre-existing
-mmax-stackframe=SIZE which unfortunately seems to lack
test-cases.

Note that the early-return for -mno-prologue-epilogue (what
some targets call -mnaked) is deliberately not clearing
current_function_static_stack_size, as I consider that
erroneous usage but don't really care to emit a better error
message.

For stack-usage-1.c, like most ILP32 targets, CRIS (at -O0)
needs 4 bytes for the return-address.  The default size of
256 seems ill chosen but not worth fixing.

gcc:
	* config/cris/cris.c (cris_expand_prologue): Set
	current_function_static_stack_size, if flag_stack_usage_info.

gcc/testsuite:
	* gcc.dg/stack-usage-1.c: Adjust for CRIS.
---
 gcc/config/cris/cris.c               | 5 +++++
 gcc/testsuite/gcc.dg/stack-usage-1.c | 2 ++
 2 files changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c
index 8a42aa16da13..0774ed8299ad 100644
--- a/gcc/config/cris/cris.c
+++ b/gcc/config/cris/cris.c
@@ -2892,8 +2892,13 @@  cris_expand_prologue (void)
       framesize += size + cfoa_size;
     }
 
+  /* FIXME: -mmax-stackframe=SIZE is obsoleted; use -Wstack-usage=SIZE
+     instead.  Make it an alias?  */
   if (cris_max_stackframe && framesize > cris_max_stackframe)
     warning (0, "stackframe too big: %d bytes", framesize);
+
+  if (flag_stack_usage_info)
+    current_function_static_stack_size = framesize;
 }
 
 /* The expander for the epilogue pattern.  */
diff --git a/gcc/testsuite/gcc.dg/stack-usage-1.c b/gcc/testsuite/gcc.dg/stack-usage-1.c
index be1254a7348d..93cfe7c01639 100644
--- a/gcc/testsuite/gcc.dg/stack-usage-1.c
+++ b/gcc/testsuite/gcc.dg/stack-usage-1.c
@@ -103,6 +103,8 @@ 
 #define SIZE 252
 #elif defined (__csky__)
 #  define SIZE 252
+#elif defined (__CRIS__)
+#  define SIZE 252
 #else
 #  define SIZE 256
 #endif