aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2025-10-21 09:27:07 +0200
committerGitHub <noreply@github.com>2025-10-21 09:27:07 +0200
commitec26f219acce77fb9b3d52abd31b0e639e788514 (patch)
treecfb956b6ba5c2c96b61ea3cf9ae02f435dcd5d8a /clang/lib/CodeGen/CodeGenModule.cpp
parent07d47c792b980746ab1ff5ea3f346c87b024bd51 (diff)
downloadllvm-ec26f219acce77fb9b3d52abd31b0e639e788514.zip
llvm-ec26f219acce77fb9b3d52abd31b0e639e788514.tar.gz
llvm-ec26f219acce77fb9b3d52abd31b0e639e788514.tar.bz2
[InstSimplify] Support ptrtoaddr in simplifyGEPInst() (#164262)
This adds support for ptrtoaddr in the `ptradd p, ptrtoaddr(p2) - ptrtoaddr(p) -> p2` fold. This fold requires that p and p2 have the same underlying object (otherwise the provenance may not be the same). The argument I would like to make here is that because the underlying objects are the same (and the pointers in the same address space), the non-address bits of the pointer must be the same. Looking at some specific cases of underlying object relationship: * phi/select: Trivially true. * getelementptr: Only modifies address bits, non-address bits must remain the same. * addrspacecast round-trip cast: Must preserve all bits because we optimize such round-trip casts away. * non-interposable global alias: I'm a bit unsure about this one, but I guess the alias and the aliasee must have the same non-address bits? * various intrinsics like launder.invariant.group, ptrmask. I think these all either preserve all pointer bits (like the invariant.group ones) or at least the non-address bits (like ptrmask). There are some interesting cases like amdgcn.make.buffer.rsrc, but those are cross address-space. ----- There is a second `gep (gep p, C), (sub 0, ptrtoint(p)) -> C` transform in this function, which I am not extending to handle ptrtoaddr, adding negative tests instead. This transform is overall dubious for provenance reasons, but especially dubious with ptrtoaddr, as then we don't have the guarantee that provenance of `p` has been exposed.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions