From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1118) id B34C33858C83; Fri, 21 Apr 2023 14:39:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B34C33858C83 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682087961; bh=fZQzklYSbwmfg6c7aJKgcBDIfbYQM8lxi3vZ0+zBugY=; h=From:To:Subject:Date:From; b=sw9YeSAKOTRzvs7Ekr5+feaEtRW46Lmf74HV4GTCAyFukYDKlGp5f4/k6VtCR55l5 u7WCPOVAxGVf2ANbKNhAfUZbjdKBdjCOVtGVitQm9dW2ChgIQcePtxoqBo27zTBPZM Ok0CVSkCRUAatFCe26RboocRt+IIByRfl2zKuf1k= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: John David Anglin To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-9461] Fix handling of large arguments passed by value. X-Act-Checkin: gcc X-Git-Author: John David Anglin X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: a8f45d61caba90649b3f264babab17353d774751 X-Git-Newrev: dca9419cc3844d3cf3c06f51d5ca57e3b5f50920 Message-Id: <20230421143921.B34C33858C83@sourceware.org> Date: Fri, 21 Apr 2023 14:39:21 +0000 (GMT) List-Id: https://gcc.gnu.org/g:dca9419cc3844d3cf3c06f51d5ca57e3b5f50920 commit r12-9461-gdca9419cc3844d3cf3c06f51d5ca57e3b5f50920 Author: John David Anglin Date: Fri Apr 21 14:38:42 2023 +0000 Fix handling of large arguments passed by value. 2023-04-15 John David Anglin gcc/ChangeLog: PR target/109478 * config/pa/pa-protos.h (pa_function_arg_size): Update prototype. * config/pa/pa.cc (pa_function_arg): Return NULL_RTX if argument size is zero. (pa_arg_partial_bytes): Don't call pa_function_arg_size twice. (pa_function_arg_size): Change return type to int. Return zero for arguments larger than 1 GB. Update comments. Diff: --- gcc/config/pa/pa-protos.h | 2 +- gcc/config/pa/pa.cc | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h index fe8b7a5091e..6b587538e94 100644 --- a/gcc/config/pa/pa-protos.h +++ b/gcc/config/pa/pa-protos.h @@ -106,7 +106,7 @@ extern void pa_asm_output_aligned_local (FILE *, const char *, unsigned int); extern void pa_hpux_asm_output_external (FILE *, tree, const char *); extern HOST_WIDE_INT pa_initial_elimination_offset (int, int); -extern HOST_WIDE_INT pa_function_arg_size (machine_mode, const_tree); +extern int pa_function_arg_size (machine_mode, const_tree); extern void pa_output_function_label (FILE *); extern void hppa_profile_hook (int); diff --git a/gcc/config/pa/pa.cc b/gcc/config/pa/pa.cc index 9f43802075f..65f8fe814c6 100644 --- a/gcc/config/pa/pa.cc +++ b/gcc/config/pa/pa.cc @@ -9784,6 +9784,8 @@ pa_function_arg (cumulative_args_t cum_v, const function_arg_info &arg) return NULL_RTX; arg_size = pa_function_arg_size (mode, type); + if (!arg_size) + return NULL_RTX; /* If this arg would be passed partially or totally on the stack, then this routine should return zero. pa_arg_partial_bytes will @@ -9985,15 +9987,16 @@ pa_arg_partial_bytes (cumulative_args_t cum_v, const function_arg_info &arg) CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); unsigned int max_arg_words = 8; unsigned int offset = 0; + int arg_size; if (!TARGET_64BIT) return 0; - if (pa_function_arg_size (arg.mode, arg.type) > 1 && (cum->words & 1)) + arg_size = pa_function_arg_size (arg.mode, arg.type); + if (arg_size > 1 && (cum->words & 1)) offset = 1; - if (cum->words + offset + pa_function_arg_size (arg.mode, arg.type) - <= max_arg_words) + if (cum->words + offset + arg_size <= max_arg_words) /* Arg fits fully into registers. */ return 0; else if (cum->words + offset >= max_arg_words) @@ -11067,17 +11070,25 @@ pa_starting_frame_offset (void) return 8; } -/* Figure out the size in words of the function argument. The size - returned by this function should always be greater than zero because - we pass variable and zero sized objects by reference. */ +/* Figure out the size in words of the function argument. */ -HOST_WIDE_INT +int pa_function_arg_size (machine_mode mode, const_tree type) { HOST_WIDE_INT size; size = mode != BLKmode ? GET_MODE_SIZE (mode) : int_size_in_bytes (type); - return CEIL (size, UNITS_PER_WORD); + + /* The 64-bit runtime does not restrict the size of stack frames, + but the gcc calling conventions limit argument sizes to 1G. Our + prologue/epilogue code limits frame sizes to just under 32 bits. + 1G is also the maximum frame size that can be handled by the HPUX + unwind descriptor. Since very large TYPE_SIZE_UNIT values can + occur for (parallel:BLK []), we need to ignore large arguments + passed by value. */ + if (size >= (1 << (HOST_BITS_PER_INT - 2))) + size = 0; + return (int) CEIL (size, UNITS_PER_WORD); } #include "gt-pa.h"