diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-23 23:46:01 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-25 13:56:37 +0100 |
commit | 218bb8a1658980ec2a25b229850236cae39de19d (patch) | |
tree | 2790fd88d4b391804c5274b1b53756a75991316e | |
parent | b098088b394cf86affd705bd27c80842a4d12460 (diff) | |
download | sparse-218bb8a1658980ec2a25b229850236cae39de19d.tar.gz |
fix testing if a OP_CALL's function is pure
kill_instruction() will kill an OP_CALL but only if it's a
forced kill or if the corresponding function is pure.
However, only functions called via a symbol pseudo are so killed.
Those called via a function pointer are not because only symbol
pseudos contain the function type needed to test the presence of
the MOD_PURE modifier.
Fix this by using the function type always available in the
instruction's ::fntypes member.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | simplify.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -351,9 +351,9 @@ int kill_insn(struct instruction *insn, int force) case OP_CALL: if (!force) { /* a "pure" function can be killed too */ - if (!(insn->func->type == PSEUDO_SYM)) - return 0; - if (!(insn->func->sym->ctype.modifiers & MOD_PURE)) + struct symbol *fntype = first_symbol(insn->fntypes); + + if (!(fntype->ctype.modifiers & MOD_PURE)) return 0; } kill_use_list(insn->arguments); |