[llvm] [GlobalOpt] Check if global gets compared to pointer of different obj. (PR #153789)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 18 09:42:41 PDT 2025


https://github.com/fhahn commented:

> This logic seems like it's working the wrong way: in general, you have to assume the pointer points to a different object unless you can prove it points to the same object.
> 
> If you want to check if a pointer points to a certain object, you can just use getUnderlyingObject().

Hm, originally I was worried that restricting to same UOs may be too restrictive and cause a large number of regressions.

But I checked this against a large corpus of IR, and there are only changes in 4 files, so it's probably not too bad.

They all seem to come from compares with a constant and a function argument, like in `@compare_arg`

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


More information about the llvm-commits mailing list