diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-01-29 11:48:06 +0100 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2017-02-13 09:34:45 +0800 |
| commit | d3bf74f5f13702fc758d442894ad034e55328062 (patch) | |
| tree | 0bc2a489c72f440336ffc53d9693d1c50518fb4f | |
| parent | 61c406241c5d1a8da3f829e51e18f20b77f25926 (diff) | |
| download | sparse-dev-d3bf74f5f13702fc758d442894ad034e55328062.tar.gz | |
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 <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
| -rw-r--r-- | simplify.c | 1 | ||||
| -rw-r--r-- | validation/kill-computedgoto.c | 17 |
2 files changed, 18 insertions, 0 deletions
@@ -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\\. + */ |
