================ @@ -415,11 +423,116 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) { if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF)) matchProfileToFunction(YamlBF, *BF); + // Uses name similarity to match functions that were not matched by name. + uint64_t MatchedWithNameSimilarity = 0; + + if (opts::NameSimilarityFunctionMatchingThreshold > 0) { + ItaniumPartialDemangler ItaniumPartialDemangler; + + auto DemangleName = [&](std::string &FunctionName) { + StringRef RestoredName = NameResolver::restore(FunctionName); + return demangle(RestoredName); + }; + + auto DeriveNameSpace = [&](std::string &DemangledName) { + if (ItaniumPartialDemangler.partialDemangle(DemangledName.c_str())) + return std::string(""); + std::vector<char> Buffer(DemangledName.begin(), DemangledName.end()); + size_t BufferSize = Buffer.size(); + char *NameSpace = ItaniumPartialDemangler.getFunctionDeclContextName( + &Buffer[0], &BufferSize); + return NameSpace ? std::string(NameSpace) : std::string(""); + }; + + // Preprocessing YamlBFs to minimize the number of BFs to process. + std::unordered_map<std::string, std::set<uint32_t>> ---------------- maksfb wrote:
Can you use `StringMap` here? https://llvm.org/docs/ProgrammersManual.html#llvm-adt-stringmap-h https://github.com/llvm/llvm-project/pull/95884 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits