Message ID | 20210124162915.9711-1-luc.vanoostenryck@gmail.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Headers | show |
Series | fix possible circular definition with can_move_to() | expand |
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)
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(+)