r196789 - Save another call to GetAddrOfFunction.
Rafael Espindola
rafael.espindola at gmail.com
Mon Dec 9 08:01:04 PST 2013
Author: rafael
Date: Mon Dec 9 10:01:03 2013
New Revision: 196789
URL: http://llvm.org/viewvc/llvm-project?rev=196789&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=196789&r1=196788&r2=196789&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Dec 9 10:01:03 2013
@@ -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(
}
}
-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
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
return;
}
- return EmitGlobalFunctionDefinition(GD);
+ return EmitGlobalFunctionDefinition(GD, GV);
}
if (const VarDecl *VD = dyn_cast<VarDecl>(D))
@@ -2091,7 +2091,8 @@ void CodeGenModule::HandleCXXStaticMembe
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::EmitGlobalFunctionDe
// 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)) {
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=196789&r1=196788&r2=196789&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Dec 9 10:01:03 2013
@@ -1048,9 +1048,9 @@ private:
llvm::Function *F,
bool IsIncompleteFunction);
- void EmitGlobalDefinition(GlobalDecl D);
+ void EmitGlobalDefinition(GlobalDecl D, llvm::GlobalValue *GV = 0);
- void EmitGlobalFunctionDefinition(GlobalDecl GD);
+ void EmitGlobalFunctionDefinition(GlobalDecl GD, llvm::GlobalValue *GV);
void EmitGlobalVarDefinition(const VarDecl *D);
void EmitAliasDefinition(GlobalDecl GD);
void EmitObjCPropertyImplementations(const ObjCImplementationDecl *D);
More information about the cfe-commits
mailing list