From efee6b3938476cec2e386d83af0899611734753e Mon Sep 17 00:00:00 2001 From: Rong Xu Date: Fri, 22 Apr 2016 21:00:17 +0000 Subject: [PATCH] [PGO] change the interface for createPGOFuncNameMetadata() This patch changes the interface for createPGOFuncNameMetadata() where we add another PGOFuncName argument. Differential Revision: http://reviews.llvm.org/D19433 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267216 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ProfileData/InstrProf.h | 2 +- lib/ProfileData/InstrProf.cpp | 12 +++++++----- lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/llvm/ProfileData/InstrProf.h b/include/llvm/ProfileData/InstrProf.h index fde4b298f8e..88fc61a9a88 100644 --- a/include/llvm/ProfileData/InstrProf.h +++ b/include/llvm/ProfileData/InstrProf.h @@ -253,7 +253,7 @@ MDNode *getPGOFuncNameMetadata(const Function &F); /// Create the PGOFuncName meta data if PGOFuncName is different from /// function's raw name. This should only apply to internal linkage functions /// declared by users only. -void createPGOFuncNameMetadata(Function &F); +void createPGOFuncNameMetadata(Function &F, const std::string &PGOFuncName); const std::error_category &instrprof_category(); diff --git a/lib/ProfileData/InstrProf.cpp b/lib/ProfileData/InstrProf.cpp index f1a6ce9854a..931282bc775 100644 --- a/lib/ProfileData/InstrProf.cpp +++ b/lib/ProfileData/InstrProf.cpp @@ -732,13 +732,15 @@ MDNode *getPGOFuncNameMetadata(const Function &F) { return F.getMetadata(getPGOFuncNameMetadataName()); } -void createPGOFuncNameMetadata(Function &F) { - const std::string &FuncName = getPGOFuncName(F); - if (FuncName == F.getName()) +void createPGOFuncNameMetadata(Function &F, const std::string &PGOFuncName) { + // Only for internal linkage functions. + if (PGOFuncName == F.getName()) + return; + // Don't create duplicated meta-data. + if (getPGOFuncNameMetadata(F)) return; - LLVMContext &C = F.getContext(); - MDNode *N = MDNode::get(C, MDString::get(C, FuncName.c_str())); + MDNode *N = MDNode::get(C, MDString::get(C, PGOFuncName.c_str())); F.setMetadata(getPGOFuncNameMetadataName(), N); } diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index bf2933e8921..ff8e9b4d5b6 100644 --- a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -732,7 +732,7 @@ void PGOUseFunc::annotateIndirectCallSites() { return; // Create the PGOFuncName meta data. - createPGOFuncNameMetadata(F); + createPGOFuncNameMetadata(F, FuncInfo.FuncName); unsigned IndirectCallSiteIndex = 0; auto IndirectCallSites = findIndirectCallSites(F); -- 2.11.0