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 | 1befc8f8e0d108ee43d3c7e738f6920f064d2181 (patch) | |
tree | f23dfefe434ecdd6f183a59517cdd362df2c11a2 /lib/CodeGen/CodeGenModule.cpp | |
parent | 9c8da1b492c33dce3367c7edd3d3bcf1560535e9 (diff) | |
download | clang-1befc8f8e0d108ee43d3c7e738f6920f064d2181.tar.gz clang-1befc8f8e0d108ee43d3c7e738f6920f064d2181.tar.bz2 clang-1befc8f8e0d108ee43d3c7e738f6920f064d2181.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196789 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 583ee88bd6..41f2c6c81f 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/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)) { |