diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp --- a/bolt/lib/Profile/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -42,13 +42,11 @@ namespace bolt { std::optional getLTOCommonName(const StringRef Name) { - size_t LTOSuffixPos = Name.find(".lto_priv."); - if (LTOSuffixPos != StringRef::npos) - 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); + for (StringRef Suffix : {".__uniq.", ".lto_priv.", ".constprop.", ".llvm."}) { + size_t LTOSuffixPos = Name.find(Suffix); + if (LTOSuffixPos != StringRef::npos) + return Name.substr(0, LTOSuffixPos + Suffix.size()); + } return std::nullopt; } diff --git a/bolt/test/X86/lto-name-match.s b/bolt/test/X86/lto-name-match.s --- a/bolt/test/X86/lto-name-match.s +++ b/bolt/test/X86/lto-name-match.s @@ -1,5 +1,3 @@ -# 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 @@ -9,7 +7,7 @@ ## 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: 6 out of {{.*}} functions in the binary {{.*}} have non-empty execution profile # CHECK-NOT: profile for {{.*}} objects was ignored .globl _start @@ -27,6 +25,14 @@ # FDATA: 1 _start #LL_start_2# 1 foo.lto_priv.321 0 0 1 call foo.lto_priv.123 +LL_start_3: +# FDATA: 1 _start #LL_start_3# 1 foo.__uniq.321 0 0 1 + call foo.__uniq.123 + +LL_start_4: +# FDATA: 1 _start #LL_start_4# 1 foo.__uniq.654.llvm.321 0 0 1 + call foo.__uniq.456.llvm.123 + call exit .size _start, .-_start @@ -47,3 +53,15 @@ foo.lto_priv.123: ret .size foo.lto_priv.123, .-foo.lto_priv.123 + + .globl foo.__uniq.123 + .type foo.__uniq.123,@function +foo.__uniq.123: + ret + .size foo.__uniq.123, .-foo.__uniq.123 + + .globl foo.__uniq.456.llvm.123 + .type foo.__uniq.456.llvm.123,@function +foo.__uniq.456.llvm.123: + ret + .size foo.__uniq.456.llvm.123, .-foo.__uniq.456.llvm.123