File: memprof_annotate_indirect_call.test

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (88 lines) | stat: -rw-r--r-- 3,515 bytes parent folder | download | duplicates (3)
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
; RUN: split-file %s %t

;; Basic functionality with flag toggle
; RUN: llvm-profdata merge --memprof-version=4 %t/basic.yaml -o %t/basic.memprofdata
; RUN: opt < %t/basic.ll -passes='memprof-use<profile-filename=%t/basic.memprofdata>' -memprof-attach-calleeguids=false -S 2>&1 | FileCheck %s --check-prefix=CHECK-DISABLE
; RUN: opt < %t/basic.ll -passes='memprof-use<profile-filename=%t/basic.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-ENABLE

;; FDO conflict handling
; RUN: llvm-profdata merge --memprof-version=4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata
; RUN: opt < %t/fdo_conflict.ll -passes='memprof-use<profile-filename=%t/fdo_conflict.memprofdata>' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-FDO

;--- basic.yaml
---
HeapProfileRecords:
  - GUID:            _Z3barv
    AllocSites:      []
    CallSites:
      - Frames:
          - { Function: _Z3barv, LineOffset: 3, Column: 5, IsInlineFrame: false }
        CalleeGuids:   [0x123456789abcdef0, 0x23456789abcdef01]
...

;--- basic.ll
define dso_local void @_Z3barv() !dbg !4 {
entry:
  %fp = alloca ptr, align 8
  %0 = load ptr, ptr %fp, align 8
  call void %0(), !dbg !5
; CHECK-ENABLE: call void %0(), {{.*}} !prof !6
; CHECK-DISABLE-NOT: !prof
  ret void
}

; CHECK-ENABLE: !6 = !{!"VP", i32 0, i64 2, i64 1311768467463790320, i64 1, i64 2541551405711093505, i64 1}

!llvm.module.flags = !{!2, !3}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)
!1 = !DIFile(filename: "t", directory: "/")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 1, unit: !0)
!5 = !DILocation(line: 4, column: 5, scope: !4)

;--- fdo_conflict.yaml
---
HeapProfileRecords:
  - GUID:            _Z3foov
    AllocSites:      []
    CallSites:
      - Frames:
          - { Function: _Z3foov, LineOffset: 3, Column: 5, IsInlineFrame: false }
        CalleeGuids:   [0x123456789abcdef0, 0x23456789abcdef01]
      - Frames:
          - { Function: _Z3foov, LineOffset: 5, Column: 5, IsInlineFrame: false }
        CalleeGuids:   [0x555556789abcdef0, 0x666656789abcdef1]
...

;--- fdo_conflict.ll
define dso_local void @_Z3foov() !dbg !14 {
entry:
  %fp = alloca ptr, align 8
  %0 = load ptr, ptr %fp, align 8
  ; This call already has FDO value profile metadata - should NOT be modified
  ; CHECK-FDO: call void %0(), {{.*}} !prof !6
  call void %0(), !dbg !15, !prof !16

  %1 = load ptr, ptr %fp, align 8
  ; This call does NOT have existing metadata - should get MemProf annotation
  ; CHECK-FDO: call void %1(), {{.*}} !prof !9
  call void %1(), !dbg !17
  ret void
}

!16 = !{!"VP", i32 0, i64 100, i64 9191153033785521275, i64 80, i64 -1069303473483922844, i64 20}

; CHECK-FDO: !6 = !{!"VP", i32 0, i64 100, i64 9191153033785521275, i64 80, i64 -1069303473483922844, i64 20}
; CHECK-FDO: !9 = !{!"VP", i32 0, i64 2, i64 6148915942236413680, i64 1, i64 7378680115485269745, i64 1}

!llvm.module.flags = !{!12, !13}

!10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11)
!11 = !DIFile(filename: "t", directory: "/")
!12 = !{i32 7, !"Dwarf Version", i32 5}
!13 = !{i32 2, !"Debug Info Version", i32 3}
!14 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !11, file: !11, line: 1, unit: !10)
!15 = !DILocation(line: 4, column: 5, scope: !14)
!17 = !DILocation(line: 6, column: 5, scope: !14)