aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2025-05-09 11:42:04 -0700
committerAmir Ayupov <aaupov@fb.com>2025-05-09 11:42:04 -0700
commit4d1140d0763423380f6cfd7dac0a6a3c695c443b (patch)
treec4edd06561f6c2436fdba3f227bea21cb90cf239
parent54aa16d2934f0d57184ab203bc3a0f534501f508 (diff)
downloadllvm-users/aaupov/spr/bolttest-add-pseudo-probe-split-functest-1.zip
llvm-users/aaupov/spr/bolttest-add-pseudo-probe-split-functest-1.tar.gz
llvm-users/aaupov/spr/bolttest-add-pseudo-probe-split-functest-1.tar.bz2
Created using spr 1.3.4
-rw-r--r--bolt/test/X86/Inputs/pseudo-probe-split-func.c20
-rw-r--r--bolt/test/X86/pseudo-probe-split-func.test18
2 files changed, 38 insertions, 0 deletions
diff --git a/bolt/test/X86/Inputs/pseudo-probe-split-func.c b/bolt/test/X86/Inputs/pseudo-probe-split-func.c
new file mode 100644
index 0000000..3f0edb3
--- /dev/null
+++ b/bolt/test/X86/Inputs/pseudo-probe-split-func.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+int bar(int x, int y) {
+ if (x % 3) {
+ return x - y;
+ }
+ return x + y;
+}
+
+void foo() {
+ int s, i = 0;
+ while (i++ < 4000 * 4000)
+ if (i % 91) s = bar(i, s); else s += 30;
+ printf("sum is %d\n", s);
+}
+
+int main() {
+ foo();
+ return 0;
+}
diff --git a/bolt/test/X86/pseudo-probe-split-func.test b/bolt/test/X86/pseudo-probe-split-func.test
new file mode 100644
index 0000000..0bce3eb
--- /dev/null
+++ b/bolt/test/X86/pseudo-probe-split-func.test
@@ -0,0 +1,18 @@
+## This test checks if pseudo probes are present in split fragments
+RUN: %clang %cflags %p/Inputs/pseudo-probe-split-func.c -o %t \
+RUN: -O3 -fuse-ld=lld -fpseudo-probe-for-profiling -fno-omit-frame-pointer \
+RUN: -mno-omit-leaf-frame-pointer -g -Wl,-q
+## Test pseudo probe encoding when hot fragments are emitted before cold
+RUN: llvm-bolt %t -o %t.out -split-functions --split-strategy=all -lite=0
+RUN: llvm-profgen --binary=%t.out --perfscript=1 --output=%t.null \
+RUN: --show-disassembly-only --show-pseudo-probe | FileCheck %s
+## Test pseudo probe encoding when cold fragments are emitted before hot
+RUN: llvm-bolt %t -o %t.cold -split-functions --split-strategy=all -lite=0 \
+RUN: --hot-functions-at-end
+RUN: llvm-profgen --binary=%t.cold --perfscript=1 --output=%t.null \
+RUN: --show-disassembly-only --show-pseudo-probe | FileCheck %s
+CHECK: Disassembly of section .text.cold.3
+CHECK: <foo.cold.3>:
+CHECK: [Probe]: FUNC: foo Index: 8 Type: Block
+CHECK: <main.cold.3>:
+CHECK: [Probe]: FUNC: foo Index: 8 Type: Block Inlined: @ main:2