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

via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 06:18:03 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Rahul Joshi (jurahul)

<details>
<summary>Changes</summary>

`llvm_anyptr_ty` should only allow scalar pointer types and disallow vector of pointers; fix the vector constraint for `llvm_anyptr_ty` accordingly.  This fixes a regression in `llvm_anyptr_ty` that was introduced in https://github.com/llvm/llvm-project/pull/203506.

Added a unit test to verify that use of a vector of pointers for `llvm_anyptr_ty` fails verification.

---
Full diff: https://github.com/llvm/llvm-project/pull/205806.diff


2 Files Affected:

- (modified) llvm/include/llvm/IR/Intrinsics.td (+1-1) 
- (added) llvm/test/Verifier/anyptr-bad.ll (+11) 


``````````diff
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
+}

``````````

</details>


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


More information about the llvm-commits mailing list