From patchwork Wed Apr 20 18:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 563974 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp4402874map; Wed, 20 Apr 2022 11:13:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx18m4JzPC3WDqmG1HDbdZJv8OBiZdjWKD8+xFUOqf5mNc+L9bpdxnbj4A0GVrEpo0giHvY X-Received: by 2002:a81:2d82:0:b0:2f4:d2b6:1864 with SMTP id t124-20020a812d82000000b002f4d2b61864mr511064ywt.342.1650478401853; Wed, 20 Apr 2022 11:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650478401; cv=none; d=google.com; s=arc-20160816; b=kyT//8ebx/jrc0En/cElO1CP5Zqme1FmIBBY16sb2m1q46WQyG535sr3+pqU5b8YKU iPCy1k7mFSYvfPk079pjC2e1YBiC/OQWDPiiDk7Nm9EJbC9WJLxgxpKQGEQkPmjdGNAQ Xsw2RfW16I6OuRRKPihmXtlwJXj1E1lPWVOqYT+X6vjyYKtXdhp+c5SQOist1Wznne95 YEJFNA/h3qtPeLK7d22kFC7LNdXRbezSgIUI6E1W6wnBJIVv77Cqv56stbum4zsnGNBI TNuoo6TRDfZ2hfPLfFGjATPE9EN3y1SuXNMcE3lFDhX3dcdh2YCZMMcSsYGJ+Z3CYzD5 sE3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=PEwpJcfavRkH3ZeiI3Zgbs8jUfxSKvoW5MoAmvkSjTE=; b=Lv6/7hVMVTfFERDlf4xIuf8BPV0DEcPupEYc5U/4DcV7ow1biXiiXGHh0AhMjvP6kQ p5YSkZEjNS2Wyi+MJRcqYnL6IOxHEd6yM8ryAR+o5vwr5cPkF+vU5IfA6dRz41MGj+KX G5wM/x7nMo+YUW5MC1xzUFQl+TtC0hPARiTY4BPjed+eIMCp2p5aLngE1egfS8pgYQya XXD8DpFMSptrw5D1ChVjlASpLuiUfHSIZzN2lgzM9qNg3sZaTzaJmaTf9r0i+PpQGcvf kB9it7MRW4lM9bRMX3tz7n8/K2HJGRiv2axUHM/jcBa1ag2IFY5VFjVDLYR2VbeHhpuT 3dsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R3sSbd4z; 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 i28-20020a25b21c000000b0063fae8d0024si577842ybj.446.2022.04.20.11.13.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Apr 2022 11:13:21 -0700 (PDT) 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=R3sSbd4z; 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]:42808 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nhEpN-0001bx-9h for patch@linaro.org; Wed, 20 Apr 2022 14:13:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nhEip-0005P1-2z for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:35 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:44976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nhEim-0001CM-U6 for qemu-devel@nongnu.org; Wed, 20 Apr 2022 14:06:34 -0400 Received: by mail-pl1-x62a.google.com with SMTP id j8so2495732pll.11 for ; Wed, 20 Apr 2022 11:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PEwpJcfavRkH3ZeiI3Zgbs8jUfxSKvoW5MoAmvkSjTE=; b=R3sSbd4z0KYX6ESpdC8j5RHWWFMUDk6D+kQX39ejRhG12ashoHkvPSIihKEu87w9hb jW+Ngkjzx1c+dAW+B7RD9bF0Q8dQ32+xiWD78MghFhYhwJpcvcKJl0SrGNF1EmnXJbug Lv7EOBuyRp7/uY5KXI2Vm15qYsB3AiKSNcDaPL+y+VUgCgJOtwNEYSixhFtnkgHoOow3 T6GV8mJa7U+NIuxYTThplsIRfQSrwaa2nP+lru2QcyrMy/kt8O2Zf5Y2vnwhILDkdjtK zBg/cfyn2U7QhF9jTtOkgdhB1k9x5/VdmnU1GMsFabh5ZLUwt76Dc0dYXdfcp2yGnZxD kntg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PEwpJcfavRkH3ZeiI3Zgbs8jUfxSKvoW5MoAmvkSjTE=; b=SZzfwOJV2appedQ446IXfLT1DOwQkFYp/ttbyBFj8xSDYudcKvvaarEPwtP+eUARIa UVAosRXnUt/aD8DFfwGY7TgydzCtBVsE++UGSd5/nxQbCiMKKAzEPmGNjOnwveC9mVsE jZdKr2CRsUoyAV7NRNE6mPuJU8j3ipnZ2PKlvrpjL5m35Z1YMNkVpMBIjmT+x9fKVsTn GuP/HOBFKSnA4e8p1ZUjWx5ghCwHQuSGkDBVqeMoG1OKTQpH9GsmXJS4BN+6td3WmK0Y 8ftcI5afWDz4XhUIIaleMnSzjXvxrBR+LhU/5QVs/LW6fxNdWwsvGNFLwDSQh69uXFDx pqRw== X-Gm-Message-State: AOAM532ioJdTjARVGf3ZhdAtUHqRBKCnQ4xhx+t+mz6PiPc6UF3HJXT4 c9VhBb62RwDd3faNa0DUJ0oMkMyJnnUIqQ== X-Received: by 2002:a17:902:b10c:b0:154:a3b5:b33a with SMTP id q12-20020a170902b10c00b00154a3b5b33amr21172573plr.3.1650477991553; Wed, 20 Apr 2022 11:06:31 -0700 (PDT) Received: from stoup.. (174-21-142-130.tukw.qwest.net. [174.21.142.130]) by smtp.gmail.com with ESMTPSA id i2-20020a17090a058200b001d2fc489b8asm56681pji.25.2022.04.20.11.06.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 11:06:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 11/39] tcg: Pass the locked filepointer to tcg_dump_ops Date: Wed, 20 Apr 2022 11:05:50 -0700 Message-Id: <20220420180618.1183855-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420180618.1183855-1-richard.henderson@linaro.org> References: <20220420180618.1183855-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62a.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, T_SCC_BODY_TEXT_LINE=-0.01 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: , Cc: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We have already looked up and locked the filepointer. Use fprintf instead of qemu_log directly for output in and around tcg_dump_ops. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson Message-Id: <20220417183019.755276-12-richard.henderson@linaro.org> --- tcg/tcg.c | 109 ++++++++++++++++++++++++++---------------------------- 1 file changed, 52 insertions(+), 57 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index d0e47e55dc..79a5e2816f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -1808,7 +1808,11 @@ static inline TCGReg tcg_regset_first(TCGRegSet d) } } -static void tcg_dump_ops(TCGContext *s, bool have_prefs) +/* Return only the number of characters output -- no error return. */ +#define ne_fprintf(...) \ + ({ int ret_ = fprintf(__VA_ARGS__); ret_ >= 0 ? ret_ : 0; }) + +static void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs) { char buf[128]; TCGOp *op; @@ -1824,7 +1828,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) if (c == INDEX_op_insn_start) { nb_oargs = 0; - col += qemu_log("\n ----"); + col += ne_fprintf(f, "\n ----"); for (i = 0; i < TARGET_INSN_START_WORDS; ++i) { target_ulong a; @@ -1833,7 +1837,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) #else a = op->args[i]; #endif - col += qemu_log(" " TARGET_FMT_lx, a); + col += ne_fprintf(f, " " TARGET_FMT_lx, a); } } else if (c == INDEX_op_call) { const TCGHelperInfo *info = tcg_call_info(op); @@ -1844,7 +1848,7 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) nb_iargs = TCGOP_CALLI(op); nb_cargs = def->nb_cargs; - col += qemu_log(" %s ", def->name); + col += ne_fprintf(f, " %s ", def->name); /* * Print the function name from TCGHelperInfo, if available. @@ -1852,15 +1856,15 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) * but the actual function pointer comes from the plugin. */ if (func == info->func) { - col += qemu_log("%s", info->name); + col += ne_fprintf(f, "%s", info->name); } else { - col += qemu_log("plugin(%p)", func); + col += ne_fprintf(f, "plugin(%p)", func); } - col += qemu_log(",$0x%x,$%d", info->flags, nb_oargs); + col += ne_fprintf(f, ",$0x%x,$%d", info->flags, nb_oargs); for (i = 0; i < nb_oargs; i++) { - col += qemu_log(",%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[i])); + col += ne_fprintf(f, ",%s", tcg_get_arg_str(s, buf, sizeof(buf), + op->args[i])); } for (i = 0; i < nb_iargs; i++) { TCGArg arg = op->args[nb_oargs + i]; @@ -1868,34 +1872,32 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) if (arg != TCG_CALL_DUMMY_ARG) { t = tcg_get_arg_str(s, buf, sizeof(buf), arg); } - col += qemu_log(",%s", t); + col += ne_fprintf(f, ",%s", t); } } else { - col += qemu_log(" %s ", def->name); + col += ne_fprintf(f, " %s ", def->name); nb_oargs = def->nb_oargs; nb_iargs = def->nb_iargs; nb_cargs = def->nb_cargs; if (def->flags & TCG_OPF_VECTOR) { - col += qemu_log("v%d,e%d,", 64 << TCGOP_VECL(op), - 8 << TCGOP_VECE(op)); + col += ne_fprintf(f, "v%d,e%d,", 64 << TCGOP_VECL(op), + 8 << TCGOP_VECE(op)); } k = 0; for (i = 0; i < nb_oargs; i++) { - if (k != 0) { - col += qemu_log(","); - } - col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[k++])); + const char *sep = k ? "," : ""; + col += ne_fprintf(f, "%s%s", sep, + tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } for (i = 0; i < nb_iargs; i++) { - if (k != 0) { - col += qemu_log(","); - } - col += qemu_log("%s", tcg_get_arg_str(s, buf, sizeof(buf), - op->args[k++])); + const char *sep = k ? "," : ""; + col += ne_fprintf(f, "%s%s", sep, + tcg_get_arg_str(s, buf, sizeof(buf), + op->args[k++])); } switch (c) { case INDEX_op_brcond_i32: @@ -1910,9 +1912,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) case INDEX_op_cmpsel_vec: if (op->args[k] < ARRAY_SIZE(cond_name) && cond_name[op->args[k]]) { - col += qemu_log(",%s", cond_name[op->args[k++]]); + col += ne_fprintf(f, ",%s", cond_name[op->args[k++]]); } else { - col += qemu_log(",$0x%" TCG_PRIlx, op->args[k++]); + col += ne_fprintf(f, ",$0x%" TCG_PRIlx, op->args[k++]); } i = 1; break; @@ -1927,12 +1929,12 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) unsigned ix = get_mmuidx(oi); if (op & ~(MO_AMASK | MO_BSWAP | MO_SSIZE)) { - col += qemu_log(",$0x%x,%u", op, ix); + col += ne_fprintf(f, ",$0x%x,%u", op, ix); } else { const char *s_al, *s_op; s_al = alignment_name[(op & MO_AMASK) >> MO_ASHIFT]; s_op = ldst_name[op & (MO_BSWAP | MO_SSIZE)]; - col += qemu_log(",%s%s,%u", s_al, s_op, ix); + col += ne_fprintf(f, ",%s%s,%u", s_al, s_op, ix); } i = 1; } @@ -1950,9 +1952,9 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) name = bswap_flag_name[flags]; } if (name) { - col += qemu_log(",%s", name); + col += ne_fprintf(f, ",%s", name); } else { - col += qemu_log(",$0x%" TCG_PRIlx, flags); + col += ne_fprintf(f, ",$0x%" TCG_PRIlx, flags); } i = k = 1; } @@ -1967,49 +1969,42 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: case INDEX_op_brcond2_i32: - col += qemu_log("%s$L%d", k ? "," : "", - arg_label(op->args[k])->id); + col += ne_fprintf(f, "%s$L%d", k ? "," : "", + arg_label(op->args[k])->id); i++, k++; break; default: break; } for (; i < nb_cargs; i++, k++) { - col += qemu_log("%s$0x%" TCG_PRIlx, k ? "," : "", op->args[k]); + col += ne_fprintf(f, "%s$0x%" TCG_PRIlx, k ? "," : "", + op->args[k]); } } if (have_prefs || op->life) { - - QemuLogFile *logfile; - - rcu_read_lock(); - logfile = qatomic_rcu_read(&qemu_logfile); - if (logfile) { - for (; col < 40; ++col) { - putc(' ', logfile->fd); - } + for (; col < 40; ++col) { + putc(' ', f); } - rcu_read_unlock(); } if (op->life) { unsigned life = op->life; if (life & (SYNC_ARG * 3)) { - qemu_log(" sync:"); + ne_fprintf(f, " sync:"); for (i = 0; i < 2; ++i) { if (life & (SYNC_ARG << i)) { - qemu_log(" %d", i); + ne_fprintf(f, " %d", i); } } } life /= DEAD_ARG; if (life) { - qemu_log(" dead:"); + ne_fprintf(f, " dead:"); for (i = 0; life; ++i, life >>= 1) { if (life & 1) { - qemu_log(" %d", i); + ne_fprintf(f, " %d", i); } } } @@ -2020,28 +2015,28 @@ static void tcg_dump_ops(TCGContext *s, bool have_prefs) TCGRegSet set = op->output_pref[i]; if (i == 0) { - qemu_log(" pref="); + ne_fprintf(f, " pref="); } else { - qemu_log(","); + ne_fprintf(f, ","); } if (set == 0) { - qemu_log("none"); + ne_fprintf(f, "none"); } else if (set == MAKE_64BIT_MASK(0, TCG_TARGET_NB_REGS)) { - qemu_log("all"); + ne_fprintf(f, "all"); #ifdef CONFIG_DEBUG_TCG } else if (tcg_regset_single(set)) { TCGReg reg = tcg_regset_first(set); - qemu_log("%s", tcg_target_reg_names[reg]); + ne_fprintf(f, "%s", tcg_target_reg_names[reg]); #endif } else if (TCG_TARGET_NB_REGS <= 32) { - qemu_log("%#x", (uint32_t)set); + ne_fprintf(f, "0x%x", (uint32_t)set); } else { - qemu_log("%#" PRIx64, (uint64_t)set); + ne_fprintf(f, "0x%" PRIx64, (uint64_t)set); } } } - qemu_log("\n"); + putc('\n', f); } } @@ -4207,7 +4202,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "OP:\n"); - tcg_dump_ops(s, false); + tcg_dump_ops(s, logfile, false); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } @@ -4254,7 +4249,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "OP before indirect lowering:\n"); - tcg_dump_ops(s, false); + tcg_dump_ops(s, logfile, false); fprintf(logfile, "\n"); qemu_log_unlock(logfile); } @@ -4277,7 +4272,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) FILE *logfile = qemu_log_trylock(); if (logfile) { fprintf(logfile, "OP after optimization and liveness analysis:\n"); - tcg_dump_ops(s, true); + tcg_dump_ops(s, logfile, true); fprintf(logfile, "\n"); qemu_log_unlock(logfile); }