[clang] [clang][CodeGen] Emit referenced __device__ definitions across incremental modules (PR #218784)

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 28 08:32:39 PDT 2026


================
@@ -5752,6 +5752,13 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
           }
         }
       }
+      if (LangOpts.IncrementalExtensions && LangOpts.CUDAIsDevice) {
+        const auto *FD = cast<FunctionDecl>(D);
+        if (const FunctionDecl *Def = FD->getDefinition();
+            Def && Def->hasBody() &&
+            (Def->isInlined() || Def->getFormalLinkage() == Linkage::Internal))
----------------
yxsamliu wrote:

This uses source-level `inline` and formal linkage, while the existing incremental logic uses the actual LLVM linkage: internal, linkonce, or weak. These can differ for templates and weak functions. Could this reuse the existing linkage rule and explain why the current `DeferredDecls` path does not handle this case?

https://github.com/llvm/llvm-project/pull/218784


More information about the cfe-commits mailing list