[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 18 23:46:54 PDT 2024
hvdijk wrote:
Sorry, but that looks like a very wrong approach to me. The code you're modifying in your last commit was already correct, and this new version means we no longer detect accesses before the start of an object as out of bounds.
```c++
#include <stdio.h>
int i = -1;
int main() {
int array[4];
printf("%zu\n", __builtin_dynamic_object_size(array + i, 0));
}
```
Here, we used to print 0, and 0 is the best possible value to print. Your update makes it so that we print 20.
When you've got an index that you *know* is before the start of an object, you know it's invalid to access any bytes, that's what the code there was correctly handling. The problem isn't that check, it's that the PHI handling wrongly concludes that we know we're at the start of an object when we're not, and that is the bit that needs to be fixed.
https://github.com/llvm/llvm-project/pull/111827
More information about the llvm-commits
mailing list