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

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 11 03:25:42 PDT 2024


hvdijk wrote:

The PR makes it so that `ObjectSizeOffsetVisitor::visitPHINode` can return different results for the same PHI node when called with a different `ConstantOffset`, but that seems like it would interfere with the caching done in `ObjectSizeOffsetEvaluator::compute_`. I do not have a test case that shows wrong behaviour because of that though.

Here is another test demonstrating the PHI handling is not quite right yet, this one not related to negative offsets:
```c++
#include <stdio.h>
int x;
int main(void) {
  int array1[4] = {0};
  int array2[4] = {0};
  int *ptr;
  if (x) {
    ptr = array1;
  } else {
    ptr = array2;
  }
  printf("%zu\n", __builtin_object_size(ptr, 3));
}
```
Regardless of whether it's `array1` or `array2`, 16 bytes are available, so .

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


More information about the llvm-commits mailing list