From patchwork Sat Feb 4 16:32:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 650664 Delivered-To: patch@linaro.org Received: by 2002:a17:522:d8c:b0:4be:c3dc:14d8 with SMTP id d12csp1447237pva; Sat, 4 Feb 2023 08:37:34 -0800 (PST) X-Google-Smtp-Source: AK7set9yoKzoHaxniHvfWonbm7J+gp8Ec6wS/+xKjotpT4LXnTmu3EhChfSJDOFoMbejSvyf9ZPM X-Received: by 2002:ac8:5a44:0:b0:3b9:b6c8:6d5b with SMTP id o4-20020ac85a44000000b003b9b6c86d5bmr26909392qta.35.1675528653822; Sat, 04 Feb 2023 08:37:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675528653; cv=none; d=google.com; s=arc-20160816; b=AC3+Vo/tsma+rdlU+3VsJPEEjUZWw6mruuAq8C9Rv0anB9JStqlz5hmhjvhCOCnu5w HkSYxt/qgYNDNgN/73NcgIp3uZ0tUReFYUnNPFJMlET5ljR+fnrN2mkCqp80RG9CiaGJ Z7X/y1YZvmtRIxeiL5QtiNcCPQ44IFQHL2XNCentSVWyHPb2iKVB7dcc30a4ypTOKBEO gi/hVhvI8Ud6lru51q26APSkoPIQShlIs/0cH7ul4dkZssvxN+I7hGzmWcUpLlrgAmJ/ uXp6JhnLsiy4+FAMa9F3EESSnUMGszR72WL8yTV/QEzqR/6BTzn3tZqcX5DgGIvoDeTa N/Ig== 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-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mc7bB5r5zBnJDhnppWeIynu+SVvx916JKpMJZLsgtRo=; b=cpRB5GHqmkBwyFR52Zb1MKfccaSdXooMySto3Pzx15Yfgz8nDTpyEVF3BNOTGGX6qS IYCwcd9Rp4Ujvt69u0QqP5u5vrdDhguDd63acguuP4OnZPkYTtFSuFttc3XkvDDl77Xo UeBOy50pbM9IOdigxOdMrx6IGpDMYeW7fRgb87KUzf+jfLS2rffbXw5grJOPoVT9PdDY P+bfWVqVL5KPVSjgxp5F1HRLTNNefkdiwcogWoK84TBxd8RNmj4F7rhna1VBADia7RS6 MmYZT9CKRmpB0UsCjZJ6QlHp2z+dfqBQIXVMo0UW2fj7s0v/0l5Sk9de78ChtPAmng7l 44rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMXEgftx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p65-20020a378d44000000b0072e597d5679si3713912qkd.334.2023.02.04.08.37.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 04 Feb 2023 08:37:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMXEgftx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOLU2-00057l-Jh; Sat, 04 Feb 2023 11:33:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOLTh-00050y-IY for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:33:39 -0500 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pOLTf-0002UX-86 for qemu-devel@nongnu.org; Sat, 04 Feb 2023 11:33:24 -0500 Received: by mail-pj1-x1029.google.com with SMTP id t12-20020a17090aae0c00b00229f4cff534so10048275pjq.1 for ; Sat, 04 Feb 2023 08:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mc7bB5r5zBnJDhnppWeIynu+SVvx916JKpMJZLsgtRo=; b=PMXEgftxDNe6yRFCHIT/Dcg4eNbFe9emV67R3fDFiqFGM6/49nzad4Nx90uQ5o1NGM OY9NAJrTgAQPi6SjbV6N47dQ/QfjOy0OK2g6DhAsdPYQTUTmkdUz21o0XIVnpZIxyHkx Vk9m1QZpfLpLeReAtl97COIQ77wCmfDCU/fieBrMqF6BLv56VfjB3t1bzuJF7SbDTRAZ ytKtdvhSlQFZbcscw+SyVvxHWI2ETIH99wdEIKl7ylBsjpwLBVzgNn8MY5I2DB092qPl rpQXKFBD2PsZmvysEgfkKn5vnZru5P8L6CnqafMSasUI5FgDt8Pd4kNxv6R9PKGOub3k IZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mc7bB5r5zBnJDhnppWeIynu+SVvx916JKpMJZLsgtRo=; b=b5QS2ji/mtoAXFpm3fglzhyL/YQrACkSTi0g2/e4LTwJTwK6bSQz/zJ+oVgsis4bkw RASnAxhNSPdQLOMQ91KkUqlNaBPuwR0Ra8VyMQ2bD1c3YPqzhG6kZ0VtfyvafjeNNZBN zusngCDNMiqElSPiApx99sGrzMJlM4H5ythhDg88G2deEB92bEHKP4DyWgcyhAYVnvdy jsh5eEOh2KTomBOkZ3esBxClr3yEla60OgDmydSsg2rRA2hCluRz+64/A0Fy/m1xNf+I LLGEwdo6JQ4UlZQpfLAEP8fSOEOXUBhLazjOXNzY6HCsCP9qWrIb1qMKN6ApXolZjPve cDog== X-Gm-Message-State: AO0yUKWoEge/6tBGfBLfqW1XO8hwmwo4Xf+n2HugeS5K3W5hcPd+Rfzn hgkuHEm0lMHnUFPHZgND9SNLmCd9/FQY/IU8 X-Received: by 2002:a17:902:e394:b0:198:e13e:e73e with SMTP id g20-20020a170902e39400b00198e13ee73emr4499330ple.53.1675528401670; Sat, 04 Feb 2023 08:33:21 -0800 (PST) Received: from stoup.. (rrcs-173-197-98-118.west.biz.rr.com. [173.197.98.118]) by smtp.gmail.com with ESMTPSA id w19-20020a1709029a9300b00186b69157ecsm3660859plp.202.2023.02.04.08.33.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Feb 2023 08:33:21 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PULL 05/40] tcg: Allocate objects contiguously in temp_allocate_frame Date: Sat, 4 Feb 2023 06:32:35 -1000 Message-Id: <20230204163310.815536-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230204163310.815536-1-richard.henderson@linaro.org> References: <20230204163310.815536-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1029; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1029.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When allocating a temp to the stack frame, consider the base type and allocate all parts at once. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- tcg/tcg.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index bc7198e5d0..cdfc50b164 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -3267,11 +3267,12 @@ static bool liveness_pass_2(TCGContext *s) static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) { - int size = tcg_type_size(ts->type); - int align; intptr_t off; + int size, align; - switch (ts->type) { + /* When allocating an object, look at the full type. */ + size = tcg_type_size(ts->base_type); + switch (ts->base_type) { case TCG_TYPE_I32: align = 4; break; @@ -3302,13 +3303,30 @@ static void temp_allocate_frame(TCGContext *s, TCGTemp *ts) tcg_raise_tb_overflow(s); } s->current_frame_offset = off + size; - - ts->mem_offset = off; #if defined(__sparc__) - ts->mem_offset += TCG_TARGET_STACK_BIAS; + off += TCG_TARGET_STACK_BIAS; #endif - ts->mem_base = s->frame_temp; - ts->mem_allocated = 1; + + /* If the object was subdivided, assign memory to all the parts. */ + if (ts->base_type != ts->type) { + int part_size = tcg_type_size(ts->type); + int part_count = size / part_size; + + /* + * Each part is allocated sequentially in tcg_temp_new_internal. + * Jump back to the first part by subtracting the current index. + */ + ts -= ts->temp_subindex; + for (int i = 0; i < part_count; ++i) { + ts[i].mem_offset = off + i * part_size; + ts[i].mem_base = s->frame_temp; + ts[i].mem_allocated = 1; + } + } else { + ts->mem_offset = off; + ts->mem_base = s->frame_temp; + ts->mem_allocated = 1; + } } /* Assign @reg to @ts, and update reg_to_temp[]. */