llvm-project/llvm/test/Transforms/LowerConstantIntrinsics
Björn Pettersson 45b697e610
[MemoryBuiltins] Consider index type size when aggregating gep offsets (#132365)
[MemoryBuiltins] Consider index type size when aggregating gep offsets
Main goal here is to fix some bugs seen with LowerConstantIntrinsics
pass and the lowering of llvm.objectsize.

In ObjectSizeOffsetVisitor::computeImpl we are using an external
analysis together with stripAndAccumulateConstantOffsets. The idea
is to compute the Min/Max value of individual offsets within a GEP.
The bug solved here is that when doing the Min/Max comparisons the
external analysis wasn't considering the index type size (given by
the data layout), it was simply using the type from the IR. Since a
GEP is defined as sext/truncating indices we need to consider the
index type size in the external analysis.

This solves a regression (false ubsan warnings) seen after commit

02b8ee2819
(https://github.com/llvm/llvm-project/pull/117849).
2025-12-03 15:45:26 +01:00
..