diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp --- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp @@ -286,9 +286,15 @@ void SampleProfileProber::instrumentOneFunc(Function &F, TargetMachine *TM) { Module *M = F.getParent(); MDBuilder MDB(F.getContext()); - // Compute a GUID without considering the function's linkage type. This is - // fine since function name is the only key in the profile database. - uint64_t Guid = Function::getGUID(F.getName()); + // Always use the name from debug info if it's avaiable. This is to be + // consistent with the probe name from the inline stack. + StringRef FName = F.getName(); + if (auto *SP = F.getSubprogram()) { + FName = SP->getLinkageName(); + if (FName.empty()) + FName = SP->getName(); + } + uint64_t Guid = Function::getGUID(FName); // Assign an artificial debug line to a probe that doesn't come with a real // line. A probe not having a debug line will get an incomplete inline