diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-12-09 16:01:03 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-12-09 16:01:03 +0000 |
commit | cd7743b5d1cbd0e3d2c77942c11799d3e0d1c320 (patch) | |
tree | a7e89de4f129e7e506bf90e68bbe5fcc83ebdf37 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 8283ba370409bd913d2b3e3275f3be8498c0d221 (diff) | |
download | bcm5719-llvm-cd7743b5d1cbd0e3d2c77942c11799d3e0d1c320.tar.gz bcm5719-llvm-cd7743b5d1cbd0e3d2c77942c11799d3e0d1c320.zip |
Save another call to GetAddrOfFunction.
Thread an optional GV down to EmitGlobalFunctionDefinition so that it can
avoid the lookup when we already know the corresponding llvm global value.
llvm-svn: 196789
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 583ee88bd6b..41f2c6c81fe 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1022,7 +1022,7 @@ void CodeGenModule::EmitDeferred() { continue; // Otherwise, emit the definition and move on to the next one. - EmitGlobalDefinition(D); + EmitGlobalDefinition(D, GV); } } @@ -1325,7 +1325,7 @@ void CodeGenModule::CompleteDIClassType(const CXXMethodDecl* D) { } } -void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { +void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) { const ValueDecl *D = cast<ValueDecl>(GD.getDecl()); PrettyStackTraceDecl CrashInfo(const_cast<ValueDecl *>(D), D->getLocation(), @@ -1347,7 +1347,7 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { else if (const CXXDestructorDecl *DD =dyn_cast<CXXDestructorDecl>(Method)) EmitCXXDestructor(DD, GD.getDtorType()); else - EmitGlobalFunctionDefinition(GD); + EmitGlobalFunctionDefinition(GD, GV); if (Method->isVirtual()) getVTables().EmitThunks(GD); @@ -1355,7 +1355,7 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { return; } - return EmitGlobalFunctionDefinition(GD); + return EmitGlobalFunctionDefinition(GD, GV); } if (const VarDecl *VD = dyn_cast<VarDecl>(D)) @@ -2091,7 +2091,8 @@ void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { EmitTopLevelDecl(VD); } -void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { +void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD, + llvm::GlobalValue *GV) { const FunctionDecl *D = cast<FunctionDecl>(GD.getDecl()); // Compute the function info and LLVM type. @@ -2100,7 +2101,8 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD) { // Get or create the prototype for the function. llvm::Constant *Entry = - GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer*/ true); + GV ? GV + : GetAddrOfFunction(GD, Ty, /*ForVTable=*/false, /*DontDefer*/ true); // Strip off a bitcast if we got one back. if (llvm::ConstantExpr *CE = dyn_cast<llvm::ConstantExpr>(Entry)) { |