Skip to content

[SPIRV][NFC] Add test that triggers ASAN failure#182550

Closed
jmmartinez wants to merge 1 commit intousers/jmmartinez/spirv/memory-issues-1from
users/jmmartinez/spirv/memory-issues-2
Closed

[SPIRV][NFC] Add test that triggers ASAN failure#182550
jmmartinez wants to merge 1 commit intousers/jmmartinez/spirv/memory-issues-1from
users/jmmartinez/spirv/memory-issues-2

Conversation

@jmmartinez
Copy link
Contributor

@jmmartinez jmmartinez commented Feb 20, 2026

This test is reduced from a failure detected after attempting to merge #178143.

Without ASAN the test passes. spirv-val fails likely due to an
unimplemented feature in spirv-val (assuming our implementation is correct).

Stacked PRs:

This test is reduced from a failure detected after attempting to merge
#178143.

Without ASAN the test passes. `spirv-val` fails likely due to an
unimplemented feature in `spirv-val` (assuming our implementation is
correct).

stack-info: PR: #182550, branch: users/jmmartinez/spirv/memory-issues-2
@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2026

@llvm/pr-subscribers-backend-spir-v

Author: Juan Manuel Martinez Caamaño (jmmartinez)

Changes

Stacked PRs:

  • #182552
  • #182551
  • ->#182550
  • #182549

[SPIRV][NFC] Add test that triggers ASAN failure

This test is reduced from a failure detected after attempting to merge
#178143.

Without ASAN the test passes. spirv-val fails likely due to an
unimplemented feature in spirv-val (assuming our implementation is
correct).


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

1 Files Affected:

  • (added) llvm/test/CodeGen/SPIRV/pointers/fun-ptr-to-itself.ll (+33)
diff --git a/llvm/test/CodeGen/SPIRV/pointers/fun-ptr-to-itself.ll b/llvm/test/CodeGen/SPIRV/pointers/fun-ptr-to-itself.ll
new file mode 100644
index 0000000000000..3415f2839d163
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/pointers/fun-ptr-to-itself.ll
@@ -0,0 +1,33 @@
+; XFAIL: asan
+; RUN: llc -mtriple=spirv32-unknown-unknown < %s --spirv-ext=+SPV_INTEL_function_pointers | FileCheck %s
+; RUN: %if spirv-tools %{ llc -mtriple=spirv32-unknown-unknown < %s -filetype=obj | not spirv-val 2>&1 | FileCheck --check-prefix=SPIRV-VAL %s %}
+
+; spirv-val poorly supports the SPV_INTEL_function_pointers extension.
+; In this case the function type used in a pointer type fails.
+; SPIRV-VAL: Invalid use of function type result id '[[#ID:]][%{{.*}}]'.
+; SPIRV-VAL: %_ptr_Generic_4 = OpTypePointer Generic %[[#ID]]
+
+; CHECK-DAG: OpCapability FunctionPointersINTEL
+; CHECK-DAG: OpExtension "SPV_INTEL_function_pointers"
+; CHECK-DAG: %[[#Void:]] = OpTypeVoid
+; CHECK-DAG: %[[#FnTy:]] = OpTypeFunction %[[#Void]]
+; CHECK-DAG: %[[#GenPtrTy:]] = OpTypePointer Generic %[[#FnTy]]
+; CHECK-DAG: %[[#GenPtrPtrTy:]] = OpTypePointer Function %[[#GenPtrTy]]
+; CHECK-DAG: %[[#Int8:]] = OpTypeInt 8 0
+; CHECK-DAG: %[[#Int8PtrTy:]] = OpTypePointer Function %[[#Int8]]
+; CHECK-DAG: %[[#CodePtrTy:]] = OpTypePointer CodeSectionINTEL %[[#FnTy]]
+; CHECK-DAG: %[[#Null:]] = OpConstantNull %[[#Int8PtrTy]]
+; CHECK-DAG: %[[#FnPtr:]] = OpConstantFunctionPointerINTEL %[[#CodePtrTy]] %[[#FnDef:]]
+; CHECK:     %[[#FnDef]] = OpFunction %[[#Void]] None %[[#FnTy]]
+; CHECK:     %[[#Cast:]] = OpPtrCastToGeneric %[[#GenPtrTy]] %[[#FnPtr]]
+; CHECK:     %[[#BC:]] = OpBitcast %[[#GenPtrPtrTy]] %[[#Null]]
+; CHECK:     OpStore %[[#BC]] %[[#Cast]] Aligned 8
+; CHECK:     OpReturn
+; CHECK:     OpFunctionEnd
+
+define void @foo() {
+entry:
+  store ptr addrspace(4) addrspacecast (ptr @foo to ptr addrspace(4)), ptr null, align 8
+  ret void
+}
+


; spirv-val poorly supports the SPV_INTEL_function_pointers extension.
; In this case the function type used in a pointer type fails.
; SPIRV-VAL: Invalid use of function type result id '[[#ID:]][%{{.*}}]'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to my response on the other PR I don't think we should do this spirv-val output checking, but otherwise LGTM.

Copy link
Contributor

@maarquitos14 maarquitos14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with @sarnex, but otherwise LGTM.

@jmmartinez
Copy link
Contributor Author

This tests was added in #183873 .

I'll fix the removal of the TODO in spirv-val with the other tests in #182549.

@jmmartinez jmmartinez closed this Mar 5, 2026
@github-actions github-actions bot deleted the users/jmmartinez/spirv/memory-issues-2 branch March 6, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants