[llvm] Added feature in llvm-profdata merge to filter functions from the profile (PR #78378)

David Li via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 10:52:35 PST 2024


================
@@ -760,6 +767,45 @@ static void mergeWriterContexts(WriterContext *Dst, WriterContext *Src) {
   });
 }
 
+static StringRef
+getFuncName(const StringMap<InstrProfWriter::ProfilingData>::value_type &Val) {
+  return Val.first();
+}
+
+static std::string
+getFuncName(const SampleProfileMap::value_type &Val) {
+  return Val.second.getContext().toString();
+}
+
+template <typename T>
+static void filterFunctions(T &ProfileMap) {
+  bool hasFilter = !FuncNameFilter.empty();
+  bool hasNegativeFilter = !FuncNameNegativeFilter.empty();
+  if (hasFilter || hasNegativeFilter) {
----------------
david-xl wrote:

Use early return to avoid the nesting.

https://github.com/llvm/llvm-project/pull/78378


More information about the llvm-commits mailing list