[llvm] [DA] Add initial support for monotonicity check (PR #162280)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 17 11:35:04 PDT 2025
amehsan wrote:
> reading passed the array is definitely a security problem
We are not accessing any out of bound memory in the above example. I am not sure whether this violates any language standard or not. I will look into it.
The fundamental issue is that two different 64 bit addresses may point to the same memory location at least on AArch64. `DataLayout::getIndexSize()` and `DataLayout::getPointerSize()` both return 8. I will check the langref further to see if there is anything I miss.
On x86 the situation maybe different. Since the upper bits of address have to be in a canonical form. I will do some more investigation on x86 as well, and then open an issue to discuss the implications.
Regarding the bug, haven't checked vectorization yet, but I have another bug. Basically alias analysis thinks `p` and `p + 1ULL << 58` point to two different memory location but that is not correct. (I have tried this on two different AArch64 chips from two different vendors)
```
#include <stdio.h>
__attribute__((noinline))
char foo (char *a) {
char *b = a+ (1ULL << 58) ;
*b = *a + 2;
return *a;
}
int main () {
char a[4];
a[0] = 25;
a[1] = 26;
a[2] = 27;
a[3] = 28;
char t = foo (a);
printf("result: %d\n", t);
}
```
https://github.com/llvm/llvm-project/pull/162280
More information about the llvm-commits
mailing list