summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-07-13 06:02:28 +0000
committerDouglas Gregor <dgregor@apple.com>2010-07-13 06:02:28 +0000
commita700f688282a1984164a2a95590eb39284fb4272 (patch)
tree448ba1a3af69e04737699b50b19d4e30683a6e32 /clang/lib/CodeGen/CodeGenModule.cpp
parent9b5561f4db6f5dad4e886083f94cf6479c852c26 (diff)
downloadbcm5719-llvm-a700f688282a1984164a2a95590eb39284fb4272.tar.gz
bcm5719-llvm-a700f688282a1984164a2a95590eb39284fb4272.zip
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index cb83ffde6f0..bf606a61658 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/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<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 CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
+ if (Method->isVirtual())
+ getVTables().EmitThunks(GD);
- if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
- return EmitCXXConstructor(CD, GD.getCtorType());
+ 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);
OpenPOWER on IntegriCloud