================
@@ -164,6 +164,18 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public 
TargetInfo {
       UseExplicitBitFieldAlignment = 
HostTarget->useExplicitBitFieldAlignment();
       ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary();
 
+      // Copy pointer-related type representations from host so that
+      // sizeof(size_t), sizeof(ptrdiff_t), sizeof(intptr_t) match
+      // between host and device. Without this, LLP64 hosts (Windows)
+      // get incorrect LP64-style defaults.
+      SizeType = HostTarget->getSizeType();
+      PtrDiffType = HostTarget->getPtrDiffType(LangAS::Default);
+      IntPtrType = HostTarget->getIntPtrType();
----------------
tahonermann wrote:

Is there any reason not to assign `PointerWidth` and `PointerAlign` to match 
the host here? It is a little odd that we're setting expectations for pointer 
related types but not setting the pointer type itself. If we do so here, then I 
think we can avoid introducing `SPIRVPhysicalTargetInfo` and can instead assert 
expected sizes in the explicitly 32-bit/64-bit derived targets when the host 
target is known. That would avoid the `assert(this || that)` logic in 
`SPIRVPhysicalTargetInfo` and reduce the size of the diff. It seems likely that 
we'll want to restrict OS support to specific memory models at some point too. 
For example, we might restrict Level Zero to SPIR-V64 and therefore want 
different assertions.

https://github.com/llvm/llvm-project/pull/208196
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to