aboutsummaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>2000-08-16 01:15:37 +0000
committerRichard Kenner <kenner@gcc.gnu.org>2000-08-15 21:15:37 -0400
commit7393c6422b26ff6275354b69b74cb06c280caa16 (patch)
treefae62ef4946025fccda89bb881cd3b03f4785068 /gcc/stmt.c
parent81baa09a56392e03742b4b253b9fd82b3ecbd783 (diff)
downloadgcc-7393c6422b26ff6275354b69b74cb06c280caa16.zip
gcc-7393c6422b26ff6275354b69b74cb06c280caa16.tar.gz
gcc-7393c6422b26ff6275354b69b74cb06c280caa16.tar.bz2
calls.c (ECF_SP_DEPRESSED): New macro.
* calls.c (ECF_SP_DEPRESSED): New macro. (calls_function_1): Treat calling sp-depressed function as alloca. (emit_call_1): Don't adjust SP if calling sp-depressed function. (expand_call): Set ECF_SP_DEPRESSED if TYPE_RETURNS_STACK_DEPRESSED. If sp-depressed, ensure block saves and restores SP. * fold-const.c (extract_muldiv): Only check TYPE_IS_SIZETYPE for INTEGER_TYPE. * function.c (keep_stack_depressed): New function. (thread_prologue_and_epilogue_insns): Call it. * print-tree.c (print_node): Use HOST_WIDE_INT_PRINT_UNSIGNED to print DECL_OFFSET_ALIGN. Print no-force-blk and transparent-union flags properly. * stmt.c (expand_goto_internal): Don't restore stack if last block and function returns with sp depressed. (fixup_gotos): Likewise. (save_stack_pointer): New function, from code in expand_decl. (expand_decl): Call new function. * tree.h (TYPE_IS_SIZETYPE): Call INTEGER_TYPE_CHECK. (TYPE_RETURNS_STACK_DEPRESSED): New macro. (save_stack_pointer): New declaration. From-SVN: r35734
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 38572ca..6ecfcd2 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -903,7 +903,15 @@ expand_goto_internal (body, label, last_insn)
deleted as dead by flow. */
clear_pending_stack_adjust ();
do_pending_stack_adjust ();
- emit_stack_restore (SAVE_BLOCK, stack_level, NULL_RTX);
+
+ /* Don't do this adjust if it's to the end label and this function
+ is to return with a depressed stack pointer. */
+ if (label == return_label
+ && (TYPE_RETURNS_STACK_DEPRESSED
+ (TREE_TYPE (current_function_decl))))
+ ;
+ else
+ emit_stack_restore (SAVE_BLOCK, stack_level, NULL_RTX);
}
if (body != 0 && DECL_TOO_LATE (body))
@@ -1182,7 +1190,10 @@ fixup_gotos (thisblock, stack_level, cleanup_list, first_insn, dont_jump_in)
/* Restore stack level for the biggest contour that this
jump jumps out of. */
- if (f->stack_level)
+ if (f->stack_level
+ && ! (f->target_rtl == return_label
+ && (TYPE_RETURNS_STACK_DEPRESSED
+ (TREE_TYPE (current_function_decl)))))
emit_stack_restore (SAVE_BLOCK, f->stack_level, f->before_jump);
/* Finish up the sequence containing the insns which implement the
@@ -3667,6 +3678,23 @@ expand_end_bindings (vars, mark_ends, dont_jump_in)
pop_temp_slots ();
}
+/* Generate code to save the stack pointer at the start of the current block
+ and set up to restore it on exit. */
+
+void
+save_stack_pointer ()
+{
+ struct nesting *thisblock = block_stack;
+
+ if (thisblock->data.block.stack_level == 0)
+ {
+ emit_stack_save (thisblock->next ? SAVE_BLOCK : SAVE_FUNCTION,
+ &thisblock->data.block.stack_level,
+ thisblock->data.block.first_insn);
+ stack_block_stack = thisblock;
+ }
+}
+
/* Generate RTL for the automatic variable declaration DECL.
(Other kinds of declarations are simply ignored if seen here.) */
@@ -3777,14 +3805,8 @@ expand_decl (decl)
/* Record the stack pointer on entry to block, if have
not already done so. */
- if (thisblock->data.block.stack_level == 0)
- {
- do_pending_stack_adjust ();
- emit_stack_save (thisblock->next ? SAVE_BLOCK : SAVE_FUNCTION,
- &thisblock->data.block.stack_level,
- thisblock->data.block.first_insn);
- stack_block_stack = thisblock;
- }
+ do_pending_stack_adjust ();
+ save_stack_pointer ();
/* In function-at-a-time mode, variable_size doesn't expand this,
so do it now. */