aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.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/CompilerInstance.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/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 09a66b6..6f8cc01 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -148,7 +148,7 @@ bool CompilerInstance::createTarget() {
// Inform the target of the language options.
// FIXME: We shouldn't need to do this, the target should be immutable once
// created. This complexity should be lifted elsewhere.
- getTarget().adjust(getDiagnostics(), getLangOpts());
+ getTarget().adjust(getDiagnostics(), getLangOpts(), getAuxTarget());
if (auto *Aux = getAuxTarget())
getTarget().setAuxTarget(Aux);
@@ -454,7 +454,7 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
getSourceManager(), *HeaderInfo, *this,
/*IdentifierInfoLookup=*/nullptr,
/*OwnsHeaderSearch=*/true, TUKind);
- getTarget().adjust(getDiagnostics(), getLangOpts());
+ getTarget().adjust(getDiagnostics(), getLangOpts(), getAuxTarget());
PP->Initialize(getTarget(), getAuxTarget());
if (PPOpts.DetailedRecord)