From d3bf74f5f13702fc758d442894ad034e55328062 Mon Sep 17 00:00:00 2001 From: Luc Van Oostenryck Date: Sun, 29 Jan 2017 11:48:06 +0100 Subject: [PATCH] fix killing OP_COMPUTEDGOTO Currently kill_instruction() doesn't do anything with the operands of computed gotos (OP_COMPUTEDGOTO). But when these instructions are removed we must also remove the operands 'usage'. Without this some instructions, which provides the select's operands, are not optimized away as expected. The fix consists by killing it's operand much like what is done for conditional branches. Signed-off-by: Luc Van Oostenryck Signed-off-by: Christopher Li --- simplify.c | 1 + validation/kill-computedgoto.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 validation/kill-computedgoto.c diff --git a/simplify.c b/simplify.c index 1e4aa63b..690fdc4e 100644 --- a/simplify.c +++ b/simplify.c @@ -225,6 +225,7 @@ void kill_instruction(struct instruction *insn) kill_use(&insn->src3); return; case OP_BR: + case OP_COMPUTEDGOTO: insn->bb = NULL; repeat_phase |= REPEAT_CSE; if (insn->bb_true && insn->bb_false) diff --git a/validation/kill-computedgoto.c b/validation/kill-computedgoto.c new file mode 100644 index 00000000..3b3ed8ff --- /dev/null +++ b/validation/kill-computedgoto.c @@ -0,0 +1,17 @@ +void foo(int a); +void foo(int a) +{ + void *l = &&end + 3; + +end: + if (a * 0) + goto *l; +} + +/* + * check-name: kill-computedgoto + * check-command: test-linearize $file + * + * check-output-ignore + * check-output-excludes: add\\. + */ -- 2.11.4.GIT