OP_STOREs were ignored by kill_instruction() but if it is force-killed because the basic block it belong became unreachable then we need to adjust the usage of its operands. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 7 +++++++ validation/kill-store.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 validation/kill-store.c diff --git a/simplify.c b/simplify.c index a27f6a33a..804467f0d 100644 --- a/simplify.c +++ b/simplify.c @@ -255,6 +255,13 @@ void kill_insn(struct instruction *insn, int force) kill_use(&insn->src); break; + case OP_STORE: + if (!force) + return; + kill_use(&insn->src); + kill_use(&insn->target); + break; + case OP_ENTRY: /* ignore */ return; diff --git a/validation/kill-store.c b/validation/kill-store.c new file mode 100644 index 000000000..8f7253226 --- /dev/null +++ b/validation/kill-store.c @@ -0,0 +1,16 @@ +void keep(int *p) { *p = 0; } +void kill(int *p, int i) { if (i && 0) *p = 0; } +void dead(int *p, int i) { int v = i++; if (i && 0) p[v] = 0; } + + +/* + * check-name: kill-store + * check-command: test-linearize -Wno-decl $file + * check-description: + * Check that stores are optimized away but only + * when needed: + * - bb unreachable. + * + * check-output-ignore + * check-output-pattern-1-times: store\\. + */ -- 2.11.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