|
| 1 | +; RUN: split-file %s %t |
| 2 | + |
| 3 | +; COM: Basic functionality with flag toggle |
| 4 | +; RUN: llvm-profdata merge --memprof-version=4 %t/basic.yaml -o %t/basic.memprofdata |
| 5 | +; 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 |
| 6 | +; 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 |
| 7 | + |
| 8 | +; COM: FDO conflict handling |
| 9 | +; RUN: llvm-profdata merge --memprof-version=4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata |
| 10 | +; 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 |
| 11 | + |
| 12 | +;--- basic.yaml |
| 13 | +--- |
| 14 | +HeapProfileRecords: |
| 15 | + - GUID: _Z3barv |
| 16 | + AllocSites: [] |
| 17 | + CallSites: |
| 18 | + - Frames: |
| 19 | + - { Function: _Z3barv, LineOffset: 3, Column: 5, IsInlineFrame: false } |
| 20 | + CalleeGuids: [0x123456789abcdef0, 0x23456789abcdef01] |
| 21 | +... |
| 22 | + |
| 23 | +;--- basic.ll |
| 24 | +define dso_local void @_Z3barv() !dbg !4 { |
| 25 | +entry: |
| 26 | + %fp = alloca ptr, align 8 |
| 27 | + %0 = load ptr, ptr %fp, align 8 |
| 28 | + call void %0(), !dbg !5 |
| 29 | +; CHECK-ENABLE: call void %0(), {{.*}} !prof !6 |
| 30 | +; CHECK-DISABLE-NOT: !prof |
| 31 | + ret void |
| 32 | +} |
| 33 | + |
| 34 | +; CHECK-ENABLE: !6 = !{!"VP", i32 0, i64 2, i64 1311768467463790320, i64 1, i64 2541551405711093505, i64 1} |
| 35 | + |
| 36 | +!llvm.module.flags = !{!2, !3} |
| 37 | + |
| 38 | +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1) |
| 39 | +!1 = !DIFile(filename: "t", directory: "/") |
| 40 | +!2 = !{i32 7, !"Dwarf Version", i32 5} |
| 41 | +!3 = !{i32 2, !"Debug Info Version", i32 3} |
| 42 | +!4 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 1, unit: !0) |
| 43 | +!5 = !DILocation(line: 4, column: 5, scope: !4) |
| 44 | + |
| 45 | +;--- fdo_conflict.yaml |
| 46 | +--- |
| 47 | +HeapProfileRecords: |
| 48 | + - GUID: _Z3foov |
| 49 | + AllocSites: [] |
| 50 | + CallSites: |
| 51 | + - Frames: |
| 52 | + - { Function: _Z3foov, LineOffset: 3, Column: 5, IsInlineFrame: false } |
| 53 | + CalleeGuids: [0x123456789abcdef0, 0x23456789abcdef01] |
| 54 | + - Frames: |
| 55 | + - { Function: _Z3foov, LineOffset: 5, Column: 5, IsInlineFrame: false } |
| 56 | + CalleeGuids: [0x555556789abcdef0, 0x666656789abcdef1] |
| 57 | +... |
| 58 | + |
| 59 | +;--- fdo_conflict.ll |
| 60 | +define dso_local void @_Z3foov() !dbg !14 { |
| 61 | +entry: |
| 62 | + %fp = alloca ptr, align 8 |
| 63 | + %0 = load ptr, ptr %fp, align 8 |
| 64 | + ; This call already has FDO value profile metadata - should NOT be modified |
| 65 | + ; CHECK-FDO: call void %0(), {{.*}} !prof !6 |
| 66 | + ; CHECK-FDO-NOT: call void %0(), {{.*}} !prof !9 |
| 67 | + call void %0(), !dbg !15, !prof !16 |
| 68 | + |
| 69 | + %1 = load ptr, ptr %fp, align 8 |
| 70 | + ; This call does NOT have existing metadata - should get MemProf annotation |
| 71 | + ; CHECK-FDO: call void %1(), {{.*}} !prof !9 |
| 72 | + call void %1(), !dbg !17 |
| 73 | + ret void |
| 74 | +} |
| 75 | + |
| 76 | +!16 = !{!"VP", i32 0, i64 100, i64 9191153033785521275, i64 80, i64 -1069303473483922844, i64 20} |
| 77 | + |
| 78 | +; CHECK-FDO: !6 = !{!"VP", i32 0, i64 100, i64 9191153033785521275, i64 80, i64 -1069303473483922844, i64 20} |
| 79 | +; CHECK-FDO: !9 = !{!"VP", i32 0, i64 2, i64 6148915942236413680, i64 1, i64 7378680115485269745, i64 1} |
| 80 | + |
| 81 | +!llvm.module.flags = !{!12, !13} |
| 82 | + |
| 83 | +!10 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !11) |
| 84 | +!11 = !DIFile(filename: "t", directory: "/") |
| 85 | +!12 = !{i32 7, !"Dwarf Version", i32 5} |
| 86 | +!13 = !{i32 2, !"Debug Info Version", i32 3} |
| 87 | +!14 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !11, file: !11, line: 1, unit: !10) |
| 88 | +!15 = !DILocation(line: 4, column: 5, scope: !14) |
| 89 | +!17 = !DILocation(line: 6, column: 5, scope: !14) |
0 commit comments