[PATCH v4 06/35] target/hexagon: Suppress unused-variable warnings for sysemu source regs

Brian Cain posted 35 patches 1 month ago
Maintainers: Brian Cain <brian.cain@oss.qualcomm.com>, Pierrick Bouvier <pierrick.bouvier@linaro.org>, Laurent Vivier <laurent@vivier.eu>, Alessandro Di Federico <ale@rev.ng>, Anton Johansson <anjo@rev.ng>
There is a newer version of this series
[PATCH v4 06/35] target/hexagon: Suppress unused-variable warnings for sysemu source regs
Posted by Brian Cain 1 month ago
The analyze_read() methods on GuestSource, GuestPairSource,
SystemSource, and SystemPairSource were no-ops because these
source registers do not need read-tracking in the analyze phase.
However, gen_analyze_funcs.py unconditionally declares the
register-number variable (e.g. GsN) via decl_reg_num() for all
registers that are read or written.  When building with
hexagon-softmmu, the generated analyze function bodies are
compiled (outside the #ifndef CONFIG_USER_ONLY guard), and the
declared-but-unreferenced register-number variable triggers
-Werror=unused-variable under both gcc and clang.

Emit a (void) cast on the register number from analyze_read() to
suppress the warning.

Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
---
 target/hexagon/hex_common.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py
index 1e2c2e46506..85745ef48c2 100755
--- a/target/hexagon/hex_common.py
+++ b/target/hexagon/hex_common.py
@@ -1075,7 +1075,9 @@ def decl_tcg(self, f, tag, regno):
             gen_read_greg({self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
-        pass
+        f.write(code_fmt(f"""\
+            (void){self.reg_num};
+        """))
 
 class GuestPairDest(GuestRegister, Pair, Dest):
     def decl_tcg(self, f, tag, regno):
@@ -1100,7 +1102,9 @@ def decl_tcg(self, f, tag, regno):
             gen_read_greg_pair({self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
-        pass
+        f.write(code_fmt(f"""\
+            (void){self.reg_num};
+        """))
 
 class SystemDest(Register, Single, Dest):
     def decl_tcg(self, f, tag, regno):
@@ -1125,7 +1129,9 @@ def decl_tcg(self, f, tag, regno):
             gen_read_sreg({self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
-        pass
+        f.write(code_fmt(f"""\
+            (void){self.reg_num};
+        """))
 
 class SystemPairDest(Register, Pair, Dest):
     def decl_tcg(self, f, tag, regno):
@@ -1150,7 +1156,9 @@ def decl_tcg(self, f, tag, regno):
             gen_read_sreg_pair({self.reg_tcg()}, {self.reg_num});
         """))
     def analyze_read(self, f, regno):
-        pass
+        f.write(code_fmt(f"""\
+            (void){self.reg_num};
+        """))
 
 def init_registers():
     regs = {
-- 
2.34.1
Re: [PATCH v4 06/35] target/hexagon: Suppress unused-variable warnings for sysemu source regs
Posted by Taylor Simpson 1 month ago
On Mon, Mar 9, 2026 at 8:48 AM Brian Cain <brian.cain@oss.qualcomm.com>
wrote:

> The analyze_read() methods on GuestSource, GuestPairSource,
> SystemSource, and SystemPairSource were no-ops because these
> source registers do not need read-tracking in the analyze phase.
> However, gen_analyze_funcs.py unconditionally declares the
> register-number variable (e.g. GsN) via decl_reg_num() for all
> registers that are read or written.  When building with
> hexagon-softmmu, the generated analyze function bodies are
> compiled (outside the #ifndef CONFIG_USER_ONLY guard), and the
> declared-but-unreferenced register-number variable triggers
> -Werror=unused-variable under both gcc and clang.
>
> Emit a (void) cast on the register number from analyze_read() to
> suppress the warning.
>
> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
> ---
>  target/hexagon/hex_common.py | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>

Better to declare GsN with G_GNUC_UNUSED.
Re: [PATCH v4 06/35] target/hexagon: Suppress unused-variable warnings for sysemu source regs
Posted by Brian Cain 1 month ago
On Mon, Mar 9, 2026 at 12:11 PM Taylor Simpson <ltaylorsimpson@gmail.com>
wrote:

>
>
> On Mon, Mar 9, 2026 at 8:48 AM Brian Cain <brian.cain@oss.qualcomm.com>
> wrote:
>
>> The analyze_read() methods on GuestSource, GuestPairSource,
>> SystemSource, and SystemPairSource were no-ops because these
>> source registers do not need read-tracking in the analyze phase.
>> However, gen_analyze_funcs.py unconditionally declares the
>> register-number variable (e.g. GsN) via decl_reg_num() for all
>> registers that are read or written.  When building with
>> hexagon-softmmu, the generated analyze function bodies are
>> compiled (outside the #ifndef CONFIG_USER_ONLY guard), and the
>> declared-but-unreferenced register-number variable triggers
>> -Werror=unused-variable under both gcc and clang.
>>
>> Emit a (void) cast on the register number from analyze_read() to
>> suppress the warning.
>>
>> Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
>> ---
>>  target/hexagon/hex_common.py | 16 ++++++++++++----
>>  1 file changed, 12 insertions(+), 4 deletions(-)
>>
>
> Better to declare GsN with G_GNUC_UNUSED.
>

This will be fixed in v5.



>
>