aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@bitrange.com>2020-07-21 01:15:36 +0200
committerHans-Peter Nilsson <hp@bitrange.com>2020-07-21 01:17:26 +0200
commite21a33c232038574c67cb2a9222c4d5fbe33f7d3 (patch)
treeb01f7867bce03f8b7ad395543012a9a5166ad62e
parent932fbc868ad429167a3d4d5625aa9d6dc0b4506b (diff)
downloadgcc-e21a33c232038574c67cb2a9222c4d5fbe33f7d3.zip
gcc-e21a33c232038574c67cb2a9222c4d5fbe33f7d3.tar.gz
gcc-e21a33c232038574c67cb2a9222c4d5fbe33f7d3.tar.bz2
mmix: support -fstack-usage
MMIX has two stacks; the regular one using register $254 as a convention and the register-stack, pushed and popped by call instructions (usually). The decision to only report the stack usage of the regular stack (and not of the register stack) may be updated, perhaps the sum is better. This initial decision is helped a little bit by the order of passes: the size of the register-stack is calculated only later (in the machine-dependent reorg pass), long after finalization of the stack-usage info (in the prologue/epilogue pass). No regressions for mmix-knuth-mmixware (but a whole lot more PASSes), committed. gcc: * config/mmix/mmix.c (mmix_expand_prologue): Calculate the total allocated size and set current_function_static_stack_size, if flag_stack_usage_info.
-rw-r--r--gcc/config/mmix/mmix.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index 66e3d58..b7263a3 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -2014,6 +2014,7 @@ mmix_expand_prologue (void)
+ crtl->args.pretend_args_size
+ locals_size + 7) & ~7;
HOST_WIDE_INT offset = -8;
+ HOST_WIDE_INT total_allocated_stack_space = 0;
/* Add room needed to save global non-register-stack registers. */
for (regno = 255;
@@ -2063,6 +2064,8 @@ mmix_expand_prologue (void)
? (256 - 8) : stack_space_to_allocate;
mmix_emit_sp_add (-stack_chunk);
+ total_allocated_stack_space += stack_chunk;
+
offset += stack_chunk;
stack_space_to_allocate -= stack_chunk;
}
@@ -2091,6 +2094,7 @@ mmix_expand_prologue (void)
? (256 - 8 - 8) : stack_space_to_allocate;
mmix_emit_sp_add (-stack_chunk);
+ total_allocated_stack_space += stack_chunk;
offset += stack_chunk;
stack_space_to_allocate -= stack_chunk;
@@ -2126,6 +2130,7 @@ mmix_expand_prologue (void)
? (256 - 8 - 8) : stack_space_to_allocate;
mmix_emit_sp_add (-stack_chunk);
+ total_allocated_stack_space += stack_chunk;
offset += stack_chunk;
stack_space_to_allocate -= stack_chunk;
@@ -2170,6 +2175,7 @@ mmix_expand_prologue (void)
? (256 - 8 - 8) : stack_space_to_allocate;
mmix_emit_sp_add (-stack_chunk);
+ total_allocated_stack_space += stack_chunk;
offset += stack_chunk;
stack_space_to_allocate -= stack_chunk;
@@ -2220,6 +2226,8 @@ mmix_expand_prologue (void)
? (256 - offset - 8) : stack_space_to_allocate);
mmix_emit_sp_add (-stack_chunk);
+ total_allocated_stack_space += stack_chunk;
+
offset += stack_chunk;
stack_space_to_allocate -= stack_chunk;
}
@@ -2237,6 +2245,14 @@ mmix_expand_prologue (void)
wasn't allocated above. */
if (stack_space_to_allocate)
mmix_emit_sp_add (-stack_space_to_allocate);
+ total_allocated_stack_space += stack_space_to_allocate;
+
+ /* Let's assume that reporting the usage of the regular stack on its
+ own, is more useful than either not supporting -fstack-usage or
+ reporting the sum of the usages of the regular stack and the
+ register stack. */
+ if (flag_stack_usage_info)
+ current_function_static_stack_size = total_allocated_stack_space;
}
/* Expands the function epilogue into RTX. */