aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorYaxun (Sam) Liu <yaxun.liu@amd.com>2025-07-09 08:53:10 -0400
committerGitHub <noreply@github.com>2025-07-09 08:53:10 -0400
commitbeea2a941470368a87b1816e455b1db366c1bbb9 (patch)
tree27495310517cfe9c2a1a5b40b02acdae8e24cece /clang/lib/Frontend/ASTUnit.cpp
parentab187bbd3a5c64451846aa3480f271a93dfba760 (diff)
downloadllvm-beea2a941470368a87b1816e455b1db366c1bbb9.zip
llvm-beea2a941470368a87b1816e455b1db366c1bbb9.tar.gz
llvm-beea2a941470368a87b1816e455b1db366c1bbb9.tar.bz2
[Clang] Respect MS layout attributes during CUDA/HIP device compilation (#146620)
This patch fixes an issue where Microsoft-specific layout attributes, such as __declspec(empty_bases), were ignored during CUDA/HIP device compilation on a Windows host. This caused a critical memory layout mismatch between host and device objects, breaking libraries that rely on these attributes for ABI compatibility. The fix introduces a centralized hasMicrosoftRecordLayout() check within the TargetInfo class. This check is aware of the auxiliary (host) target and is set during TargetInfo::adjust if the host uses a Microsoft ABI. The empty_bases, layout_version, and msvc::no_unique_address attributes now use this centralized flag, ensuring device code respects them and maintains layout consistency with the host. Fixes: https://github.com/llvm/llvm-project/issues/146047
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 4ebec8e..b7f52fd 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -631,7 +631,7 @@ private:
//
// FIXME: We shouldn't need to do this, the target should be immutable once
// created. This complexity should be lifted elsewhere.
- Target->adjust(PP.getDiagnostics(), LangOpt);
+ Target->adjust(PP.getDiagnostics(), LangOpt, /*AuxTarget=*/nullptr);
// Initialize the preprocessor.
PP.Initialize(*Target);