llvm-project/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test
Snehasish Kumar c7b421deac
[MemProf] Attach value profile metadata to the IR using CalleeGuids. (#141164)
Use the newly introduced CalleeGuids in CallSiteInfo to annotate the IR
where necessary with value profile metadata. Use a synthetic count of 1
since we don't have actual counts in the profile collection.
2025-05-31 12:53:30 -07:00

89 lines
3.4 KiB
Plaintext

; 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)