From 7ce1f2714ac0f33210bab14650bce2078ebf343e Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 12 Jul 2010 17:24:55 +0000 Subject: Do not generate LLVM IR for available_externally function bodies at -O0, since we won't be using the definitions for anything anyway. For lib/System/Path.o when built in Debug+Asserts mode, this leads to a 4% improvement in compile time (and suppresses 440 function bodies). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108156 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index cb83ffde6f..d544d4c233 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -817,14 +817,22 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { if (Method->isVirtual()) getVTables().EmitThunks(GD); - if (const CXXConstructorDecl *CD = dyn_cast(D)) - return EmitCXXConstructor(CD, GD.getCtorType()); + 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 CXXConstructorDecl *CD = dyn_cast(Function)) + return EmitCXXConstructor(CD, GD.getCtorType()); - if (const CXXDestructorDecl *DD = dyn_cast(D)) - return EmitCXXDestructor(DD, GD.getDtorType()); + if (const CXXDestructorDecl *DD = dyn_cast(Function)) + 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-18-g5258