r205977 - CodeGen: Move PGO initialization into Release()
Justin Bogner
mail at justinbogner.com
Thu Apr 10 11:13:13 PDT 2014
Author: bogner
Date: Thu Apr 10 13:13:13 2014
New Revision: 205977
URL: http://llvm.org/viewvc/llvm-project?rev=205977&view=rev
Log:
CodeGen: Move PGO initialization into Release()
Emitting the PGO initialization in EmitGlobalFunctionDefinition is
inefficient, since this only has an effect once per module. We move
this to Release() with the rest of the once-per-module logic.
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=205977&r1=205976&r2=205977&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Apr 10 13:13:13 2014
@@ -283,6 +283,9 @@ void CodeGenModule::Release() {
if (ObjCRuntime)
if (llvm::Function *ObjCInitFunction = ObjCRuntime->ModuleInitFunction())
AddGlobalCtor(ObjCInitFunction);
+ if (getCodeGenOpts().ProfileInstrGenerate)
+ if (llvm::Function *PGOInit = CodeGenPGO::emitInitialization(*this))
+ AddGlobalCtor(PGOInit, 0);
EmitCtorList(GlobalCtors, "llvm.global_ctors");
EmitCtorList(GlobalDtors, "llvm.global_dtors");
EmitGlobalAnnotations();
@@ -2218,10 +2221,6 @@ void CodeGenModule::EmitGlobalFunctionDe
AddGlobalDtor(Fn, DA->getPriority());
if (D->hasAttr<AnnotateAttr>())
AddGlobalAnnotations(D, Fn);
-
- llvm::Function *PGOInit = CodeGenPGO::emitInitialization(*this);
- if (PGOInit)
- AddGlobalCtor(PGOInit, 0);
}
void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=205977&r1=205976&r2=205977&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Thu Apr 10 13:13:13 2014
@@ -294,9 +294,8 @@ llvm::Function *CodeGenPGO::emitInitiali
if (!CGM.getCodeGenOpts().ProfileInstrGenerate)
return nullptr;
- // Only need to create this once per module.
- if (CGM.getModule().getFunction("__llvm_profile_init"))
- return nullptr;
+ assert(CGM.getModule().getFunction("__llvm_profile_init") == nullptr &&
+ "profile initialization already emitted");
// Get the function to call at initialization.
llvm::Constant *RegisterF = getRegisterFunc(CGM);
More information about the cfe-commits
mailing list