llvm-project
b7424965 - [LAA] Drop redundant start check in evaluatePtrAddRecAtMaxBTCWillNotWrap (#237282)

Commit
22 days ago
[LAA] Drop redundant start check in evaluatePtrAddRecAtMaxBTCWillNotWrap (#237282) The function bailed out unless AR's start was known u>= StartPtr. This is implied by the final MaxOffset u<= DerefBytes check, which in both directions bounds StartOffset by DerefBytes: for a non-negative step MaxOffset is StartOffset + AccessedBytes, built without overflow; for a negative step it is StartOffset itself. StartOffset is Start - StartPtr modulo 2^N, so Start == StartPtr + StartOffset with StartOffset in [0, DerefBytes]: ``` StartPtr StartPtr + DerefBytes | | |===================|==========| dereferenceable, cannot wrap |<-- StartOffset -->| | Start ``` Hence Start u>= StartPtr. A start below StartPtr wraps StartOffset to a large value and still fails the check. This gives reverse loops with a symbolic start a tight lower bound, e.g. Low: %A instead of null in negative-step-deref-off-by-eltsize.ll. Add tests for accesses starting below the base pointer.
Author
Parents
Loading