[llvm] [LLVM][Intrinsics] Fix `llvm_anyptr_ty` to disallow vectors of pointers (PR #205806)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 05:51:20 PDT 2026


https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/205806

None

>From 3eff7315ead318afef3999a790caefa19f05220c Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Thu, 25 Jun 2026 05:49:06 -0700
Subject: [PATCH] [LLVM][Intrinsics] Fix `llvm_anyptr_ty` to disallow vectors
 of pointers

---
 llvm/include/llvm/IR/Intrinsics.td |  2 +-
 llvm/test/Verifier/anyptr-bad.ll   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Verifier/anyptr-bad.ll

diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index c4eedb62d46fc..129fe08ce3877 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -584,7 +584,7 @@ def llvm_anyvector_ty  : LLVMAnyType<vAny,
 
 // Note: CodeGenIntrinsics.cpp seems to check this class to check pointers.
 class LLVMAnyPointerType : LLVMAnyType<pAny,
-                                       AnyKindVectorConstraint.None,
+                                       AnyKindVectorConstraint.Scalar,
                                        AnyKindElementConstraint.Pointer>;
 
 def llvm_anyptr_ty     : LLVMAnyPointerType;      // ptr addrspace(N)
diff --git a/llvm/test/Verifier/anyptr-bad.ll b/llvm/test/Verifier/anyptr-bad.ll
new file mode 100644
index 0000000000000..7f942b39efe48
--- /dev/null
+++ b/llvm/test/Verifier/anyptr-bad.ll
@@ -0,0 +1,11 @@
+; RUN: not opt -passes=verify < %s 2>&1 | FileCheck %s
+
+; CHECK: intrinsic return type (overload type 0) expected any pointer type, but got <2 x ptr>
+; CHECK-NEXT: ptr @llvm.returnaddress
+
+declare <2 x ptr> @llvm.returnaddress(i32)
+
+define void @foo() {
+  call <2 x ptr> @llvm.returnaddress(i32 0)
+  ret void
+}



More information about the llvm-commits mailing list