From nobody Tue Nov 18 11:51:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.53 as permitted sender) client-ip=209.85.218.53; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f53.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1610377304; cv=none; d=zohomail.com; s=zohoarc; b=EPZ2KWNedg4Nh0283p9kIg6ev8s2vH3MSAY7dpz5jXyjtLWnOh3d2G43bG7XZbnH6P4J4dTSmXksFDKRqajKszeVNpDzrdRsdu+Nj8Wbb2B5NnIH01swVzHVIq6EGUePGejoJ/H/PpJLkGTkviSAwTzufXF6r1SGXrj2YFqZbaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610377304; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+Yz+q+sYA548DZkc3uhP8nuaBAcly6SiME04TkIbzu0=; b=nhAhY2Mmpm+wCoGR+0odory6pXraFT2oPLSHB9BRiV/Pt7tAVQGlryq78nUPO5J+U7ALmPzzphrlRkU1ygv3EI8r+S9Ri3g7bUxkdHvFrhTeVs9j2G8LUICUsgUTfroA3MMxF85MC8c8dDKv9PrvazP3wsUQ6WQr9BWh7K+NPOc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.53 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by mx.zohomail.com with SMTPS id 1610377304332889.8682491849534; Mon, 11 Jan 2021 07:01:44 -0800 (PST) Received: by mail-ej1-f53.google.com with SMTP id g20so82390ejb.1 for ; Mon, 11 Jan 2021 07:01:43 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (129.red-88-21-205.staticip.rima-tde.net. [88.21.205.129]) by smtp.gmail.com with ESMTPSA id cc8sm68591edb.17.2021.01.11.07.01.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 07:01:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+Yz+q+sYA548DZkc3uhP8nuaBAcly6SiME04TkIbzu0=; b=PejHZBubdAGZ3MyD7BeZLf8GSdxbtdEHpKiQ9OZWiN+wMSNTTFCH0Dg/97ZjM4TXW0 2OVKBZTjbqVrY9QarWetjQKiVb9iA7gwDkFWgpO3N12SQhqqg3dLkQkHgjNcRg0UHbbs Ftgx5PJDU7PNcUMbb2y8OB/TZpT5oUx5XLyVm/Y4VATRlwJs2K2nv+YkikIH+MYn42eh 56qJvEX10gjPgw3fglxqCm08eBnuSw9SVthdVU7HYjJTw3uyP5Q/2NZCY3Y/1CsKJSqL 5jhLPqxFCvEA3k615otkxN40fRBJ4vwFQNB3JVhcv4LvJJ3Boe4I12zT8NQjDtAaw9b1 wsww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=+Yz+q+sYA548DZkc3uhP8nuaBAcly6SiME04TkIbzu0=; b=Wlp5+gmkmooVFwfz0Rg4GIMjWSki1lmd0X1+VouEHkiNxiBnT1ZvxNhaxLEyc9Ybta SI1lSPPAnkpLLnPCC7DnF64/qFGnqmLBB4FJBMyzCcIt6evZuWXXK3b+xyXxRhnD02jU F5Ckrqm9eMM1LwJpsBkQegnxgFqnXVg4YXBumBo7DWIWVacvvVeat563FPJvIy7C8VQk ceYvfg9/ef5KG4aTdaSc4ic8m7ZXuvBcSyRE+EH7ZR70uJEK51plOUTvXjHE8Ya6ts2n Fs1QYHSklBB60FQ1IAA3tResoiNLfeH/YMIEBDEOOzUUCODmtJAZ2EuAY0ziZRXfclH0 UxMw== X-Gm-Message-State: AOAM530o7KwxMpR+b8Ba8w46vShOAKzWTHyxKnEEyx5nCMQWdgKGBJT9 hd6x3a/j/0KaHnxc98ueXRQ= X-Google-Smtp-Source: ABdhPJyGU5wbk10Z1JnKHb2TkfqvKDTRbwtSey20RaMhAP4tkhOEORcuywDvafrzzvmQZsoeJt1DcQ== X-Received: by 2002:a17:906:d0c1:: with SMTP id bq1mr10818129ejb.202.1610377302012; Mon, 11 Jan 2021 07:01:42 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Huacai Chen , Aurelien Jarno , Aleksandar Rikalo , Thomas Huth , Stefan Weil , qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Jiaxun Yang , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cornelia Huck , Richard Henderson , Andrzej Zaborowski , Alistair Francis , Palmer Dabbelt , Miroslav Rezanina Subject: [RFC PATCH 4/5] tcg: Restrict tcg_out_op() to arrays of TCG_MAX_OP_ARGS elements Date: Mon, 11 Jan 2021 16:01:13 +0100 Message-Id: <20210111150114.1415930-5-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210111150114.1415930-1-f4bug@amsat.org> References: <20210111150114.1415930-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) tcg_reg_alloc_op() allocates arrays of TCG_MAX_OP_ARGS elements. The Aarch64 target already does this since commit 8d8db193f25 ("tcg-aarch64: Hoist common argument loads in tcg_out_op"), SPARC since commit b357f902bff ("tcg-sparc: Hoist common argument loads in tcg_out_op"). RISCV missed it upon introduction in commit bdf503819ee ("tcg/riscv: Add the out op decoder"), MIPS since commit 22ee3a987d5 ("tcg-mips: Hoist args loads") and i386 since commit 42d5b514928 ("tcg/i386: Hoist common arguments in tcg_out_op"). Provide this information as a hint to the compiler in the function prototype, and update the funtion definitions. This fixes this warning (using GCC 11): tcg/aarch64/tcg-target.c.inc:1855:37: error: argument 3 of type 'const = TCGArg[16]' {aka 'const long unsigned int[16]'} with mismatched bound [-Wer= ror=3Darray-parameter=3D] tcg/aarch64/tcg-target.c.inc:1856:34: error: argument 4 of type 'const = int[16]' with mismatched bound [-Werror=3Darray-parameter=3D] Reported-by: Miroslav Rezanina Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Miroslav Rezanina =20 --- RFC because such compiler hint is somehow "new" to me. Also I expect this to be superseeded by Richard 'tcg constant' branch mentioned here: https://www.mail-archive.com/qemu-devel@nongnu.org/msg771401.html --- tcg/tcg.c | 5 +++-- tcg/i386/tcg-target.c.inc | 3 ++- tcg/mips/tcg-target.c.inc | 3 ++- tcg/riscv/tcg-target.c.inc | 3 ++- tcg/tci/tcg-target.c.inc | 5 +++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index 472bf1755bf..97d074d8fab 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -110,8 +110,9 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCG= Reg ret, TCGReg arg1, static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg ar= g); static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg ret, tcg_target_long arg); -static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, - const int *const_args); +static void tcg_out_op(TCGContext *s, TCGOpcode opc, + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]); #if TCG_TARGET_MAYBE_vec static bool tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, TCGReg dst, TCGReg src); diff --git a/tcg/i386/tcg-target.c.inc b/tcg/i386/tcg-target.c.inc index 46e856f4421..d121dca8789 100644 --- a/tcg/i386/tcg-target.c.inc +++ b/tcg/i386/tcg-target.c.inc @@ -2215,7 +2215,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is64) } =20 static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, - const TCGArg *args, const int *const_args) + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]) { TCGArg a0, a1, a2; int c, const_a2, vexop, rexw =3D 0; diff --git a/tcg/mips/tcg-target.c.inc b/tcg/mips/tcg-target.c.inc index add157f6c32..b9bb54f0ecc 100644 --- a/tcg/mips/tcg-target.c.inc +++ b/tcg/mips/tcg-target.c.inc @@ -1691,7 +1691,8 @@ static void tcg_out_clz(TCGContext *s, MIPSInsn opcv2= , MIPSInsn opcv6, } =20 static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, - const TCGArg *args, const int *const_args) + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]) { MIPSInsn i1, i2; TCGArg a0, a1, a2; diff --git a/tcg/riscv/tcg-target.c.inc b/tcg/riscv/tcg-target.c.inc index c60b91ba58f..5bf0d069532 100644 --- a/tcg/riscv/tcg-target.c.inc +++ b/tcg/riscv/tcg-target.c.inc @@ -1238,7 +1238,8 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGA= rg *args, bool is_64) static const tcg_insn_unit *tb_ret_addr; =20 static void tcg_out_op(TCGContext *s, TCGOpcode opc, - const TCGArg *args, const int *const_args) + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]) { TCGArg a0 =3D args[0]; TCGArg a1 =3D args[1]; diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc index d5a4d9d37cf..60464524f3d 100644 --- a/tcg/tci/tcg-target.c.inc +++ b/tcg/tci/tcg-target.c.inc @@ -553,8 +553,9 @@ static inline void tcg_out_call(TCGContext *s, const tc= g_insn_unit *arg) old_code_ptr[1] =3D s->code_ptr - old_code_ptr; } =20 -static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, - const int *const_args) +static void tcg_out_op(TCGContext *s, TCGOpcode opc, + const TCGArg args[TCG_MAX_OP_ARGS], + const int const_args[TCG_MAX_OP_ARGS]) { uint8_t *old_code_ptr =3D s->code_ptr; =20 --=20 2.26.2