diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/ProfileData/InstrProf.h | 2 | ||||
| -rw-r--r-- | llvm/lib/ProfileData/InstrProf.cpp | 12 | ||||
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h index fde4b298f8e..88fc61a9a88 100644 --- a/llvm/include/llvm/ProfileData/InstrProf.h +++ b/llvm/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/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp index f1a6ce9854a..931282bc775 100644 --- a/llvm/lib/ProfileData/InstrProf.cpp +++ b/llvm/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/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index bf2933e8921..ff8e9b4d5b6 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/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); |

