[llvm-branch-commits] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)
Alexander Richardson via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri May 9 22:36:38 PDT 2025
https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/139357
This introduces a new `ptrtoaddr` instruction which is similar to
`ptrtoint` but has two differences:
1) Unlike `ptrtoint`, `ptrtoaddr` does not capture provenance
2) `ptrtoaddr` only extracts (and then extends/truncates) the low
index-width bits of the pointer
For most architectures, difference 2) does not matter since index (address)
width and pointer representation width are the same, but this does make a
difference for architectures that have pointers that aren't just plain
integer addresses such as AMDGPU fat pointers or CHERI capabilities.
This commit introduces textual and bitcode IR support as well as basic code
generation, but optimization passes do not handle the new instruction yet
so it may result in worse code than using ptrtoint. Follow-up changes will
update capture tracking, etc. for the new instruction.
RFC: https://discourse.llvm.org/t/clarifiying-the-semantics-of-ptrtoint/83987/54
More information about the llvm-branch-commits
mailing list