From f2ea775ed9ec93ac5402d226d1841443555e5421 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Thu, 10 Apr 2014 18:13:13 +0000 Subject: 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. llvm-svn: 205977 --- clang/lib/CodeGen/CodeGenModule.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 2d87738..6ea60ba 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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::EmitGlobalFunctionDefinition(GlobalDecl GD, AddGlobalDtor(Fn, DA->getPriority()); if (D->hasAttr()) AddGlobalAnnotations(D, Fn); - - llvm::Function *PGOInit = CodeGenPGO::emitInitialization(*this); - if (PGOInit) - AddGlobalCtor(PGOInit, 0); } void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) { -- cgit v1.1