[llvm] [MemoryBuiltins] Consider index type size when aggregating gep offsets (PR #132365)
Björn Pettersson via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 07:02:58 PDT 2025
bjope wrote:
> I thought there would be test cases where the offset accumulation would lead to an overflow. What should we do in that case?
The idea with this patch is to make sure we make a correct comparison when comparing GEP indices, when aggregating the highest/lowest offsets from select/phi operations. LangRef (https://llvm.org/docs/LangRef.html#id240) says that "The indices are first converted to offsets in the pointer’s index type.", so unless we follow that semantic when we compare GEP indices we could pick the wrong values for the aggregated result.
I think that the logic for adding the aggregated offset to the base pointer (and checking for overflow) is handled here https://github.com/llvm/llvm-project/blob/c20605be9d8e63dd38efeb8547abae90097ba493/llvm/lib/Analysis/MemoryBuiltins.cpp#L835
https://github.com/llvm/llvm-project/pull/132365
More information about the llvm-commits
mailing list