namespace bolt {
std::optional<StringRef> 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;
}
-# 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
## 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
# 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
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