In simplify_one_memop(), addresses with a constant offset are folded into the load or store operation itself. It's also checked that this address calculation doesn't create a loop (this can currently happen when using undefined variables) as such a loop would create an infinite loop in sparse simplification phase. Independently of the result of this check, the offset is effectively folded into the memop. In such loops there is a mutual dependency between the loaded value and the address. There is a second kind of possible infinite loop: one where the mutual dependency is between the old and the new value of the offset. Of course, both cases are internal errors and should be correctly addressed. but it's not the purpose of this patch. This patch add the detection of this second kind of infinite loop and, since in this case it doesn't make sense to try to update the offset, the 'simplification' of this memop is stopped there (which seems to be a good thing for the first kind too). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/simplify.c b/simplify.c index b28d93755..588267065 100644 --- a/simplify.c +++ b/simplify.c @@ -1059,7 +1059,7 @@ static int simplify_one_memop(struct instruction *insn, pseudo_t orig) offset: /* Invalid code */ - if (new == orig) { + if (new == orig || new == addr) { if (new == VOID) return 0; /* @@ -1071,8 +1071,9 @@ offset: */ if (repeat_phase & REPEAT_CFG_CLEANUP) return 0; - new = VOID; warning(insn->pos, "crazy programmer"); + replace_pseudo(insn, &insn->src, VOID); + return 0; } insn->offset += off->value; replace_pseudo(insn, &insn->src, new); -- 2.18.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html