[llvm] [InstSimplify] Fold `getelementptr inbounds null, idx -> null` (PR #130742)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 21 11:57:02 PDT 2025


efriedma-quic wrote:

For reference, the relevant construct in xalancbmk looks something like this:

```
C* p = nullptr;
size_t offset = (char*)(&p->x) - (char*)p;
```

This isn't caught by the checks we added to clang because it requires some non-trivial analysis to figure out that `p` is actually null at the point of use: it isn't declared as a constant.

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


More information about the llvm-commits mailing list