From 4cb42564ec4b56ef7eb4758bfa4ddf844a163687 Mon Sep 17 00:00:00 2001 From: "Yaxun (Sam) Liu" Date: Wed, 19 May 2021 15:44:20 -0400 Subject: [CUDA][HIP] Fix device variables used by host variables emitted on both host and device side with different addresses when ODR-used by host function should not cause device side counter-part to be force emitted. This fixes the regression caused by https://reviews.llvm.org/D102237 Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D102801 --- clang/lib/CodeGen/CodeGenModule.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 03920982ee08..8d1b2ea5d522 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2368,6 +2368,8 @@ void CodeGenModule::EmitDeferred() { } // Emit CUDA/HIP static device variables referenced by host code only. + // Note we should not clear CUDADeviceVarODRUsedByHost since it is still + // needed for further handling. if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) for (const auto *V : getContext().CUDADeviceVarODRUsedByHost) DeferredDeclsToEmit.push_back(V); -- cgit v1.2.3