* [PATCH] target/hexagon: Emit comments to silence coverity
@ 2023-06-02 19:06 Anton Johansson via
0 siblings, 0 replies; only message in thread
From: Anton Johansson via @ 2023-06-02 19:06 UTC (permalink / raw)
To: qemu-devel; +Cc: ale, bcain, richard.henderson, pbonzini, peter.maydell
idef-parser emits safety checks around shifts and extensions to deal
with shift amounts larger than the TCGv size and extensions of 0-bit
regions. These safety checks sometimes result in dead branches, which
coverity detects and warns about.
This commits silences these dead code warnings in emitted code by using
markup comments.
Signed-off-by: Anton Johansson <anjo@rev.ng>
---
target/hexagon/idef-parser/parser-helpers.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/target/hexagon/idef-parser/parser-helpers.c b/target/hexagon/idef-parser/parser-helpers.c
index 7b5ebafec2..59ef018d44 100644
--- a/target/hexagon/idef-parser/parser-helpers.c
+++ b/target/hexagon/idef-parser/parser-helpers.c
@@ -636,6 +636,7 @@ static void gen_asl_op(Context *c, YYLTYPE *locp, unsigned bit_width,
} break;
case REG_IMM: {
OUT(c, locp, "if (", op2, " >= ", &bit_width, ") {\n");
+ OUT(c, locp, "/* coverity[dead_error_condition] */\n");
OUT(c, locp, "tcg_gen_movi_", bit_suffix, "(", res, ", 0);\n");
OUT(c, locp, "} else {\n");
OUT(c, locp, "tcg_gen_shli_", bit_suffix,
@@ -691,7 +692,8 @@ static void gen_asr_op(Context *c, YYLTYPE *locp, unsigned bit_width,
gen_c_int_type(c, locp, bit_width, signedness);
OUT(c, locp, " shift = ", op2, ";\n");
OUT(c, locp, "if (", op2, " >= ", &bit_width, ") {\n");
- OUT(c, locp, " shift = ", &bit_width, " - 1;\n");
+ OUT(c, locp, "/* coverity[dead_error_condition] */\n");
+ OUT(c, locp, "shift = ", &bit_width, " - 1;\n");
OUT(c, locp, "}\n");
OUT(c, locp, "tcg_gen_sari_", bit_suffix,
"(", res, ", ", op1, ", shift);\n}\n");
@@ -1060,6 +1062,7 @@ static HexValue gen_extend_imm_width_op(Context *c,
");\n");
if (need_guarding) {
OUT(c, locp, "} else {\n");
+ OUT(c, locp, "/* coverity[dead_error_condition] */\n");
OUT(c, locp, "tcg_gen_movi_i", &dst_width, "(", &res,
", 0);\n");
OUT(c, locp, "}\n");
--
2.39.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-02 19:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02 19:06 [PATCH] target/hexagon: Emit comments to silence coverity Anton Johansson via
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).