Currently OP_SWITCHes are only handled by default in kill_insn(). In consequence, when killed, OP_SWITCHes leave a fake usage on the condition. Fix this by removing the condition's usage when killing an OP_SWITCH. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 1 + validation/kill-switch.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 validation/kill-switch.c diff --git a/simplify.c b/simplify.c index ad32fe08a..048f7c3aa 100644 --- a/simplify.c +++ b/simplify.c @@ -270,6 +270,7 @@ int kill_insn(struct instruction *insn, int force) break; case OP_CBR: + case OP_SWITCH: case OP_COMPUTEDGOTO: kill_use(&insn->cond); break; diff --git a/validation/kill-switch.c b/validation/kill-switch.c new file mode 100644 index 000000000..f6b879b31 --- /dev/null +++ b/validation/kill-switch.c @@ -0,0 +1,20 @@ +static struct s { + unsigned f:1; +} s; + +static void foo(void) +{ + switch (s.f) { + case 0: + ; + } +} + +/* + * check-name: kill-switch + * check-command: test-linearize $file + * + * check-output-ignore + * check-output-excludes: load\\. + * check-output-excludes: trunc\\. + */ -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html