[clang] [clang][CUDA][HIP] Use host alignment for device definitions (PR #246922)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 1 12:59:45 PST 2026


================
@@ -1845,6 +1845,22 @@ const llvm::fltSemantics &ASTContext::getFloatTypeSemantics(QualType T) const {
   }
 }
 
+static const TargetInfo *
+getHostTargetForDeviceAlignment(const ASTContext &Context, const VarDecl *VD) {
+  if (!Context.getLangOpts().CUDAIsDevice || !VD || !VD->hasGlobalStorage())
+    return nullptr;
+  const TargetInfo *HostTarget = Context.getAuxTargetInfo();
+  if (!HostTarget)
+    return nullptr;
+
+  // Storage supplied by another object can have a different alignment.
----------------
yxsamliu wrote:

Thanks. The device now uses the host’s alignment for known definitions. This keeps both jobs in agreement when an alignment check affects a kernel argument’s layout.

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


More information about the cfe-commits mailing list