diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-03-12 05:13:59 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-03-12 05:13:59 +0000 | 
| commit | 539bc40906c36c142d678c7d6155cee904bc6a54 (patch) | |
| tree | 05f62cf5cc1aab2b85b0aa83362f98de6dc3f33a /clang/lib | |
| parent | 3c289673d6ce7740c426b2fada774b143f9210bc (diff) | |
| download | bcm5719-llvm-539bc40906c36c142d678c7d6155cee904bc6a54.tar.gz bcm5719-llvm-539bc40906c36c142d678c7d6155cee904bc6a54.zip  | |
Revert the linkage change for explicit template instantiations; something is amiss
llvm-svn: 98332
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 18 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 3 | 
2 files changed, 9 insertions, 12 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 7314dae8131..c67948d27f0 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -285,7 +285,8 @@ GetLinkageForFunction(ASTContext &Context, const FunctionDecl *FD,        break;      case TSK_ExplicitInstantiationDefinition: -      return CodeGenModule::GVA_ExplicitTemplateInstantiation; +      // FIXME: explicit instantiation definitions should use weak linkage +      return CodeGenModule::GVA_StrongExternal;      case TSK_ExplicitInstantiationDeclaration:      case TSK_ImplicitInstantiation: @@ -334,8 +335,7 @@ CodeGenModule::getFunctionLinkage(const FunctionDecl *D) {      // In C99 mode, 'inline' functions are guaranteed to have a strong      // definition somewhere else, so we can use available_externally linkage.      return llvm::Function::AvailableExternallyLinkage; -  } else if (Linkage == GVA_CXXInline || Linkage == GVA_TemplateInstantiation || -             Linkage == GVA_ExplicitTemplateInstantiation) { +  } else if (Linkage == GVA_CXXInline || Linkage == GVA_TemplateInstantiation) {      // In C++, the compiler has to emit a definition in every translation unit      // that references the function.  We should use linkonce_odr because      // a) if all references in this translation unit are optimized away, we @@ -589,7 +589,6 @@ bool CodeGenModule::MayDeferGeneration(const ValueDecl *Global) {      // static, static inline, always_inline, and extern inline functions can      // always be deferred.  Normal inline functions can be deferred in C99/C++. -    // Implicit template instantiations can also be deferred in C++.      if (Linkage == GVA_Internal || Linkage == GVA_C99Inline ||          Linkage == GVA_CXXInline || Linkage == GVA_TemplateInstantiation)        return true; @@ -1044,15 +1043,15 @@ GetLinkageForVariable(ASTContext &Context, const VarDecl *VD) {      switch (TSK) {      case TSK_Undeclared:      case TSK_ExplicitSpecialization: -      return CodeGenModule::GVA_StrongExternal; +      // FIXME: ExplicitInstantiationDefinition should be weak! +    case TSK_ExplicitInstantiationDefinition: +      return CodeGenModule::GVA_StrongExternal; +            case TSK_ExplicitInstantiationDeclaration:        llvm_unreachable("Variable should not be instantiated");        // Fall through to treat this like any other instantiation. -    case TSK_ExplicitInstantiationDefinition: -      return CodeGenModule::GVA_ExplicitTemplateInstantiation; -      case TSK_ImplicitInstantiation:        return CodeGenModule::GVA_TemplateInstantiation;            } @@ -1172,8 +1171,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D) {        GV->setLinkage(llvm::GlobalVariable::WeakODRLinkage);      else        GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage); -  } else if (Linkage == GVA_TemplateInstantiation ||  -             Linkage == GVA_ExplicitTemplateInstantiation) +  } else if (Linkage == GVA_TemplateInstantiation)      GV->setLinkage(llvm::GlobalVariable::WeakAnyLinkage);       else if (!getLangOptions().CPlusPlus && !CodeGenOpts.NoCommon &&             !D->hasExternalStorage() && !D->getInit() && diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 9077adedd0b..40dc5638898 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -437,8 +437,7 @@ public:      GVA_C99Inline,      GVA_CXXInline,      GVA_StrongExternal, -    GVA_TemplateInstantiation, -    GVA_ExplicitTemplateInstantiation +    GVA_TemplateInstantiation    };    llvm::GlobalVariable::LinkageTypes  | 

