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

Tom Honermann via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 10 15:55:37 PDT 2026


================
@@ -272,8 +286,10 @@ class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
     assert(Triple.getArch() == llvm::Triple::spir &&
            "Invalid architecture for 32-bit SPIR.");
     PointerWidth = PointerAlign = 32;
-    SizeType = TargetInfo::UnsignedInt;
-    PtrDiffType = IntPtrType = TargetInfo::SignedInt;
+    if (!HostTarget) {
+      SizeType = TargetInfo::UnsignedInt;
+      PtrDiffType = IntPtrType = TargetInfo::SignedInt;
+    }
----------------
tahonermann wrote:

If we do what I suggested in another comment and assign `PointerWidth` and `PointerAlign` in `BaseSPIRTargetInfo` when a host target is present, then we can add asserts here that expectations are met. Likewise for the SPIR64, SPIR-V32, and SPIR-V64 targets.

```suggestion
    if (!HostTarget) {
      PointerWidth = PointerAlign = 32;
      SizeType = TargetInfo::UnsignedInt;
      PtrDiffType = IntPtrType = TargetInfo::SignedInt;
    } else {
      assert(PointerWidth == 32 && "Invalid host target pointer size for SPIR32");
      assert(PointerAlign == 32 && "Invalid host target pointer alignment for SPIR32");
    }
```

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


More information about the cfe-commits mailing list