| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,6 @@ | |
| #include <mutex> | ||
| #include <string> | ||
| #include <unordered_map> | ||
| #include <utility> | ||
| #include <vector> | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,6 @@ | |
|
|
||
| #include "bolt/Core/Linker.h" | ||
| #include "llvm/ADT/StringRef.h" | ||
| #include <vector> | ||
|
|
||
| namespace llvm { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| B 40164b 401608 109 0 | ||
| B 401611 4017e0 115 0 | ||
| B 4017f0 401616 117 0 | ||
| B 401ba2 4015da 6 0 | ||
| B 4015d5 401b60 1 0 | ||
| B 40159a 401b60 5 0 | ||
| B 401b9d 401b70 615 2 | ||
| B 401b90 401b99 344 37 | ||
| B 401ba2 40159f 8 0 | ||
| B 4015b0 401070 9 0 | ||
| B 401544 4014a0 6 0 | ||
| B 40188a 401928 5 0 | ||
| B 40152a 4014b0 21 0 | ||
| B 40169e 40165b 2 0 | ||
| B 4014dd 401070 12 1 | ||
| B 401509 4014ec 2 2 | ||
| B 401510 401030 673 0 | ||
| B 4019de 401080 1 0 | ||
| B 401500 401070 22 0 | ||
| B 401921 4014d6 9 0 | ||
| B 4019b3 401080 3 0 | ||
| B 40162d 401070 113 0 | ||
| B 4014d1 401800 27 0 | ||
| B 401a3f 401080 1 0 | ||
| B 4018d2 401050 17 0 | ||
| B 401664 4017c0 2 0 | ||
| B 401680 401070 2 0 | ||
| B 4017d0 401669 2 0 | ||
| B 4018f7 40190d 9 0 | ||
| B 4015bc 401592 6 0 | ||
| B 401964 401090 5 0 | ||
| B 4015f8 4015cd 1 0 | ||
| B 4015ec 401070 6 0 | ||
| F 40165b 401664 2 | ||
| F 4017c0 4017d0 2 | ||
| F 401669 401680 2 | ||
| F 40190d 401921 9 | ||
| F 4014d6 4014dd 9 | ||
| F 401800 4018d2 17 | ||
| F 4018d7 4018f7 9 | ||
| F 40159f 4015b0 8 | ||
| F 401515 401544 6 | ||
| F 401070 401500 1 | ||
| F 401070 401070 157 | ||
| F 4014a0 4014d1 6 | ||
| F 401616 40162d 112 | ||
| F 4019e3 401a3f 1 | ||
| F 4014e2 401500 19 | ||
| F 401090 401090 5 | ||
| F 401030 401030 673 | ||
| F 401505 401510 668 | ||
| F 401616 4017f0 2 | ||
| F 401070 4015b0 1 | ||
| F 4015da 4015ec 6 | ||
| F 401b60 401b90 6 | ||
| F 4019b8 4019de 1 | ||
| F 401969 4019b3 3 | ||
| F 401505 401509 2 | ||
| F 401515 40152a 21 | ||
| F 401592 40159a 4 | ||
| F 401050 401050 17 | ||
| F 4015cd 4015d5 1 | ||
| F 401070 4014dd 1 | ||
| F 401b99 401ba2 8 | ||
| F 401b70 401b90 326 | ||
| F 401b99 401b9d 324 | ||
| F 401592 4015bc 1 | ||
| F 401608 401611 109 | ||
| F 401b70 401b9d 268 | ||
| F 4015b5 4015bc 5 | ||
| F 401b99 401b90 1 | ||
| F 401b70 401ba2 5 | ||
| F 401632 40164b 108 | ||
| F 401080 401080 5 | ||
| F 4014b0 4014d1 21 | ||
| F 4017e0 4017f0 115 | ||
| F 4015f1 4015f8 1 | ||
| F 401685 40169e 2 | ||
| F 401928 401964 5 | ||
| F 401800 40188a 5 | ||
| F 4014ec 401500 2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| B 40169e 40165b 7 0 | ||
| B 401664 800012 7 0 | ||
| B 401680 401070 7 0 | ||
| B 800022 401669 7 0 | ||
| B 401611 800000 121 0 | ||
| B 40162d 401070 119 0 | ||
| B 4015d5 800040 2 0 | ||
| B 800080 4015da 6 0 | ||
| B 40164b 401608 115 0 | ||
| B 800080 40159f 24 0 | ||
| B 4015ec 401070 6 0 | ||
| B 8001d0 401090 1 0 | ||
| B 4014d1 800082 25 0 | ||
| B 401510 401030 616 0 | ||
| B 8002ab 401080 1 0 | ||
| B 80007b 80004c 483 1 | ||
| B 800072 80004c 597 77 | ||
| B 80010c 800194 1 0 | ||
| B 401509 4014ec 1 0 | ||
| B 800010 401616 119 0 | ||
| B 80024a 401080 1 0 | ||
| B 800154 401050 20 0 | ||
| B 4014dd 401070 9 0 | ||
| B 80021f 401080 1 0 | ||
| B 800193 4014d6 8 0 | ||
| B 40159a 800040 19 0 | ||
| B 4015f8 4015cd 2 0 | ||
| B 40152a 4014b0 24 0 | ||
| B 401500 401070 15 0 | ||
| B 4015bc 401592 21 0 | ||
| B 401544 4014a0 1 0 | ||
| B 80004a 800052 24 0 | ||
| B 4015b0 401070 20 0 | ||
| B 800050 80007d 29 29 | ||
| F 401685 40169e 7 | ||
| F 4014a0 4014d1 1 | ||
| F 401090 401090 1 | ||
| F 401050 401050 20 | ||
| F 40159f 4015b0 20 | ||
| F 80007d 800080 27 | ||
| F 401515 401544 1 | ||
| F 4014e2 401500 13 | ||
| F 401592 40159a 19 | ||
| F 401505 401509 1 | ||
| F 4014b0 4014d1 24 | ||
| F 800194 8001d0 1 | ||
| F 8001d5 80021f 1 | ||
| F 401616 40162d 114 | ||
| F 80024f 8002ab 1 | ||
| F 800159 800193 7 | ||
| F 80004c 800050 26 | ||
| F 800224 80024a 1 | ||
| F 800082 80010c 1 | ||
| F 401080 401080 3 | ||
| F 401070 401070 168 | ||
| F 80004c 800072 555 | ||
| F 401616 800010 2 | ||
| F 401070 40162d 4 | ||
| F 800082 800154 20 | ||
| F 401669 401680 7 | ||
| F 40159f 800080 1 | ||
| F 4014ec 401500 1 | ||
| F 800012 800022 7 | ||
| F 401030 401030 616 | ||
| F 80004c 80007b 473 | ||
| F 800052 800072 24 | ||
| F 800040 80004a 21 | ||
| F 4015b5 4015bc 18 | ||
| F 4015cd 4015d5 2 | ||
| F 401592 4015bc 1 | ||
| F 4015da 4015ec 6 | ||
| F 4015f1 4015f8 2 | ||
| F 800000 800010 116 | ||
| F 401608 401611 115 | ||
| F 401632 40164b 114 | ||
| F 401515 40152a 24 | ||
| F 40165b 401664 7 | ||
| F 401505 401510 612 | ||
| F 4014d6 4014dd 8 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Check new BAT format containing hashes for YAML profile. | ||
|
|
||
| RUN: yaml2obj %p/Inputs/blarge_new.yaml &> %t.exe | ||
| RUN: llvm-bolt %t.exe -o %t.out --pa -p %p/Inputs/blarge_new.preagg.txt \ | ||
| RUN: --reorder-blocks=ext-tsp --split-functions --split-strategy=cdsplit \ | ||
| RUN: --reorder-functions=cdsort --enable-bat --dyno-stats --skip-funcs=main \ | ||
| RUN: 2>&1 | FileCheck --check-prefix WRITE-BAT-CHECK %s | ||
| RUN: perf2bolt %t.out --pa -p %p/Inputs/blarge_new_bat.preagg.txt -w %t.yaml -o %t.fdata \ | ||
| RUN: 2>&1 | FileCheck --check-prefix READ-BAT-CHECK %s | ||
| RUN: FileCheck --input-file %t.yaml --check-prefix YAML-BAT-CHECK %s | ||
| # Check that YAML converted from fdata matches YAML created directly with BAT. | ||
| RUN: llvm-bolt %t.exe -data %t.fdata -w %t.yaml-fdata -o /dev/null | ||
| RUN: FileCheck --input-file %t.yaml-fdata --check-prefix YAML-BAT-CHECK %s | ||
|
|
||
| # Test resulting YAML profile with the original binary (no-stale mode) | ||
| RUN: llvm-bolt %t.exe -data %t.yaml -o %t.null -dyno-stats \ | ||
| RUN: | FileCheck --check-prefix CHECK-BOLT-YAML %s | ||
|
|
||
| WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps | ||
| WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes | ||
| WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384 | ||
|
|
||
| READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT | ||
| READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries | ||
| READ-BAT-CHECK: PERF2BOLT: read 79 aggregated LBR entries | ||
|
|
||
| YAML-BAT-CHECK: functions: | ||
| # Function not covered by BAT - has insns in basic block | ||
| YAML-BAT-CHECK: - name: main | ||
| YAML-BAT-CHECK-NEXT: fid: 2 | ||
| YAML-BAT-CHECK-NEXT: hash: 0x9895746D48B2C876 | ||
| YAML-BAT-CHECK-NEXT: exec: 0 | ||
| YAML-BAT-CHECK-NEXT: nblocks: 46 | ||
| YAML-BAT-CHECK-NEXT: blocks: | ||
| YAML-BAT-CHECK-NEXT: - bid: 0 | ||
| YAML-BAT-CHECK-NEXT: insns: 26 | ||
| YAML-BAT-CHECK-NEXT: hash: 0xA900AE79CFD40000 | ||
| YAML-BAT-CHECK-NEXT: succ: [ { bid: 3, cnt: 0 }, { bid: 1, cnt: 0 } ] | ||
| # Function covered by BAT with calls | ||
| YAML-BAT-CHECK: - name: SolveCubic | ||
| YAML-BAT-CHECK-NEXT: fid: [[#]] | ||
| YAML-BAT-CHECK-NEXT: hash: 0x6AF7E61EA3966722 | ||
| YAML-BAT-CHECK-NEXT: exec: 25 | ||
| YAML-BAT-CHECK-NEXT: nblocks: 15 | ||
| YAML-BAT-CHECK-NEXT: blocks: | ||
| YAML-BAT-CHECK: - bid: 3 | ||
| YAML-BAT-CHECK-NEXT: insns: [[#]] | ||
| YAML-BAT-CHECK-NEXT: hash: 0xDDA1DC5F69F900AC | ||
| YAML-BAT-CHECK-NEXT: calls: [ { off: 0x26, fid: [[#]], cnt: [[#]] } ] | ||
| YAML-BAT-CHECK-NEXT: succ: [ { bid: 5, cnt: [[#]] } | ||
| # Function covered by BAT - doesn't have insns in basic block | ||
| YAML-BAT-CHECK: - name: usqrt | ||
| YAML-BAT-CHECK-NEXT: fid: [[#]] | ||
| YAML-BAT-CHECK-NEXT: hash: 0x99E67ED32A203023 | ||
| YAML-BAT-CHECK-NEXT: exec: 21 | ||
| YAML-BAT-CHECK-NEXT: nblocks: 5 | ||
| YAML-BAT-CHECK-NEXT: blocks: | ||
| YAML-BAT-CHECK: - bid: 1 | ||
| YAML-BAT-CHECK-NEXT: insns: [[#]] | ||
| YAML-BAT-CHECK-NEXT: hash: 0xD70DC695320E0010 | ||
| YAML-BAT-CHECK-NEXT: succ: {{.*}} { bid: 2, cnt: [[#]] } | ||
|
|
||
| CHECK-BOLT-YAML: pre-processing profile using YAML profile reader | ||
| CHECK-BOLT-YAML-NEXT: 5 out of 16 functions in the binary (31.2%) have non-empty execution profile |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,263 @@ | ||
|
|
||
| # REQUIRES: system-linux | ||
|
|
||
| # RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o | ||
| # RUN: %clang %cflags -dwarf-4 %tmain.o -o %t.exe -Wl,-q | ||
| # RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections | ||
| # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s | ||
| # RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt > %t.txt | ||
| # RUN: llvm-objdump -d %t.bolt >> %t.txt | ||
| # RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s | ||
|
|
||
| ## This test checks that we correctly handle DW_AT_low_pc [DW_FORM_addr] that is part of DW_TAG_label. | ||
|
|
||
| # PRECHECK: version = 0x0004 | ||
| # PRECHECK: DW_TAG_label | ||
| # PRECHECK-NEXT: DW_AT_name | ||
| # PRECHECK-NEXT: DW_AT_decl_file | ||
| # PRECHECK-NEXT: DW_AT_decl_line | ||
| # PRECHECK-NEXT:DW_AT_low_pc [DW_FORM_addr] | ||
| # PRECHECK: DW_TAG_label | ||
| # PRECHECK-NEXT: DW_AT_name | ||
| # PRECHECK-NEXT: DW_AT_decl_file | ||
| # PRECHECK-NEXT: DW_AT_decl_line | ||
| # PRECHECK-NEXT:DW_AT_low_pc [DW_FORM_addr] | ||
|
|
||
| # POSTCHECK: version = 0x0004 | ||
| # POSTCHECK: DW_TAG_label | ||
| # POSTCHECK-NEXT: DW_AT_name | ||
| # POSTCHECK-NEXT: DW_AT_decl_file | ||
| # POSTCHECK-NEXT: DW_AT_decl_line | ||
| # POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addr] (0x[[ADDR:[1-9a-f]*]] | ||
| # POSTCHECK: DW_TAG_label | ||
| # POSTCHECK-NEXT: DW_AT_name | ||
| # POSTCHECK-NEXT: DW_AT_decl_file | ||
| # POSTCHECK-NEXT: DW_AT_decl_line | ||
| # POSTCHECK-NEXT:DW_AT_low_pc [DW_FORM_addr] (0x[[ADDR2:[1-9a-f]*]] | ||
|
|
||
| # POSTCHECK: [[ADDR]]: 8b 45 f8 | ||
| # POSTCHECK: [[ADDR2]]: 8b 45 f8 | ||
|
|
||
| ## clang++ main.cpp -g2 -gdwarf-4 -S | ||
| ## int main() { | ||
| ## int a = 4; | ||
| ## if (a == 5) | ||
| ## goto LABEL1; | ||
| ## else | ||
| ## goto LABEL2; | ||
| ## LABEL1:a++; | ||
| ## LABEL2:a--; | ||
| ## return 0; | ||
| ## } | ||
|
|
||
| .text | ||
| .file "main.cpp" | ||
| .globl main # -- Begin function main | ||
| .p2align 4, 0x90 | ||
| .type main,@function | ||
| main: # @main | ||
| .Lfunc_begin0: | ||
| .file 1 "/home" "main.cpp" | ||
| .loc 1 1 0 # main.cpp:1:0 | ||
| .cfi_startproc | ||
| # %bb.0: # %entry | ||
| pushq %rbp | ||
| .cfi_def_cfa_offset 16 | ||
| .cfi_offset %rbp, -16 | ||
| movq %rsp, %rbp | ||
| .cfi_def_cfa_register %rbp | ||
| movl $0, -4(%rbp) | ||
| .Ltmp0: | ||
| .loc 1 2 7 prologue_end # main.cpp:2:7 | ||
| movl $4, -8(%rbp) | ||
| .Ltmp1: | ||
| .loc 1 3 9 # main.cpp:3:9 | ||
| cmpl $5, -8(%rbp) | ||
| .Ltmp2: | ||
| .loc 1 3 7 is_stmt 0 # main.cpp:3:7 | ||
| jne .LBB0_2 | ||
| # %bb.1: # %if.then | ||
| .Ltmp3: | ||
| .loc 1 4 5 is_stmt 1 # main.cpp:4:5 | ||
| jmp .LBB0_3 | ||
| .LBB0_2: # %if.else | ||
| .loc 1 6 5 # main.cpp:6:5 | ||
| jmp .LBB0_4 | ||
| .Ltmp4: | ||
| .LBB0_3: # %LABEL1 | ||
| #DEBUG_LABEL: main:LABEL1 | ||
| .loc 1 7 11 # main.cpp:7:11 | ||
| movl -8(%rbp), %eax | ||
| addl $1, %eax | ||
| movl %eax, -8(%rbp) | ||
| .LBB0_4: # %LABEL2 | ||
| .Ltmp5: | ||
| #DEBUG_LABEL: main:LABEL2 | ||
| .loc 1 8 11 # main.cpp:8:11 | ||
| movl -8(%rbp), %eax | ||
| addl $-1, %eax | ||
| movl %eax, -8(%rbp) | ||
| .loc 1 9 3 # main.cpp:9:3 | ||
| xorl %eax, %eax | ||
| .loc 1 9 3 epilogue_begin is_stmt 0 # main.cpp:9:3 | ||
| popq %rbp | ||
| .cfi_def_cfa %rsp, 8 | ||
| retq | ||
| .Ltmp6: | ||
| .Lfunc_end0: | ||
| .size main, .Lfunc_end0-main | ||
| .cfi_endproc | ||
| # -- End function | ||
| .section .debug_abbrev,"",@progbits | ||
| .byte 1 # Abbreviation Code | ||
| .byte 17 # DW_TAG_compile_unit | ||
| .byte 1 # DW_CHILDREN_yes | ||
| .byte 37 # DW_AT_producer | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 19 # DW_AT_language | ||
| .byte 5 # DW_FORM_data2 | ||
| .byte 3 # DW_AT_name | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 16 # DW_AT_stmt_list | ||
| .byte 23 # DW_FORM_sec_offset | ||
| .byte 27 # DW_AT_comp_dir | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 17 # DW_AT_low_pc | ||
| .byte 1 # DW_FORM_addr | ||
| .byte 18 # DW_AT_high_pc | ||
| .byte 6 # DW_FORM_data4 | ||
| .byte 0 # EOM(1) | ||
| .byte 0 # EOM(2) | ||
| .byte 2 # Abbreviation Code | ||
| .byte 46 # DW_TAG_subprogram | ||
| .byte 1 # DW_CHILDREN_yes | ||
| .byte 17 # DW_AT_low_pc | ||
| .byte 1 # DW_FORM_addr | ||
| .byte 18 # DW_AT_high_pc | ||
| .byte 6 # DW_FORM_data4 | ||
| .byte 64 # DW_AT_frame_base | ||
| .byte 24 # DW_FORM_exprloc | ||
| .byte 3 # DW_AT_name | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 58 # DW_AT_decl_file | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 59 # DW_AT_decl_line | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 73 # DW_AT_type | ||
| .byte 19 # DW_FORM_ref4 | ||
| .byte 63 # DW_AT_external | ||
| .byte 25 # DW_FORM_flag_present | ||
| .byte 0 # EOM(1) | ||
| .byte 0 # EOM(2) | ||
| .byte 3 # Abbreviation Code | ||
| .byte 52 # DW_TAG_variable | ||
| .byte 0 # DW_CHILDREN_no | ||
| .byte 2 # DW_AT_location | ||
| .byte 24 # DW_FORM_exprloc | ||
| .byte 3 # DW_AT_name | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 58 # DW_AT_decl_file | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 59 # DW_AT_decl_line | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 73 # DW_AT_type | ||
| .byte 19 # DW_FORM_ref4 | ||
| .byte 0 # EOM(1) | ||
| .byte 0 # EOM(2) | ||
| .byte 4 # Abbreviation Code | ||
| .byte 10 # DW_TAG_label | ||
| .byte 0 # DW_CHILDREN_no | ||
| .byte 3 # DW_AT_name | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 58 # DW_AT_decl_file | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 59 # DW_AT_decl_line | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 17 # DW_AT_low_pc | ||
| .byte 1 # DW_FORM_addr | ||
| .byte 0 # EOM(1) | ||
| .byte 0 # EOM(2) | ||
| .byte 5 # Abbreviation Code | ||
| .byte 36 # DW_TAG_base_type | ||
| .byte 0 # DW_CHILDREN_no | ||
| .byte 3 # DW_AT_name | ||
| .byte 14 # DW_FORM_strp | ||
| .byte 62 # DW_AT_encoding | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 11 # DW_AT_byte_size | ||
| .byte 11 # DW_FORM_data1 | ||
| .byte 0 # EOM(1) | ||
| .byte 0 # EOM(2) | ||
| .byte 0 # EOM(3) | ||
| .section .debug_info,"",@progbits | ||
| .Lcu_begin0: | ||
| .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit | ||
| .Ldebug_info_start0: | ||
| .short 4 # DWARF version number | ||
| .long .debug_abbrev # Offset Into Abbrev. Section | ||
| .byte 8 # Address Size (in bytes) | ||
| .byte 1 # Abbrev [1] 0xb:0x6d DW_TAG_compile_unit | ||
| .long .Linfo_string0 # DW_AT_producer | ||
| .short 33 # DW_AT_language | ||
| .long .Linfo_string1 # DW_AT_name | ||
| .long .Lline_table_start0 # DW_AT_stmt_list | ||
| .long .Linfo_string2 # DW_AT_comp_dir | ||
| .quad .Lfunc_begin0 # DW_AT_low_pc | ||
| .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc | ||
| .byte 2 # Abbrev [2] 0x2a:0x46 DW_TAG_subprogram | ||
| .quad .Lfunc_begin0 # DW_AT_low_pc | ||
| .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc | ||
| .byte 1 # DW_AT_frame_base | ||
| .byte 86 | ||
| .long .Linfo_string3 # DW_AT_name | ||
| .byte 1 # DW_AT_decl_file | ||
| .byte 1 # DW_AT_decl_line | ||
| .long 112 # DW_AT_type | ||
| # DW_AT_external | ||
| .byte 3 # Abbrev [3] 0x43:0xe DW_TAG_variable | ||
| .byte 2 # DW_AT_location | ||
| .byte 145 | ||
| .byte 120 | ||
| .long .Linfo_string5 # DW_AT_name | ||
| .byte 1 # DW_AT_decl_file | ||
| .byte 2 # DW_AT_decl_line | ||
| .long 112 # DW_AT_type | ||
| .byte 4 # Abbrev [4] 0x51:0xf DW_TAG_label | ||
| .long .Linfo_string6 # DW_AT_name | ||
| .byte 1 # DW_AT_decl_file | ||
| .byte 7 # DW_AT_decl_line | ||
| .quad .Ltmp4 # DW_AT_low_pc | ||
| .byte 4 # Abbrev [4] 0x60:0xf DW_TAG_label | ||
| .long .Linfo_string7 # DW_AT_name | ||
| .byte 1 # DW_AT_decl_file | ||
| .byte 8 # DW_AT_decl_line | ||
| .quad .Ltmp5 # DW_AT_low_pc | ||
| .byte 0 # End Of Children Mark | ||
| .byte 5 # Abbrev [5] 0x70:0x7 DW_TAG_base_type | ||
| .long .Linfo_string4 # DW_AT_name | ||
| .byte 5 # DW_AT_encoding | ||
| .byte 4 # DW_AT_byte_size | ||
| .byte 0 # End Of Children Mark | ||
| .Ldebug_info_end0: | ||
| .section .debug_str,"MS",@progbits,1 | ||
| .Linfo_string0: | ||
| .asciz "clang version 19.0.0git" # string offset=0 | ||
| .Linfo_string1: | ||
| .asciz "main.cpp" # string offset=24 | ||
| .Linfo_string2: | ||
| .asciz "/home" # string offset=33 | ||
| .Linfo_string3: | ||
| .asciz "main" # string offset=71 | ||
| .Linfo_string4: | ||
| .asciz "int" # string offset=76 | ||
| .Linfo_string5: | ||
| .asciz "a" # string offset=80 | ||
| .Linfo_string6: | ||
| .asciz "LABEL1" # string offset=82 | ||
| .Linfo_string7: | ||
| .asciz "LABEL2" # string offset=89 | ||
| .ident "clang version 19.0.0git" | ||
| .section ".note.GNU-stack","",@progbits | ||
| .addrsig | ||
| .section .debug_line,"",@progbits | ||
| .Lline_table_start0: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # REQUIRES: system-linux | ||
|
|
||
| ## Check that BOLT correctly updates the Linux kernel static keys jump table. | ||
|
|
||
| # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o | ||
| # RUN: %clang %cflags -nostdlib %t.o -o %t.exe \ | ||
| # RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr | ||
|
|
||
| ## Verify static keys jump bindings to instructions. | ||
|
|
||
| # RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \ | ||
| # RUN: --bolt-info=0 |& FileCheck %s | ||
|
|
||
| ## Verify the bindings again on the rewritten binary with nops removed. | ||
|
|
||
| # RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s | ||
|
|
||
| # CHECK: BOLT-INFO: Linux kernel binary detected | ||
| # CHECK: BOLT-INFO: parsed 2 static keys jump entries | ||
|
|
||
| .text | ||
| .globl _start | ||
| .type _start, %function | ||
| _start: | ||
| # CHECK: Binary Function "_start" | ||
| nop | ||
| .L0: | ||
| jmp .L1 | ||
| # CHECK: jit | ||
| # CHECK-SAME: # ID: 1 {{.*}} # Likely: 0 # InitValue: 1 | ||
| nop | ||
| .L1: | ||
| .nops 5 | ||
| # CHECK: jit | ||
| # CHECK-SAME: # ID: 2 {{.*}} # Likely: 1 # InitValue: 1 | ||
| .L2: | ||
| nop | ||
| .size _start, .-_start | ||
|
|
||
| .globl foo | ||
| .type foo, %function | ||
| foo: | ||
| ret | ||
| .size foo, .-foo | ||
|
|
||
|
|
||
| ## Static keys jump table. | ||
| .rodata | ||
| .globl __start___jump_table | ||
| .type __start___jump_table, %object | ||
| __start___jump_table: | ||
|
|
||
| .long .L0 - . # Jump address | ||
| .long .L1 - . # Target address | ||
| .quad 1 # Key address | ||
|
|
||
| .long .L1 - . # Jump address | ||
| .long .L2 - . # Target address | ||
| .quad 0 # Key address | ||
|
|
||
| .globl __stop___jump_table | ||
| .type __stop___jump_table, %object | ||
| __stop___jump_table: | ||
|
|
||
| ## Fake Linux Kernel sections. | ||
| .section __ksymtab,"a",@progbits | ||
| .section __ksymtab_gpl,"a",@progbits |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| # This reproduces a bug with BOLT setting incorrect discriminator for | ||
| # secondary entry points in YAML profile. | ||
|
|
||
| # 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 -Wl,-q -nostdlib | ||
| # RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata -w %t.yaml --print-profile \ | ||
| # RUN: --print-only=main | FileCheck %s --check-prefix=CHECK-CFG | ||
| # RUN: FileCheck %s -input-file %t.yaml | ||
| # CHECK: - name: main | ||
| # CHECK-NEXT: fid: 2 | ||
| # CHECK-NEXT: hash: 0xADF270D550151185 | ||
| # CHECK-NEXT: exec: 0 | ||
| # CHECK-NEXT: nblocks: 4 | ||
| # CHECK-NEXT: blocks: | ||
| # CHECK: - bid: 1 | ||
| # CHECK-NEXT: insns: 1 | ||
| # CHECK-NEXT: hash: 0x36A303CBA4360014 | ||
| # CHECK-NEXT: calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1 } ] | ||
| # CHECK: - bid: 2 | ||
| # CHECK-NEXT: insns: 5 | ||
| # CHECK-NEXT: hash: 0x8B2F5747CD0019 | ||
| # CHECK-NEXT: calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1, mis: 1 } ] | ||
|
|
||
| # Make sure that the profile is attached correctly | ||
| # RUN: llvm-bolt %t.exe -o %t.out --data %t.yaml --print-profile \ | ||
| # RUN: --print-only=main | FileCheck %s --check-prefix=CHECK-CFG | ||
|
|
||
| # CHECK-CFG: Binary Function "main" after attaching profile { | ||
| # CHECK-CFG: callq secondary_entry # Offset: [[#]] # Count: 1 | ||
| # CHECK-CFG: callq *%rax # Offset: [[#]] # CallProfile: 1 (1 misses) : | ||
| # CHECK-CFG-NEXT: { secondary_entry: 1 (1 misses) } | ||
|
|
||
| .globl func | ||
| .type func, @function | ||
| func: | ||
| # FDATA: 0 [unknown] 0 1 func 0 1 0 | ||
| .cfi_startproc | ||
| pushq %rbp | ||
| movq %rsp, %rbp | ||
| .globl secondary_entry | ||
| secondary_entry: | ||
| popq %rbp | ||
| retq | ||
| nopl (%rax) | ||
| .cfi_endproc | ||
| .size func, .-func | ||
|
|
||
| .globl main | ||
| .type main, @function | ||
| main: | ||
| .cfi_startproc | ||
| pushq %rbp | ||
| movq %rsp, %rbp | ||
| subq $16, %rsp | ||
| movl $0, -4(%rbp) | ||
| testq %rax, %rax | ||
| jne Lindcall | ||
| Lcall: | ||
| call secondary_entry | ||
| # FDATA: 1 main #Lcall# 1 secondary_entry 0 1 1 | ||
| Lindcall: | ||
| callq *%rax | ||
| # FDATA: 1 main #Lindcall# 1 secondary_entry 0 1 1 | ||
| xorl %eax, %eax | ||
| addq $16, %rsp | ||
| popq %rbp | ||
| retq | ||
| # For relocations against .text | ||
| call exit | ||
| .cfi_endproc | ||
| .size main, .-main |