diff options
author | Amir Ayupov <aaupov@fb.com> | 2023-02-08 19:11:13 -0800 |
---|---|---|
committer | Amir Ayupov <aaupov@fb.com> | 2023-02-08 19:11:27 -0800 |
commit | c49941bd0d7f2a7a9ddbdce29fd584827d00dd06 (patch) | |
tree | c8dd9c2468d481c6d5e27e2f173395454716601a /bolt/test | |
parent | 061201ec3d6d78ca5d5a583eb9141623ea3f66e7 (diff) | |
download | llvm-c49941bd0d7f2a7a9ddbdce29fd584827d00dd06.tar.gz |
[BOLT] Process fragment siblings in lite mode, keep lite mode on
In lite mode, include split function fragments to the list of functions to
process even if a fragment has no samples. This is required to properly
detect and update split jump tables (jump tables that contain pointers to code
in the main and cold fragments).
Reviewed By: #bolt, maksfb
Differential Revision: https://reviews.llvm.org/D140457
Diffstat (limited to 'bolt/test')
-rw-r--r-- | bolt/test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | bolt/test/X86/fragment-lite-reverse.s | 81 | ||||
-rw-r--r-- | bolt/test/X86/fragment-lite.s | 151 | ||||
-rw-r--r-- | bolt/test/X86/split-func-icf.s | 2 | ||||
-rw-r--r-- | bolt/test/lit.cfg.py | 1 |
5 files changed, 235 insertions, 1 deletions
diff --git a/bolt/test/CMakeLists.txt b/bolt/test/CMakeLists.txt index 898ac3ee3b85..1c7814155bda 100644 --- a/bolt/test/CMakeLists.txt +++ b/bolt/test/CMakeLists.txt @@ -52,6 +52,7 @@ list(APPEND BOLT_TEST_DEPS merge-fdata not perf2bolt + split-file yaml2obj ) diff --git a/bolt/test/X86/fragment-lite-reverse.s b/bolt/test/X86/fragment-lite-reverse.s new file mode 100644 index 000000000000..3d681208d3e9 --- /dev/null +++ b/bolt/test/X86/fragment-lite-reverse.s @@ -0,0 +1,81 @@ +# Check that BOLT in lite mode processes fragments as expected. + +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o +# RUN: link_fdata %s %t.o %t.fdata +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.out --lite=1 --data %t.fdata -v=1 2>&1 \ +# RUN: | FileCheck %s + +# CHECK: BOLT-INFO: skipping processing main.cold.1 together with parent function +# CHECK: BOLT-INFO: skipping processing foo.cold.1/1 together with parent function +# CHECK: BOLT-INFO: skipping processing bar.cold.1/1 together with parent function + + .globl main + .type main, %function +main: + .cfi_startproc + cmpl $0x0, %eax + je main.cold.1 + retq + .cfi_endproc +.size main, .-main + + .globl foo + .type foo, %function +foo: + .cfi_startproc + cmpl $0x0, %eax + je foo.cold.1 + retq + .cfi_endproc +.size foo, .-foo + + .local bar + .type bar, %function +bar: + .cfi_startproc + cmpl $0x0, %eax + je bar.cold.1 + retq + .cfi_endproc +.size bar, .-bar + + .section .text.cold + .globl main.cold.1 + .type main.cold.1, %function +main.cold.1: +# FDATA: 0 [unknown] 0 1 main.cold.1 0 1 0 + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size main.cold.1, .-main.cold.1 + + .local foo.cold.1 + .type foo.cold.1, %function +foo.cold.1: +# FDATA: 0 [unknown] 0 1 foo.cold.1/1 0 1 0 + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size foo.cold.1, .-foo.cold.1 + + .local bar.cold.1 + .type bar.cold.1, %function +bar.cold.1: +# FDATA: 0 [unknown] 0 1 bar.cold.1/1 0 1 0 + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size bar.cold.1, .-bar.cold.1 diff --git a/bolt/test/X86/fragment-lite.s b/bolt/test/X86/fragment-lite.s new file mode 100644 index 000000000000..97069bf8096e --- /dev/null +++ b/bolt/test/X86/fragment-lite.s @@ -0,0 +1,151 @@ +# Check that BOLT in lite mode processes fragments as expected. + +# RUN: split-file %s %t +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/baz.s -o %t.baz.o +# RUN: link_fdata %s %t.o %t.main.fdata +# RUN: link_fdata %s %t.baz.o %t.baz.fdata +# RUN: merge-fdata %t.main.fdata %t.baz.fdata > %t.fdata +# RUN: %clang %cflags %t.o %t.baz.o -o %t.exe -Wl,-q +# RUN: llvm-bolt %t.exe -o %t.out --lite=1 --data %t.fdata -v=1 -print-cfg \ +# RUN: 2>&1 | FileCheck %s + +# CHECK: BOLT-INFO: processing main.cold.1 as a sibling of non-ignored function +# CHECK: BOLT-INFO: processing foo.cold.1/1 as a sibling of non-ignored function +# CHECK: BOLT-INFO: processing bar.cold.1/1 as a sibling of non-ignored function +# CHECK: BOLT-INFO: processing baz.cold.1 as a sibling of non-ignored function +# CHECK: BOLT-INFO: processing baz.cold.1/1 as a sibling of non-ignored function + +# CHECK: Binary Function "main.cold.1" after building cfg +# CHECK: Parent : main + +# CHECK: Binary Function "foo.cold.1/1" after building cfg +# CHECK: Parent : foo + +# CHECK: Binary Function "bar.cold.1/1" after building cfg +# CHECK: Parent : bar/1 + +# CHECK: Binary Function "baz.cold.1" after building cfg +# CHECK: Parent : baz{{$}} + +# CHECK: Binary Function "baz.cold.1/1" after building cfg +# CHECK: Parent : baz/1 + +#--- main.s + .globl main + .type main, %function +main: + .cfi_startproc +# FDATA: 0 [unknown] 0 1 main 0 1 0 + cmpl $0x0, %eax + je main.cold.1 + retq + .cfi_endproc +.size main, .-main + + .globl foo + .type foo, %function +foo: + .cfi_startproc +# FDATA: 0 [unknown] 0 1 foo 0 1 0 + cmpl $0x0, %eax + je foo.cold.1 + retq + .cfi_endproc +.size foo, .-foo + + .local bar + .type bar, %function +bar: + .cfi_startproc +# FDATA: 0 [unknown] 0 1 bar/1 0 1 0 + cmpl $0x0, %eax + je bar.cold.1 + retq + .cfi_endproc +.size bar, .-bar + + .globl baz + .type baz, %function +baz: + .cfi_startproc +# FDATA: 0 [unknown] 0 1 baz 0 1 0 + cmpl $0x0, %eax + je baz.cold.1 + retq + .cfi_endproc +.size baz, .-baz + + .section .text.cold + .globl main.cold.1 + .type main.cold.1, %function +main.cold.1: + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size main.cold.1, .-main.cold.1 + + .local foo.cold.1 + .type foo.cold.1, %function +foo.cold.1: + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size foo.cold.1, .-foo.cold.1 + + .local bar.cold.1 + .type bar.cold.1, %function +bar.cold.1: + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size bar.cold.1, .-bar.cold.1 + + .globl baz.cold.1 + .type baz.cold.1, %function +baz.cold.1: + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size baz.cold.1, .-baz.cold.1 + +#--- baz.s + .local baz + .type baz, %function +baz: + .cfi_startproc +# FDATA: 0 [unknown] 0 1 baz/1 0 1 0 + cmpl $0x0, %eax + je baz.cold.1 + retq + .cfi_endproc +.size baz, .-baz + + .section .text.cold + .local baz.cold.1 + .type baz.cold.1, %function +baz.cold.1: + .cfi_startproc + pushq %rbp + movq %rsp, %rbp + movl $0x0, %eax + popq %rbp + retq + .cfi_endproc +.size baz.cold.1, .-baz.cold.1 diff --git a/bolt/test/X86/split-func-icf.s b/bolt/test/X86/split-func-icf.s index eac4174fefd5..259c30186400 100644 --- a/bolt/test/X86/split-func-icf.s +++ b/bolt/test/X86/split-func-icf.s @@ -11,8 +11,8 @@ # RUN: llvm-bolt %t.exe -o %t.out -v=1 --print-only=main2.cold.1 --print-disasm 2>&1 | FileCheck %s # CHECK-NOT: unclaimed PC-relative relocations left in data -# CHECK-DAG: BOLT-INFO: marking main2.cold.1(*2) as a fragment of main # CHECK-DAG: BOLT-INFO: marking main2.cold.1(*2) as a fragment of main2 +# CHECK-DAG: BOLT-INFO: marking main2.cold.1(*2) as a fragment of main # CHECK: Binary Function "main2.cold.1(*2)" after disassembly # CHECK: End of Function "main2.cold.1(*2)" # CHECK-DAG: BOLT-WARNING: Ignoring main2 diff --git a/bolt/test/lit.cfg.py b/bolt/test/lit.cfg.py index 87d437c2277c..b5e15e20b1fe 100644 --- a/bolt/test/lit.cfg.py +++ b/bolt/test/lit.cfg.py @@ -93,6 +93,7 @@ tools = [ ToolSubst('merge-fdata', unresolved='fatal'), ToolSubst('llvm-readobj', unresolved='fatal'), ToolSubst('llvm-dwp', unresolved='fatal'), + ToolSubst('split-file', unresolved='fatal'), ] llvm_config.add_tool_substitutions(tools, tool_dirs) |