[llvm] [llvm] Improve llvm.objectsize computation by computing GEP, alloca a… (PR #117849)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 18 04:57:07 PST 2024
serge-sans-paille wrote:
Simpler reproducer:
```
unsigned char check_loopfilter_16y(unsigned i, int dir, long * res)
{
unsigned char base1[32 + 16 * 16];
int midoff = dir ? 4 * 16 : 4;
int midoff_aligned = dir ? 4 * 16 : 16;
unsigned char *buf1 = base1 + midoff_aligned;
*res = __builtin_object_size((buf1 - midoff), 0);
return base1[i];
}
```
Basically what happens here is that `buf1` is computed to be in `[base1 + 16, base1 + 4 * 16]` and `-midoff` in `[-4 * 16, -4]`. Because we have no data dependency, `__builtin_object_size` computes that its argument may be *before* `base1` (through `16 - 4*16`) and correctly detects it, but the corresponding action is probably not the best. please give me a day to make sure my local patch is correct, otherwise we'll revert.
https://github.com/llvm/llvm-project/pull/117849
More information about the llvm-commits
mailing list