aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 73a9cb9..0c447b2 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3952,8 +3952,20 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
// behavior may break ABI compatibility of the current unit.
if (const Module *M = F->getOwningModule();
M && M->getTopLevelModule()->isNamedModule() &&
- getContext().getCurrentNamedModule() != M->getTopLevelModule())
- return false;
+ getContext().getCurrentNamedModule() != M->getTopLevelModule()) {
+ // There are practices to mark template member function as always-inline
+ // and mark the template as extern explicit instantiation but not give
+ // the definition for member function. So we have to emit the function
+ // from explicitly instantiation with always-inline.
+ //
+ // See https://github.com/llvm/llvm-project/issues/86893 for details.
+ //
+ // TODO: Maybe it is better to give it a warning if we call a non-inline
+ // function from other module units which is marked as always-inline.
+ if (!F->isTemplateInstantiation() || !F->hasAttr<AlwaysInlineAttr>()) {
+ return false;
+ }
+ }
if (F->hasAttr<NoInlineAttr>())
return false;