[llvm-branch-commits] [llvm] [BOLT] Name similarity function matching (PR #95884)
Maksim Panchenko via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 27 14:45:42 PDT 2024
================
@@ -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
More information about the llvm-branch-commits
mailing list