[llvm] [llvm] Fix __builtin_object_size interaction between Negative Offset … (PR #111827)

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 20 14:29:36 PDT 2024


hvdijk wrote:

> Which makes me think that in both cases, if we have the choice between two object with the same size + offset value, then choosing the one with the larger offset solves the issue. I'll check that.

That works for this test, though for `__builtin_dynamic_object_size(ptr + index, 1)` it might cause a too large value to be returned.

I think we need to, at least in the `__builtin_dynamic_object_size` case, use `ObjectSizeOpts::Mode::ExactUnderlyingSizeAndOffset` in which case we can return that we do not statically know the size of the object. That way, we end up in `ObjectSizeOffsetEvaluator::visitPHINode` and can handle each incoming value separately and return the correct value.

https://github.com/llvm/llvm-project/pull/111827


More information about the llvm-commits mailing list