Reinstate the optimization suppressing available_externally functions

at -O0. The only change from the previous patch is that we don't try
to generate virtual method thunks for an available_externally
function.

llvm-svn: 108230
This commit is contained in:
Douglas Gregor
2010-07-13 06:02:28 +00:00
parent 9b5561f4db
commit a700f68828
7 changed files with 37 additions and 16 deletions

View File

@@ -813,18 +813,27 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
Context.getSourceManager(),
"Generating code for declaration");
if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
if (Method->isVirtual())
getVTables().EmitThunks(GD);
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
// At -O0, don't generate IR for functions with available_externally
// linkage.
if (CodeGenOpts.OptimizationLevel == 0 &&
getFunctionLinkage(Function)
== llvm::Function::AvailableExternallyLinkage)
return;
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
return EmitCXXConstructor(CD, GD.getCtorType());
if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
if (Method->isVirtual())
getVTables().EmitThunks(GD);
if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
return EmitCXXConstructor(CD, GD.getCtorType());
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))
return EmitCXXDestructor(DD, GD.getDtorType());
if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(Method))
return EmitCXXDestructor(DD, GD.getDtorType());
}
if (isa<FunctionDecl>(D))
return EmitGlobalFunctionDefinition(GD);
}
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
return EmitGlobalVarDefinition(VD);