|
| 1 | +# This reproduces a bug with BOLT setting incorrect discriminator for |
| 2 | +# secondary entry points in YAML profile. |
| 3 | + |
| 4 | +# REQUIRES: system-linux |
| 5 | +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o |
| 6 | +# RUN: link_fdata %s %t.o %t.fdata |
| 7 | +# RUN: llvm-strip --strip-unneeded %t.o |
| 8 | +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib |
| 9 | +# 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-CFG |
| 11 | +# RUN: FileCheck %s -input-file %t.yaml |
| 12 | +# CHECK: - name: main |
| 13 | +# CHECK-NEXT: fid: 2 |
| 14 | +# CHECK-NEXT: hash: 0xADF270D550151185 |
| 15 | +# CHECK-NEXT: exec: 0 |
| 16 | +# CHECK-NEXT: nblocks: 4 |
| 17 | +# CHECK-NEXT: blocks: |
| 18 | +# CHECK: - bid: 1 |
| 19 | +# CHECK-NEXT: insns: 1 |
| 20 | +# CHECK-NEXT: hash: 0x36A303CBA4360014 |
| 21 | +# CHECK-NEXT: calls: [ { off: 0x0, fid: 1, disc: 1, cnt: 1 } ] |
| 22 | + |
| 23 | +# Make sure that the profile is attached correctly |
| 24 | +# RUN: llvm-bolt %t.exe -o %t.out --data %t.yaml --print-profile \ |
| 25 | +# RUN: --print-only=main | FileCheck %s --check-prefix=CHECK-CFG |
| 26 | + |
| 27 | +# CHECK-CFG: Binary Function "main" after attaching profile { |
| 28 | +# CHECK-CFG: callq secondary_entry # Offset: [[#]] # Count: 1 |
| 29 | +# CHECK-CFG: callq *%rax # Offset: [[#]] # CallProfile: 1 (1 misses) : |
| 30 | +# XXX: uncomment after discriminator is set correctly for indirect calls |
| 31 | +# COM: CHECK-CFG-NEXT: { secondary_entry: 1 (1 misses) } |
| 32 | +# CHECK-CFG: } |
| 33 | + |
| 34 | +.globl func |
| 35 | +.type func, @function |
| 36 | +func: |
| 37 | + .cfi_startproc |
| 38 | + pushq %rbp |
| 39 | + movq %rsp, %rbp |
| 40 | +.globl secondary_entry |
| 41 | +secondary_entry: |
| 42 | + popq %rbp |
| 43 | + retq |
| 44 | + nopl (%rax) |
| 45 | + .cfi_endproc |
| 46 | + .size func, .-func |
| 47 | + |
| 48 | +.globl main |
| 49 | +.type main, @function |
| 50 | +main: |
| 51 | + .cfi_startproc |
| 52 | + pushq %rbp |
| 53 | + movq %rsp, %rbp |
| 54 | + subq $16, %rsp |
| 55 | + movl $0, -4(%rbp) |
| 56 | + testq %rax, %rax |
| 57 | + jne Lindcall |
| 58 | +Lcall: |
| 59 | + call secondary_entry |
| 60 | +# FDATA: 1 main #Lcall# 1 secondary_entry 0 1 1 |
| 61 | +Lindcall: |
| 62 | + callq *%rax |
| 63 | +# FDATA: 1 main #Lindcall# 1 secondary_entry 0 1 1 |
| 64 | + xorl %eax, %eax |
| 65 | + addq $16, %rsp |
| 66 | + popq %rbp |
| 67 | + retq |
| 68 | +# For relocations against .text |
| 69 | + call exit |
| 70 | + .cfi_endproc |
| 71 | + .size main, .-main |
0 commit comments