From 8b2423361648c39a7d8a3c5e8129e12006deac32 Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 25 May 2010 04:30:21 +0000 Subject: If a function definition has any sort of weak linkage, its static local variables should have that linkage. Otherwise, its static local variables should have internal linkage. To avoid computing this excessively, set a function's linkage before we emit code for it. Previously we were assigning weak linkage to the static variables of static inline functions in C++, with predictably terrible results. This fixes that and also gives better linkage than 'weak' when merging is required. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104581 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 05c7a87e5f..2f8404e251 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -361,7 +361,6 @@ CodeGenModule::getFunctionLinkage(const FunctionDecl *D) { /// variables (these details are set in EmitGlobalVarDefinition for variables). void CodeGenModule::SetFunctionDefinitionAttributes(const FunctionDecl *D, llvm::GlobalValue *GV) { - GV->setLinkage(getFunctionLinkage(D)); SetCommonAttributes(D, GV); } @@ -1330,6 +1329,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { } llvm::Function *Fn = cast(Entry); + setFunctionLinkage(D, Fn); CodeGenFunction(*this).GenerateCode(D, Fn); -- cgit v1.2.3-18-g5258