[PATCH] D124117: [BOLT] Add fuzzy function name matching for LLVM LTO

Maksim Panchenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 17:00:56 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG76981fbcf622: [BOLT] Add fuzzy function name matching for LLVM LTO (authored by maksfb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124117/new/

https://reviews.llvm.org/D124117

Files:
  bolt/lib/Profile/DataReader.cpp
  bolt/test/X86/lto-name-match.s


Index: bolt/test/X86/lto-name-match.s
===================================================================
--- /dev/null
+++ bolt/test/X86/lto-name-match.s
@@ -0,0 +1,49 @@
+# REQUIRES: system-linux
+
+# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
+# RUN: link_fdata %s %t.o %t.fdata
+# RUN: llvm-strip --strip-unneeded %t.o
+# RUN: %clang %cflags %t.o -o %t.exe
+# RUN: llvm-bolt %t.exe -data %t.fdata -o /dev/null | FileCheck %s
+
+## Check that profile is correctly matched by functions with variable suffixes.
+## E.g., LTO-generated name foo.llvm.123 should match foo.llvm.*.
+
+# CHECK: 4 out of {{.*}} functions in the binary {{.*}} have non-empty execution profile
+# CHECK-NOT: profile for {{.*}} objects was ignored
+
+	.globl _start
+_start:
+
+LL_start_0:
+# FDATA: 1 _start #LL_start_0# 1 foo.llvm.321 0 0 1
+  call foo.llvm.123
+
+LL_start_1:
+# FDATA: 1 _start #LL_start_1# 1 foo.constprop.321 0 0 1
+  call foo.constprop.123
+
+LL_start_2:
+# FDATA: 1 _start #LL_start_2# 1 foo.lto_priv.321 0 0 1
+  call foo.lto_priv.123
+
+  call exit
+  .size _start, .-_start
+
+  .globl foo.llvm.123
+  .type foo.llvm.123, at function
+foo.llvm.123:
+  ret
+  .size foo.llvm.123, .-foo.llvm.123
+
+  .globl foo.constprop.123
+  .type foo.constprop.123, at function
+foo.constprop.123:
+  ret
+  .size foo.constprop.123, .-foo.constprop.123
+
+  .globl foo.lto_priv.123
+  .type foo.lto_priv.123, at function
+foo.lto_priv.123:
+  ret
+  .size foo.lto_priv.123, .-foo.lto_priv.123
Index: bolt/lib/Profile/DataReader.cpp
===================================================================
--- bolt/lib/Profile/DataReader.cpp
+++ bolt/lib/Profile/DataReader.cpp
@@ -47,6 +47,8 @@
     return Name.substr(0, LTOSuffixPos + 10);
   if ((LTOSuffixPos = Name.find(".constprop.")) != StringRef::npos)
     return Name.substr(0, LTOSuffixPos + 11);
+  if ((LTOSuffixPos = Name.find(".llvm.")) != StringRef::npos)
+    return Name.substr(0, LTOSuffixPos + 6);
   return NoneType();
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124117.424058.patch
Type: text/x-patch
Size: 1996 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220421/58a00560/attachment.bin>


More information about the llvm-commits mailing list