brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 5d6e291 Raw
146 lines · plain
1## This reproduces a bug with BOLT setting incorrect discriminator for2## secondary entry points in YAML profile.3 4# REQUIRES: system-linux5# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o6# RUN: link_fdata %s %t.o %t.fdata7# RUN: llvm-strip --strip-unneeded %t.o8# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib9# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata -w %t.yaml --print-profile \10# RUN:   --print-only=main | FileCheck %s --check-prefix=CHECK-CFG11# RUN: FileCheck %s -input-file %t.yaml12# CHECK:      - name:    main13# CHECK-NEXT:   fid:     214# CHECK-NEXT:   hash:    {{.*}}15# CHECK-NEXT:   exec:    016# CHECK-NEXT:   nblocks: 417# CHECK-NEXT:   blocks:18# CHECK:          - bid:   119# CHECK-NEXT:       insns: 120# CHECK-NEXT:       hash:  {{.*}}21# CHECK-NEXT:       calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1 } ]22# CHECK:          - bid:   223# CHECK-NEXT:       insns: 524# CHECK-NEXT:       hash:  {{.*}}25# CHECK-NEXT:       calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1, mis: 1 } ]26 27## Make sure that the profile is attached correctly28# RUN: llvm-bolt %t.exe -o %t.out --data %t.yaml --print-profile \29# RUN:   --print-only=main | FileCheck %s --check-prefix=CHECK-CFG30 31# CHECK-CFG: Binary Function "main" after attaching profile {32# CHECK-CFG:      callq secondary_entry # Offset: [[#]] # Count: 133# CHECK-CFG:      callq *%rax # Offset: [[#]] # CallProfile: 1 (1 misses) :34# CHECK-CFG-NEXT:     { secondary_entry: 1 (1 misses) }35 36## YAML BAT test of calling BAT secondary entry from non-BAT function37## Now force-split func and skip main (making it call secondary entries)38# RUN: llvm-bolt %t.exe -o %t.bat --data %t.fdata --funcs=func \39# RUN:   --split-functions --split-strategy=all --split-all-cold --enable-bat40 41## Prepare pre-aggregated profile using %t.bat42# RUN: link_fdata %s %t.bat %t.preagg PREAGG43## Strip labels used for pre-aggregated profile44# RUN: llvm-strip -NLcall -NLindcall %t.bat45 46## Convert pre-aggregated profile using BAT47# RUN: perf2bolt %t.bat -p %t.preagg --pa -o %t.bat.fdata -w %t.bat.yaml48 49## Convert BAT fdata into YAML50# RUN: llvm-bolt %t.exe -data %t.bat.fdata -w %t.bat.fdata-yaml -o /dev/null51 52## Check fdata YAML - make sure that a direct call has discriminator field53# RUN: FileCheck %s --input-file %t.bat.fdata-yaml -check-prefix CHECK-BAT-YAML54 55## Check BAT YAML - make sure that a direct call has discriminator field56# RUN: FileCheck %s --input-file %t.bat.yaml --check-prefix CHECK-BAT-YAML57 58## YAML BAT test of calling BAT secondary entry from BAT function59# RUN: llvm-bolt %t.exe -o %t.bat2 --data %t.fdata --funcs=main,func \60# RUN:   --split-functions --split-strategy=all --split-all-cold --enable-bat61 62## Prepare pre-aggregated profile using %t.bat63# RUN: link_fdata %s %t.bat2 %t.preagg2 PREAGG264 65## Strip labels used for pre-aggregated profile66# RUN: llvm-strip -NLcall -NLindcall %t.bat267 68## Convert pre-aggregated profile using BAT69# RUN: perf2bolt %t.bat2 -p %t.preagg2 --pa -o %t.bat2.fdata -w %t.bat2.yaml70 71## Convert BAT fdata into YAML72# RUN: llvm-bolt %t.exe -data %t.bat2.fdata -w %t.bat2.fdata-yaml -o /dev/null73 74## Check fdata YAML - make sure that a direct call has discriminator field75# RUN: FileCheck %s --input-file %t.bat2.fdata-yaml -check-prefix CHECK-BAT-YAML76 77## Check BAT YAML - make sure that a direct call has discriminator field78# RUN: FileCheck %s --input-file %t.bat2.yaml --check-prefix CHECK-BAT-YAML79 80# CHECK-BAT-YAML:      - name:    main81# CHECK-BAT-YAML-NEXT:   fid:     [[#]]82# CHECK-BAT-YAML-NEXT:   hash:    0xADF270D55015118583# CHECK-BAT-YAML-NEXT:   exec:    084# CHECK-BAT-YAML-NEXT:   nblocks: 485# CHECK-BAT-YAML-NEXT:   blocks:86# CHECK-BAT-YAML:          - bid:   187# CHECK-BAT-YAML-NEXT:       insns: [[#]]88# CHECK-BAT-YAML-NEXT:       hash:  0x36A303CBA436001889# CHECK-BAT-YAML-NEXT:       calls: [ { off: 0x0, fid: [[#]], disc: 1, cnt: 190 91.globl func92.type	func, @function93func:94# FDATA: 0 [unknown] 0 1 func 0 1 095# PREAGG: B X:0 #func# 1 196# PREAGG2: B X:0 #func# 1 197  .cfi_startproc98  pushq   %rbp99  movq    %rsp, %rbp100## Placeholder code to make splitting profitable101.rept 5102  testq   %rax, %rax103.endr104.globl secondary_entry105secondary_entry:106## Placeholder code to make splitting profitable107.rept 5108  testq   %rax, %rax109.endr110  popq    %rbp111  retq112  nopl    (%rax)113  .cfi_endproc114  .size	func, .-func115 116.globl main117.type	main, @function118main:119  .cfi_startproc120  pushq   %rbp121  movq    %rsp, %rbp122  subq    $16, %rsp123  movl    $0, -4(%rbp)124  testq   %rax, %rax125  jne     Lindcall126.globl Lcall127Lcall:128  call    secondary_entry129# FDATA: 1 main #Lcall# 1 secondary_entry 0 1 1130# PREAGG: B #Lcall# #secondary_entry# 1 1131# PREAGG2: B #main.cold.0# #func.cold.0# 1 1132.globl Lindcall133Lindcall:134  callq   *%rax135# FDATA: 1 main #Lindcall# 1 secondary_entry 0 1 1136# PREAGG: B #Lindcall# #secondary_entry# 1 1137# PREAGG2: B #main.cold.1# #func.cold.0# 1 1138  xorl    %eax, %eax139  addq    $16, %rsp140  popq    %rbp141  retq142## For relocations against .text143  call exit144  .cfi_endproc145  .size	main, .-main146