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. llvm-svn: 104581
This commit is contained in:
@@ -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<llvm::Function>(Entry);
|
||||
setFunctionLinkage(D, Fn);
|
||||
|
||||
CodeGenFunction(*this).GenerateCode(D, Fn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user