[clang] [clang] Diagnose host/device pointer width mismatches (PR #215620)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 21 11:13:00 PDT 2026


================
@@ -254,16 +254,18 @@ class LLVM_LIBRARY_VISIBILITY SPIR32TargetInfo : public SPIRTargetInfo {
       : SPIRTargetInfo(Triple, Opts) {
     assert(Triple.getArch() == llvm::Triple::spir &&
            "Invalid architecture for 32-bit SPIR.");
-    // FIXME: Assert that a present host target's pointer types match the ones
-    // set below, once the driver diagnoses unsupported host/device combinations
-    // (until then such an assert would fire on existing tests).
     PointerWidth = PointerAlign = 32;
-    const TargetInfo *HostTarget = getHostTarget();
-    if (!HostTarget || HostTarget->getPointerWidth(LangAS::Default) != 32) {
+    if (!getHostTarget()) {
       SizeType = TargetInfo::UnsignedInt;
       PtrDiffType = IntPtrType = TargetInfo::SignedInt;
     }
 
+    // Host and device pointer related type widths must match.
+    assert(PointerWidth == 32 && PointerAlign == 32 &&
+           getTypeWidth(SizeType) == 32 && getTypeWidth(PtrDiffType) == 32 &&
+           getTypeWidth(IntPtrType) == 32 &&
+           "Invalid pointer related types for SPIR32");
----------------
schittir wrote:

That was a miss. Thanks for catching it. 

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


More information about the cfe-commits mailing list