diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h --- a/llvm/include/llvm/ProfileData/SampleProf.h +++ b/llvm/include/llvm/ProfileData/SampleProf.h @@ -444,9 +444,9 @@ if (FS != iter->second.end()) return &FS->second; // If we cannot find exact match of the callee name, return the FS with - // the max total count. Only do this when CalleeName is not provided, + // the max total count. Only do this when CalleeName is not provided, // i.e., only for indirect calls. - if (!CalleeName.empty()) + if (!CalleeName.empty()) return nullptr; uint64_t MaxTotalSamples = 0; const FunctionSamples *R = nullptr; @@ -533,8 +533,7 @@ for (const auto &BS : BodySamples) for (const auto &TS : BS.second.getCallTargets()) if (TS.getValue() > Threshold) { - const Function *Callee = - M->getFunction(getNameInModule(TS.getKey(), M)); + const Function *Callee = M->getFunction(getFuncName(TS.getKey())); if (!Callee || !Callee->getSubprogram()) S.insert(getGUID(TS.getKey())); } @@ -549,10 +548,8 @@ /// Return the function name. StringRef getName() const { return Name; } - /// Return the original function name if it exists in Module \p M. - StringRef getFuncNameInModule(const Module *M) const { - return getNameInModule(Name, M); - } + /// Return the original function name. + StringRef getFuncName() const { return getFuncName(Name); } /// Return the canonical name for a function, taking into account /// suffix elision policy attributes. @@ -582,13 +579,14 @@ return F.getName(); } - /// Translate \p Name into its original name in Module. + /// Translate \p Name into its original name. /// When profile doesn't use MD5, \p Name needs no translation. /// When profile uses MD5, \p Name in current FunctionSamples - /// is actually GUID of the original function name. getNameInModule will - /// translate \p Name in current FunctionSamples into its original name. - /// If the original name doesn't exist in \p M, return empty StringRef. - StringRef getNameInModule(StringRef Name, const Module *M) const { + /// is actually GUID of the original function name. getFuncName will + /// translate \p Name in current FunctionSamples into its original name + /// by looking up in the function map GUIDToFuncNameMap. + /// If the original name doesn't exist in the map, return empty StringRef. + StringRef getFuncName(StringRef Name) const { if (!UseMD5) return Name; diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -944,7 +944,7 @@ for (auto I : Candidates) { Function *CalledFunction = I->getCalledFunction(); if (CalledFunction) { - ORE->emit(OptimizationRemarkAnalysis(CSINLINE_DEBUG, "InlineAttempt", + ORE->emit(OptimizationRemarkAnalysis(CSINLINE_DEBUG, "InlineAttempt", I->getDebugLoc(), I->getParent()) << "previous inlining reattempted for " << (Hot ? "hotness: '" : "size: '") @@ -1025,7 +1025,7 @@ PSI->getOrCompHotCountThreshold()); continue; } - auto CalleeFunctionName = FS->getFuncNameInModule(F.getParent()); + auto CalleeFunctionName = FS->getFuncName(); // If it is a recursive call, we do not inline it as it could bloat // the code exponentially. There is way to better handle this, e.g. // clone the caller first, and inline the cloned caller if it is