aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-24 14:54:14 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2021-01-24 17:22:45 +0100
commit879b11da4ef9a675216eb1f3458cff1e53904c03 (patch)
tree3b0f52687a71d4ba4592a217d58366e5bf4c121d
parent56dbccf50c2185571f34c3dfaf4753942f6a2372 (diff)
downloadsparse-879b11da4ef9a675216eb1f3458cff1e53904c03.tar.gz
fix possible circular definition with can_move_to()
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>
-rw-r--r--simplify.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/simplify.c b/simplify.c
index 1e764848..0bb66bed 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)