[llvm-branch-commits] [llvm] [IR] Introduce the `ptrtoaddr` instruction (PR #139357)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 6 01:18:09 PDT 2025


================
@@ -3532,6 +3533,28 @@ void Verifier::visitFPToSIInst(FPToSIInst &I) {
   visitInstruction(I);
 }
 
+void Verifier::visitPtrToAddrInst(PtrToAddrInst &I) {
+  // Get the source and destination types
+  Type *SrcTy = I.getOperand(0)->getType();
+  Type *DestTy = I.getType();
+
+  Check(SrcTy->isPtrOrPtrVectorTy(), "PtrToAddr source must be pointer", &I);
+  Check(DestTy->isIntOrIntVectorTy(), "PtrToAddr result must be integral", &I);
+  Check(SrcTy->isVectorTy() == DestTy->isVectorTy(), "PtrToAddr type mismatch",
+        &I);
+
+  if (SrcTy->isVectorTy()) {
+    auto *VSrc = cast<VectorType>(SrcTy);
+    auto *VDest = cast<VectorType>(DestTy);
+    Check(VSrc->getElementCount() == VDest->getElementCount(),
+          "PtrToAddr vector width mismatch", &I);
----------------
nikic wrote:

```suggestion
          "PtrToAddr vector length mismatch", &I);
```
width would typically be the bit width, not the element count.

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


More information about the llvm-branch-commits mailing list