aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Interpreter/Interpreter.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/Interpreter/Interpreter.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/Interpreter/Interpreter.cpp')
-rw-r--r--clang/lib/Interpreter/Interpreter.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp
index 98fc0a5..ed3bae5 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -132,7 +132,8 @@ CreateCI(const llvm::opt::ArgStringList &Argv) {
"Initialization failed. "
"Target is missing");
- Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts());
+ Clang->getTarget().adjust(Clang->getDiagnostics(), Clang->getLangOpts(),
+ Clang->getAuxTarget());
// Don't clear the AST before backend codegen since we do codegen multiple
// times, reusing the same AST.