From patchwork Sat Apr 15 17:56:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John David Anglin X-Patchwork-Id: 83764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1168991vqo; Sat, 15 Apr 2023 10:57:21 -0700 (PDT) X-Google-Smtp-Source: AKy350ZqvSGoALLqABbHPpmne1r1R+QBPeDr0khFcmNDV2LUy6eVLrDvYSOHJ/eB+OoNL0LI/Qrg X-Received: by 2002:a17:906:c041:b0:921:da99:f39c with SMTP id bm1-20020a170906c04100b00921da99f39cmr2933300ejb.12.1681581440774; Sat, 15 Apr 2023 10:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681581440; cv=none; d=google.com; s=arc-20160816; b=q3Pr5RVilXmyzUQ+Qw1Y/Etk4ONBTv9IZNz6cl8S4dHJAahFHAoDS/oWNNpGuhIa7l 0oa4xmoXWBgSDOMXfViWxGhZYItRwuFAPF8omfXp7ZYMwyJcer7QGf+8LsNKlbdVHgcU k+GoDzyWZOpFmy8soa4DPcaxEiokev6IdHWuPVkRWjfOK2kA9AMTxLDkZWfSWGn4QbZv zTybgKE9Lh6Y6afsYqdVp4RjueQiqGxo5ekhPT1YVlgxE5nQLyCZq7YN2n8xRN9yyEcy bETjEsSZdQBxdNig99kHJWXzlLDR7kiM7/UwbKzjEl538wFoVUN4Dlf31bXXdJZATwoX YUVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition :mime-version:message-id:subject:to:from:date:dmarc-filter :delivered-to; bh=IEeTdr8uKnyk50zmaPoCQ10g8S61bU1AKEmCHWGUez4=; b=nceraoAq5XEJTmErW32pPq8rgm2gXjQN5/F6KvMXcSeQ1ulCi+UMw26kynT5Lz1G/y kc9BO4apo3ZKiMR19svbGvXdMkU4YV2vWfn+qRGh8jw+D29J0n4tiX20lmSUR6aRdwlY OFbu4b63W89U/eSl7h+SngvVQ2MVcKxU/iGDnFXkDjHVJ3Fr6c37S+6zx4mfzEp7Slvf f9MmFToBk36745TEVHj/HsQASQtvQD67wtLzLELJ6UkI6QwUhuqIhIMwzO3i0Lx9Ttkd MlRey1VShnLy8/oO72BfRcTA0xq7HfRsNIIxdA6dLleL/x1vFv4FRbPXJCEUhPjVyHc9 SyvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d14-20020a50fb0e000000b0050480a1c7d9si6316502edq.435.2023.04.15.10.57.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Apr 2023 10:57:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BD9813857343 for ; Sat, 15 Apr 2023 17:57:13 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from dellerweb.de (unknown [IPv6:2a02:c207:3003:236::1]) by sourceware.org (Postfix) with ESMTPS id BB1233858D20 for ; Sat, 15 Apr 2023 17:56:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BB1233858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=parisc-linux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=parisc-linux.org Received: from mx3210.localdomain (unknown [142.181.186.176]) by dellerweb.de (Postfix) with ESMTPSA id 4818516000A8; Sat, 15 Apr 2023 19:56:47 +0200 (CEST) Received: by mx3210.localdomain (Postfix, from userid 1000) id 4988D22012C; Sat, 15 Apr 2023 17:56:45 +0000 (UTC) Date: Sat, 15 Apr 2023 17:56:45 +0000 From: John David Anglin To: GCC Patches Subject: [committed] hppa: Fix handling of large arguments passed by value Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763265941099555493?= X-GMAIL-MSGID: =?utf-8?q?1763265941099555493?= This change revises pa_function_arg_size to return values that fit in an int. For a number of reasons, updating pa_function_arg, pa_arg_partial_bytes, etc, to handle handle HOST_WIDE_INT values didn't seem useful. Currently, gcc limits the size of arguments passed by value to 1 GB. The PA prologue/epilogue code only handles 32-bit frame offsets and 1 GB is the maximum frame size that can be recorded in the HPUX unwind descriptor. Thus, limiting argument sizes to 1 GB is enough. Tested on hppa64-hp-hpux11.11 and hppa-unknown-linux-gnu. Committed to trunk. Dave --- 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 --git a/gcc/config/pa/pa-protos.h b/gcc/config/pa/pa-protos.h index c0a61ea89c3..b4b1310a52d 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 3f91ebce603..db633b275e5 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"