* [PATCH 0/2] fix testing if a OP_CALL's function is pure
@ 2020-10-25 13:09 Luc Van Oostenryck
2020-10-25 13:09 ` [PATCH 1/2] add helper first_symbol() Luc Van Oostenryck
2020-10-25 13:09 ` [PATCH 2/2] fix testing if a OP_CALL's function is pure Luc Van Oostenryck
0 siblings, 2 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2020-10-25 13:09 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
kill_instruction() will only kill an OP_CALL corresponding to
a pure function but this can't be testing if the call is not
done directly via the function's symbols.
These 2 patches fix this by using the function's type always
available in the instruction itself.
Luc Van Oostenryck (2):
add helper first_symbol()
fix testing if a OP_CALL's function is pure
lib.h | 5 +++++
simplify.c | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
base-commit: 8f7e21cadc21f49819d003e560d4607d720c647f
--
2.29.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] add helper first_symbol()
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 ` Luc Van Oostenryck
2020-10-25 13:09 ` [PATCH 2/2] fix testing if a OP_CALL's function is pure Luc Van Oostenryck
1 sibling, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2020-10-25 13:09 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
This is just a wrapper around first_ptr_list().
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
lib.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib.h b/lib.h
index 0b1d4492e6bd..b4c3db93ab31 100644
--- a/lib.h
+++ b/lib.h
@@ -204,6 +204,11 @@ static inline pseudo_t first_pseudo(struct pseudo_list *head)
return first_ptr_list((struct ptr_list *)head);
}
+static inline struct symbol *first_symbol(struct symbol_list *head)
+{
+ return first_ptr_list((struct ptr_list *)head);
+}
+
static inline void concat_symbol_list(struct symbol_list *from, struct symbol_list **to)
{
concat_ptr_list((struct ptr_list *)from, (struct ptr_list **)to);
--
2.29.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] fix testing if a OP_CALL's function is pure
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
1 sibling, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2020-10-25 13:09 UTC (permalink / raw)
To: linux-sparse; +Cc: Luc Van Oostenryck
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-25 13:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 2/2] fix testing if a OP_CALL's function is pure Luc Van Oostenryck
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).