diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-11 14:52:57 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-11 14:52:57 +0000 |
commit | 26d04e5f6ba139e1bb67304415bd449fb3850aaf (patch) | |
tree | 85ac110020df9a0d5ae2303c5c233d027bad4d3a /gcc/function.c | |
parent | 49166fc31e2764a27545c4522a21396ce2e5814b (diff) | |
download | gcc-26d04e5f6ba139e1bb67304415bd449fb3850aaf.tar.gz |
* function.h (frame_offset_overflow): Declare.
* function.c (frame_offset_overflow): New function.
(assign_stack_local_1): Call it to detect that the offset overflows.
* cfgexpand.c (alloc_stack_frame_space): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111964 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/function.c')
-rw-r--r-- | gcc/function.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/gcc/function.c b/gcc/function.c index 473f5d4758f..988d613c4d7 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -358,12 +358,33 @@ get_func_frame_size (struct function *f) /* Return size needed for stack frame based on slots so far allocated. This size counts from zero. It is not rounded to PREFERRED_STACK_BOUNDARY; the caller may have to do that. */ + HOST_WIDE_INT get_frame_size (void) { return get_func_frame_size (cfun); } +/* Issue an error message and return TRUE if frame OFFSET overflows in + the signed target pointer arithmetics for function FUNC. Otherwise + return FALSE. */ + +bool +frame_offset_overflow (HOST_WIDE_INT offset, tree func) +{ + unsigned HOST_WIDE_INT size = FRAME_GROWS_DOWNWARD ? -offset : offset; + + if (size > ((unsigned HOST_WIDE_INT) 1 << (GET_MODE_BITSIZE (Pmode) - 1)) + /* Leave room for the fixed part of the frame. */ + - 64 * UNITS_PER_WORD) + { + error ("%Jtotal size of local objects too large", func); + return TRUE; + } + + return FALSE; +} + /* Allocate a stack slot of SIZE bytes and return a MEM rtx for it with machine mode MODE. @@ -479,20 +500,8 @@ assign_stack_local_1 (enum machine_mode mode, HOST_WIDE_INT size, int align, function->x_stack_slot_list = gen_rtx_EXPR_LIST (VOIDmode, x, function->x_stack_slot_list); - /* Try to detect frame size overflows on native platforms. */ -#if BITS_PER_WORD >= 32 - if ((FRAME_GROWS_DOWNWARD - ? (unsigned HOST_WIDE_INT) -function->x_frame_offset - : (unsigned HOST_WIDE_INT) function->x_frame_offset) - > ((unsigned HOST_WIDE_INT) 1 << (BITS_PER_WORD - 1)) - /* Leave room for the fixed part of the frame. */ - - 64 * UNITS_PER_WORD) - { - error ("%Jtotal size of local objects too large", function->decl); - /* Avoid duplicate error messages as much as possible. */ - function->x_frame_offset = 0; - } -#endif + if (frame_offset_overflow (function->x_frame_offset, function->decl)) + function->x_frame_offset = 0; return x; } |