Skip to content

[SYCL][SPIR-V] Implement fix for Windows/MSVC SPIR-V device target support#208196

Draft
schittir wants to merge 4 commits into
llvm:mainfrom
schittir:Windows_SPIRV_targets
Draft

[SYCL][SPIR-V] Implement fix for Windows/MSVC SPIR-V device target support#208196
schittir wants to merge 4 commits into
llvm:mainfrom
schittir:Windows_SPIRV_targets

Conversation

@schittir

@schittir schittir commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

The following are five gaps identified in the existing host-adaptation mechanism in BaseSPIRTargetInfo, which are causing incorrect behaviour on Windows.

  1. SizeType/PtrDiffType/IntPtrType: not copied from host; hardcoded to LP64 defaults in derived classes, giving 32-bit size_t on Win64.
  2. UseMicrosoftManglingForC: never inherited; operator new mangles as _Znwm (unsigned long) instead of _Znwy (unsigned long long).
  3. getBuiltinVaListKind(): returns VoidPtr unconditionally instead of delegating to the host's va_list kind.
  4. checkCallingConvention(): rejects host calling conventions (__vectorcall, __regcall) that device code inherits from shared headers.
  5. Derived-class defaults: unconditionally overwrite host-adapted values, working on Linux only by coincidence.

This patch extends BaseSPIRTargetInfo's host-adaptation mechanism to attempt fixing existing issues for Windows support, by copying pointer-related types from the host, querying for the right mangling, delegating va_list and calling convention checks to the host, and guarding derived-class fallbacks behind if(!HostTarget).

This patch also introduces SPIRVPhysicalTargetInfo as a unified base for spirv32/spirv64 that derives pointer width from the host target when available.

Overall, this patch attempts to fix issues and take advantage of the existing OS-agnostic aux-triple mechanism used for Linux, to work for Windows too, without introducing new triples.

…pport

The following are five gaps identified ing the existing host-adaptation
mechanism in BaseSPIRTargetInfo, causing incorrect behaviour on Windows.

  1. SizeType/PtrDiffType/IntPtrType: not copied from host; hardcoded to
     LP64 defaults in derived classes, giving 32-bit size_t on Win64.
  2. UseMicrosoftManglingForC: never inherited; operator new mangles as
     _Znwm (unsigned long) instead of _Znwy (unsigned long long).
  3. getBuiltinVaListKind(): returns VoidPtr unconditionally instead of
     delegating to the host's va_list kind.
  4. checkCallingConvention(): rejects host calling conventions
     (__vectorcall, __regcall) that device code inherits from shared
     headers.
  5. Derived-class defaults: unconditionally overwrite host-adapted
     values, working on Linux only by coincidence.

This patch extends BaseSPIRTargetInfo's host-adaptation mechanism to
attempt fixing existing issues for Windows support, by copying pointer-related
types from the host, querying for the right mangling, delegating va_list and
calling convention checks to the host, and guarding derived-class fallbacks
behind if(!HostTarget).

This patch also introduces SPIRVPhysicalTargetInfo as a unified base for
spirv32/spirv64 that derives pointer width from the host target when available.

Overall, this patch takes advantage of the existing OS-agnostic aux-triple
mechanism currently used for Linux, to work for Windows without introducing
new triples.
@schittir schittir requested a review from tahonermann July 8, 2026 11:10
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

✅ With the latest revision this PR passed the C/C++ code formatter.

@schittir schittir requested a review from Fznamznon July 8, 2026 14:00
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.

1 participant