File: call-graph-profile.test

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (105 lines) | stat: -rw-r--r-- 3,618 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
## This test checks how we handle the --elf-cg-profile option.

# RUN: yaml2obj %s -o %t.o
# RUN: llvm-readobj %t.o --cg-profile | FileCheck %s --check-prefix=LLVM
# RUN: llvm-readelf %t.o --cg-profile | FileCheck %s --check-prefix=GNU
# RUN: llvm-readobj %t.o --elf-cg-profile | FileCheck %s --check-prefix=LLVM
# RUN: llvm-readelf %t.o --elf-cg-profile | FileCheck %s --check-prefix=GNU

# LLVM:      CGProfile [
# LLVM-NEXT:  CGProfileEntry {
# LLVM-NEXT:    From: foo (1)
# LLVM-NEXT:    To: bar (2)
# LLVM-NEXT:    Weight: 89
# LLVM-NEXT:  }
# LLVM-NEXT:  CGProfileEntry {
# LLVM-NEXT:    From: bar (2)
# LLVM-NEXT:    To: foo (1)
# LLVM-NEXT:    Weight: 98
# LLVM-NEXT:  }
# LLVM-NEXT: ]

# GNU: GNUStyle::printCGProfile not implemented

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .llvm.call-graph-profile
    Type: SHT_LLVM_CALL_GRAPH_PROFILE
    Entries:
      - From:   foo
        To:     bar
        Weight: 89
      - From:   bar
        To:     foo
        Weight: 98
## 0x10 is the normal entry size for the SHT_LLVM_CALL_GRAPH_PROFILE section.
    EntSize: [[ENTSIZE=0x10]]
Symbols:
  - Name: foo
  - Name: bar

## Check we report a warning when unable to get the content of the SHT_LLVM_CALL_GRAPH_PROFILE section.
# RUN: yaml2obj %s -DENTSIZE=0xF -o %t2.o
# RUN: llvm-readobj %t2.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t2.o --check-prefix=LLVM-ERR
# RUN: llvm-readelf %t2.o --cg-profile | FileCheck %s --check-prefix=GNU

# LLVM-ERR:      CGProfile [
# LLVM-ERR-NEXT: warning: '[[FILE]]': unable to dump the SHT_LLVM_CALL_GRAPH_PROFILE section: section [index 1] has an invalid sh_entsize: 15
# LLVM-ERR-NEXT: ]

## Check we report a warning when unable to dump a name of a symbol.
# RUN: yaml2obj %s --docnum=2 -o %t3.o
# RUN: llvm-readobj %t3.o --cg-profile 2>&1 | FileCheck %s -DFILE=%t3.o --check-prefix=LLVM-BROKEN-SYM
# RUN: llvm-readelf %t3.o --cg-profile | FileCheck %s --check-prefix=GNU

# LLVM-BROKEN-SYM:      CGProfile [
# LLVM-BROKEN-SYM-NEXT:   CGProfileEntry {
# LLVM-BROKEN-SYM-NEXT:     From: A (1)
# LLVM-BROKEN-SYM-NEXT: warning: '[[FILE]]': unable to read the name of symbol with index 2: st_name (0xff) is past the end of the string table of size 0x5
# LLVM-BROKEN-SYM-NEXT:     To: <?> (2)
# LLVM-BROKEN-SYM-NEXT:     Weight: 10
# LLVM-BROKEN-SYM-NEXT:   }
# LLVM-BROKEN-SYM-NEXT:   CGProfileEntry {
# LLVM-BROKEN-SYM-NEXT:     From: <?> (2)
# LLVM-BROKEN-SYM-NEXT:     To: B (3)
# LLVM-BROKEN-SYM-NEXT:     Weight: 20
# LLVM-BROKEN-SYM-NEXT:   }
# LLVM-BROKEN-SYM-NEXT:   CGProfileEntry {
# LLVM-BROKEN-SYM-NEXT:     From: (0)
# LLVM-BROKEN-SYM-NEXT: warning: '[[FILE]]': unable to read the name of symbol with index 4: unable to get symbol from section [index 3]: invalid symbol index (4)
# LLVM-BROKEN-SYM-NEXT:     To: <?> (4)
# LLVM-BROKEN-SYM-NEXT:     Weight: 20
# LLVM-BROKEN-SYM-NEXT:   }
# LLVM-BROKEN-SYM-NEXT: ]

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_DYN
  Machine: EM_X86_64
Sections:
  - Name: .llvm.call-graph-profile
    Type: SHT_LLVM_CALL_GRAPH_PROFILE
    Entries:
      - From:   1
        To:     2
        Weight: 10
      - From:   2
        To:     3
        Weight: 20
      - From:   0x0 ## Null symbol.
        To:     0x4 ## This index goes past the end of the symbol table.
        Weight: 20
  - Name:    .strtab
    Type:    SHT_STRTAB
    Content: "0041004200" ## '\0', 'A', '\0', 'B', '\0'
Symbols:
  - StName: 1    ## 'A'
  - StName: 0xFF ## An arbitrary currupted index in the string table.
  - StName: 3    ## 'B'