================
@@ -4461,8 +4461,14 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, 
llvm::GlobalValue *GV) {
     return EmitGlobalFunctionDefinition(GD, GV);
   }
 
-  if (const auto *VD = dyn_cast<VarDecl>(D))
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
+    if (VD->isStaticLocal() && !getContext().shouldExternalize(D)) {
----------------
Fznamznon wrote:

After my changes, I noticed one of CUDA tests failing. The only difference 
between old and new IR was that one of the variables was getting internal 
linkage with my changes. I found that CUDA device static variables used by host 
(stored in `CUDADeviceVarODRUsedByHost` field of ASTContext) are also put into 
`DeferredDeclsToEmit` and they were emitted as globals. I'm not really an 
expert in CUDA support, so I tried to preserve the old behavior. 
`shouldExternalize` seems like an appropriate way to detect the case.

https://github.com/llvm/llvm-project/pull/156933
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to