All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix possible circular definition with can_move_to()
@ 2021-01-24 16:29 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2021-01-24 16:29 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

can_move_to() is used to test if it is safe for a given pseudo to
be used by some instruction. This is done by checking that the
pseudo is defined 'before' the instruction.

This should, of course, reject the cases where the pseudo is defined
by the instruction itself because it would create a circular definition.
However, this special case was not checked.

Fix this by adding the missing check.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/simplify.c b/simplify.c
index 1e7648486c49..0bb66bedf463 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1606,6 +1606,8 @@ static inline bool can_move_to(pseudo_t src, struct instruction *dst)
 		return true;
 
 	def = src->def;
+	if (dst == def)
+		return false;
 	bbs = def->bb;
 	bbd = dst->bb;
 	if (bbs == bbd)
-- 
2.30.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-24 16:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-24 16:29 [PATCH] fix possible circular definition with can_move_to() Luc Van Oostenryck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.