Skip to content

Allow address space cast for function pointer when Intel function pointer extension is available#3786

Open
jinge90 wants to merge 2 commits into
KhronosGroup:mainfrom
jinge90:fix_bitcast_for_as9_ptr
Open

Allow address space cast for function pointer when Intel function pointer extension is available#3786
jinge90 wants to merge 2 commits into
KhronosGroup:mainfrom
jinge90:fix_bitcast_for_as9_ptr

Conversation

@jinge90

@jinge90 jinge90 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

pointer extension is available

Signed-off-by: jinge90 <ge.jin@intel.com>
@CLAassistant

CLAassistant commented Jun 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Signed-off-by: jinge90 <ge.jin@intel.com>

@MrSidims MrSidims left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you please provide a link with a spec change, which allows such cast?

Comment thread lib/SPIRV/SPIRVWriter.cpp
SPIRVEC_InvalidModule, U,
"Casts from CodeSectionINTEL address space require "
"SPV_INTEL_function_pointers extension\n");
BOC = OpBitcast;

@MrSidims MrSidims Jun 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No bitcast please. It should be a storage cast.

; RUN: llvm-spirv %t.spv -to-text -o %t.spt
; RUN: FileCheck < %t.spt %s

; CHECK: Bitcast {{[0-9]+}} [[#]] [[#]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test currently checks nothing. Add checks for type and operands.


; RUN: llvm-spirv %s -spirv-ext=+SPV_INTEL_function_pointers -spirv-emit-function-ptr-addr-space -o %t.spv
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
; RUN: FileCheck < %t.spt %s

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is LLVM IR after the round trip?

Comment on lines +1 to +2
; Test that addrspacecast for CodeSectionINTEL (addrspace 9) does not
; produce an error when SPV_INTEL_function_pointers is enabled.

@MrSidims MrSidims Jun 22, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe it's mustn't be the goal of the test. Instead we must check, what SPIR-V is produced, because you are not only preventing a crash/error, but introducing new SPIR-V pattern.

Comment thread lib/SPIRV/SPIRVWriter.cpp
Comment on lines +1722 to +1723
"Casts from CodeSectionINTEL address space require "
"SPV_INTEL_function_pointers extension\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The error will never fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants