[llvm] [SPIR-V] Add lowering of ptrtoaddr (PR #184577)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 04:47:07 PST 2026
================
@@ -1725,6 +1726,16 @@ Instruction *SPIRVEmitIntrinsics::visitBitCastInst(BitCastInst &I) {
return NewI;
}
+Instruction *SPIRVEmitIntrinsics::visitPtrToAddrInst(PtrToAddrInst &I) {
+ // Replace PtrToAddr with PtrToInt.
+ auto *PtrToInt =
+ CastInst::Create(Instruction::PtrToInt, I.getOperand(0), I.getType());
+ PtrToInt->insertBefore(I.getIterator());
+ replaceAllUsesWith(&I, PtrToInt);
+ I.eraseFromParent();
----------------
jmmartinez wrote:
I'd add an assertion about the assumption we're making here (check the method `PointerSpec &DataLayout::getPointerSpec(uint32_t AddrSpace)`).
For example, AMDGPU has fat pointers with bounds checking and strides.
https://github.com/llvm/llvm-project/pull/184577
More information about the llvm-commits
mailing list