[llvm] [IR] Use iteration limit in stripPointerCastsAndOffsets (PR #190472)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 13:25:00 PDT 2026
aengelke wrote:
Thanks for reducing. The problem is that the code expects that stripPointerCasts(stripPointerCasts(X))==stripPointerCasts(X), which obviously doesn't hold after this change. Options:
1. Document that strip*Casts are not guaranteed to strip everything and refactor SelectionDAG code to no longer rely on this. (The same assumption might be made elsewhere, though.)
2. Disallow degenerate IR in unreachable blocks where values use themselves, possibly transitively. I'm not sure where exactly the fact that this is allowed is used, but it is used and this has been allowed since 2004.
3. Forbid stripPointerCasts calls on unreachable instructions. (How to enforce this? Do all callers need to do reachability checks first?)
4. Do nothing.
The strip*Casts functions are, IMO, inherently a bit problematic, because using them can even on sufficiently reasonable IR (long GEP chains) lead to quadratic compile time (this is even more relevant for #190473). Option 1 seems therefore most reasonable to me. Option 2 is idealistically the best, but is likely difficult to implement. Option 3 is not viable. Option 4 is.. frustrating, because "some weird corner case" (non-PHI use cycles) cause a performance degradation in the common case.
@nikic Opinions?
https://github.com/llvm/llvm-project/pull/190472
More information about the llvm-commits
mailing list