From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/2] fix testing if a OP_CALL's function is pure
Date: Sun, 25 Oct 2020 14:09:21 +0100 [thread overview]
Message-ID: <20201025130921.20693-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20201025130921.20693-1-luc.vanoostenryck@gmail.com>
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>
---
simplify.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/simplify.c b/simplify.c
index 6caf6cbcf918..634a3ea66e91 100644
--- a/simplify.c
+++ b/simplify.c
@@ -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);
--
2.29.0
prev parent reply other threads:[~2020-10-25 13:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-25 13:09 [PATCH 0/2] fix testing if a OP_CALL's function is pure Luc Van Oostenryck
2020-10-25 13:09 ` [PATCH 1/2] add helper first_symbol() Luc Van Oostenryck
2020-10-25 13:09 ` Luc Van Oostenryck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201025130921.20693-3-luc.vanoostenryck@gmail.com \
--to=luc.vanoostenryck@gmail.com \
--cc=linux-sparse@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).