From nobody Wed May 14 02:54:42 2025 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677475756; cv=none; d=zohomail.com; s=zohoarc; b=N0A9pUjor1M5ulcFpY/c9BfGDhGBJ9ZZMzp424Ax1FNAwHqgFBfQxJG7GAsej+wBWcARSs46AJPZx8GxjAcQW/gD/NZ1USdYnmHD3W70uoeXjFgIE/9bDyLgnHHRnDWRan6Uuan6opCorX0QuckoqIYJVRZz9iNuDWdA/aB6kfc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677475756; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D7Dr5dVd5BMP8VbVASryumiENZXah1Y2zUeyDZafQVk=; b=TimD/XnH3qXM403y/wRISS4xVjST+6rs0Flp4eRUXy6gXYe66Varexm9RSH6sM1gbGB03TnJpTrZYZKXzlBLO7j33Ol1msf6PPzAZ8wyWIXOpqiDGYNxFpeufw8n2fBd85m4GIhgD9O//g9PYPVOpqAnAQE/pN7jdzAxP79RhVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677475756424680.4898065357611; Sun, 26 Feb 2023 21:29:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWW1A-0006ob-GA; Mon, 27 Feb 2023 00:25:44 -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 1pWW0l-0006dH-Q0 for qemu-devel@nongnu.org; Mon, 27 Feb 2023 00:25:20 -0500 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWW0h-00079a-6q for qemu-devel@nongnu.org; Mon, 27 Feb 2023 00:25:18 -0500 Received: by mail-pj1-x1031.google.com with SMTP id gi3-20020a17090b110300b0023762f642dcso5005610pjb.4 for ; Sun, 26 Feb 2023 21:25:14 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id a14-20020a170902ecce00b0019a837be977sm3513341plh.271.2023.02.26.21.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Feb 2023 21:25:12 -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=D7Dr5dVd5BMP8VbVASryumiENZXah1Y2zUeyDZafQVk=; b=AIwUmVtqm3EQWqE0nuArRl98xM3APLghad3m8L3hE5rrtJYNzonJWtFFfNEnAuTvII SiyuAV6LWAhVizYX3oMLoYAbskNCs89x5af4UVaHqUwak0O82e4trCLH3DjPiEN5PvRX AK0uk9b6l8dqnTruUVm+ZXYCDxNxq+xpSMzghVDCndGXp/lTV6KQe+aVkNHrMBl1eOS9 3T578Xi0b1XjaM2gRLrCUkv7B3cvQ1ooC7XhazzyLKzVh1u+0PGq5XafZ/uiiFOaDOe2 kGy7jDAhVloSh6Wi9pwjbpU6D/XDAb/dHzlU1A7kz+b178ZeMAxSq22Aox9oaYbKa41w GFPw== 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=D7Dr5dVd5BMP8VbVASryumiENZXah1Y2zUeyDZafQVk=; b=D+7Ns/XwTWlWh+QEePAIA+MOkO8gKBLle9Dy1277Rwo9QmN1ihjDP8Yb4kWQriZmVa ujdvAnUCmSfYZEbHP2NfWklsmbozuXLXMmtDgH5IeCOlK/wRdGeFSiBxyKtnEuY0QGhE h7XZentyuXaKyGhj0PqIVE/am5Ahgis2y8icbbLgYS3UXZhawAuqXTPbxZ9oZzVheZPf tjKVeqgvVOsb2wZ8F9YeGaKxN1CBotxHYckqSvQ4fg7wmXmgQGYCCwdYXwrjJ4JHVThw ND849hXwftL32Fhd+2i51svmYuDCN3FQ6Feg1CbRKYJbGYv28jfL8h1Xn1D0Cxypn4sr gH4w== X-Gm-Message-State: AO0yUKVavaNn2tzpy2lkcDulCQ8YCoUbXe0koR0VcU+dWwfCZ+qj8GqU 1x7lOXJN0RY/MF2vA7dzcNwIaS5KpVkXOjZ0clo= X-Google-Smtp-Source: AK7set/fMeI0SqXaIxDJlJv6jADDS28zH5sRrUoa33mqbv05qgxGhKi3UDGWt4jd1g+vRaHyRPswAQ== X-Received: by 2002:a17:902:f693:b0:19d:1e33:a60d with SMTP id l19-20020a170902f69300b0019d1e33a60dmr1212656plg.25.1677475512964; Sun, 26 Feb 2023 21:25:12 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, jcmvbkbc@gmail.com, kbastian@mail.uni-paderborn.de, ysato@users.sourceforge.jp, gaosong@loongson.cn, jiaxun.yang@flygoat.com, tsimpson@quicinc.com, ale@rev.ng, mrolnik@gmail.com, edgar.iglesias@gmail.com Subject: [PATCH v2 01/76] tcg: Remove tcg_check_temp_count, tcg_clear_temp_count Date: Sun, 26 Feb 2023 19:23:50 -1000 Message-Id: <20230227052505.352889-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230227052505.352889-1-richard.henderson@linaro.org> References: <20230227052505.352889-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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=unavailable 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677475758666100003 Content-Type: text/plain; charset="utf-8" Since all temps allocated by guest front-ends are now TEMP_TB, and we don't recycle TEMP_TB, there's no point in requiring that the front-ends free the temps at all. Begin by dropping the inner-most checks that all temps have been freed. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- include/tcg/tcg.h | 14 ----------- accel/tcg/translator.c | 12 ---------- tcg/tcg.c | 54 +++++++----------------------------------- 3 files changed, 8 insertions(+), 72 deletions(-) diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 7e2b954dbc..e8f73115ec 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -567,7 +567,6 @@ struct TCGContext { #endif =20 #ifdef CONFIG_DEBUG_TCG - int temps_in_use; int goto_tb_issue_mask; const TCGOpcode *vecop_list; #endif @@ -958,19 +957,6 @@ static inline TCGv_ptr tcg_temp_new_ptr(void) return temp_tcgv_ptr(t); } =20 -#if defined(CONFIG_DEBUG_TCG) -/* If you call tcg_clear_temp_count() at the start of a section of - * code which is not supposed to leak any TCG temporaries, then - * calling tcg_check_temp_count() at the end of the section will - * return 1 if the section did in fact leak a temporary. - */ -void tcg_clear_temp_count(void); -int tcg_check_temp_count(void); -#else -#define tcg_clear_temp_count() do { } while (0) -#define tcg_check_temp_count() 0 -#endif - int64_t tcg_cpu_exec_time(void); void tcg_dump_info(GString *buf); void tcg_dump_op_count(GString *buf); diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 62e8f28025..88567a88d1 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -18,17 +18,8 @@ #include "exec/plugin-gen.h" #include "sysemu/replay.h" =20 -/* Pairs with tcg_clear_temp_count. - To be called by #TranslatorOps.{translate_insn,tb_stop} if - (1) the target is sufficiently clean to support reporting, - (2) as and when all temporaries are known to be consumed. - For most targets, (2) is at the end of translate_insn. */ void translator_loop_temp_check(DisasContextBase *db) { - if (tcg_check_temp_count()) { - qemu_log("warning: TCG temporary leaks before " - TARGET_FMT_lx "\n", db->pc_next); - } } =20 bool translator_use_goto_tb(DisasContextBase *db, target_ulong dest) @@ -67,9 +58,6 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb,= int *max_insns, ops->init_disas_context(db, cpu); tcg_debug_assert(db->is_jmp =3D=3D DISAS_NEXT); /* no early exit */ =20 - /* Reset the temp count so that we can identify leaks */ - tcg_clear_temp_count(); - /* Start translating. */ gen_tb_start(db->tb); ops->tb_start(db, cpu); diff --git a/tcg/tcg.c b/tcg/tcg.c index b65f2ffdbe..e3c0fa1012 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1272,7 +1272,7 @@ TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempK= ind kind) ts->temp_allocated =3D 1; tcg_debug_assert(ts->base_type =3D=3D type); tcg_debug_assert(ts->kind =3D=3D kind); - goto done; + return ts; } } else { tcg_debug_assert(kind =3D=3D TEMP_TB); @@ -1316,11 +1316,6 @@ TCGTemp *tcg_temp_new_internal(TCGType type, TCGTemp= Kind kind) ts2->kind =3D kind; } } - - done: -#if defined(CONFIG_DEBUG_TCG) - s->temps_in_use++; -#endif return ts; } =20 @@ -1365,30 +1360,18 @@ void tcg_temp_free_internal(TCGTemp *ts) =20 switch (ts->kind) { case TEMP_CONST: - /* - * In order to simplify users of tcg_constant_*, - * silently ignore free. - */ - return; - case TEMP_EBB: case TEMP_TB: + /* Silently ignore free. */ + break; + case TEMP_EBB: + tcg_debug_assert(ts->temp_allocated !=3D 0); + ts->temp_allocated =3D 0; + set_bit(temp_idx(ts), s->free_temps[ts->base_type].l); break; default: + /* It never made sense to free TEMP_FIXED or TEMP_GLOBAL. */ g_assert_not_reached(); } - - tcg_debug_assert(ts->temp_allocated !=3D 0); - ts->temp_allocated =3D 0; - -#if defined(CONFIG_DEBUG_TCG) - assert(s->temps_in_use > 0); - s->temps_in_use--; -#endif - - if (ts->kind =3D=3D TEMP_EBB) { - int idx =3D temp_idx(ts); - set_bit(idx, s->free_temps[ts->base_type].l); - } } =20 TCGTemp *tcg_constant_internal(TCGType type, int64_t val) @@ -1476,27 +1459,6 @@ TCGv_i64 tcg_const_i64(int64_t val) return t0; } =20 -#if defined(CONFIG_DEBUG_TCG) -void tcg_clear_temp_count(void) -{ - TCGContext *s =3D tcg_ctx; - s->temps_in_use =3D 0; -} - -int tcg_check_temp_count(void) -{ - TCGContext *s =3D tcg_ctx; - if (s->temps_in_use) { - /* Clear the count so that we don't give another - * warning immediately next time around. - */ - s->temps_in_use =3D 0; - return 1; - } - return 0; -} -#endif - /* Return true if OP may appear in the opcode stream. Test the runtime variable that controls each opcode. */ bool tcg_op_supported(TCGOpcode op) --=20 2.34.1