Skip to contentSkip to conversation

target/hexagon: Emit comments to silence coverity

PATCH New Anton Johansson via 1 participant 1 message Jun 2, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/hexagon: Emit comments to silence coverity

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.

---
 target/hexagon/idef-parser/parser-helpers.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
target/hexagon/idef-parser/parser-helpers.c +4 -1
index 7b5ebafec2..59ef018d44 100644
@@ -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");
Signature · 1 line
2.39.1