From 44eac33ae12df384f3f002102f919f603bee330f Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 13 Jul 2010 06:02:28 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108230 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index cb83ffde6f..bf606a6165 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -813,18 +813,27 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { Context.getSourceManager(), "Generating code for declaration"); - if (const CXXMethodDecl *Method = dyn_cast(D)) - if (Method->isVirtual()) - getVTables().EmitThunks(GD); + if (const FunctionDecl *Function = dyn_cast(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 CXXMethodDecl *Method = dyn_cast(D)) { + if (Method->isVirtual()) + getVTables().EmitThunks(GD); - if (const CXXConstructorDecl *CD = dyn_cast(D)) - return EmitCXXConstructor(CD, GD.getCtorType()); + if (const CXXConstructorDecl *CD = dyn_cast(Method)) + return EmitCXXConstructor(CD, GD.getCtorType()); - if (const CXXDestructorDecl *DD = dyn_cast(D)) - return EmitCXXDestructor(DD, GD.getDtorType()); + if (const CXXDestructorDecl *DD = dyn_cast(Method)) + return EmitCXXDestructor(DD, GD.getDtorType()); + } - if (isa(D)) return EmitGlobalFunctionDefinition(GD); + } if (const VarDecl *VD = dyn_cast(D)) return EmitGlobalVarDefinition(VD); -- cgit v1.2.3-70-g09d2