|
| 1 | +; Tests that the compiler dumps call site matches upon request. |
| 2 | +; |
| 3 | +; The test case is generated from: |
| 4 | +; |
| 5 | +; // main |
| 6 | +; // | |
| 7 | +; // f1 (noinline) |
| 8 | +; // | |
| 9 | +; // f2 |
| 10 | +; // | |
| 11 | +; // f3 (noinline) |
| 12 | +; // | |
| 13 | +; // new |
| 14 | +; |
| 15 | +; __attribute__((noinline)) char *f3() { return ::new char[4]; } |
| 16 | +; |
| 17 | +; static char *f2() { return f3(); } |
| 18 | +; |
| 19 | +; __attribute__((noinline)) static char *f1() { return f2(); } |
| 20 | +; |
| 21 | +; int main() { |
| 22 | +; f1(); |
| 23 | +; return 0; |
| 24 | +; } |
| 25 | +; |
| 26 | +; Here we expect to match two inline call stacks: |
| 27 | +; |
| 28 | +; - [main] |
| 29 | +; - [f1, f2] |
| 30 | +; |
| 31 | +; Note that f3 is considered to be an allocation site, not a call site, because |
| 32 | +; it directly calls new after inlining. |
| 33 | + |
| 34 | +; REQUIRES: x86_64-linux |
| 35 | +; RUN: split-file %s %t |
| 36 | +; RUN: llvm-profdata merge %t/memprof-dump-matched-call-site.yaml -o %t/memprof-dump-matched-call-site.memprofdata |
| 37 | +; RUN: opt < %t/memprof-dump-matched-call-site.ll -passes='memprof-use<profile-filename=%t/memprof-dump-matched-call-site.memprofdata>' -memprof-print-match-info -S 2>&1 | FileCheck %s |
| 38 | + |
| 39 | +;--- memprof-dump-matched-call-site.yaml |
| 40 | +--- |
| 41 | +HeapProfileRecords: |
| 42 | + - GUID: main |
| 43 | + AllocSites: [] |
| 44 | + CallSites: |
| 45 | + - - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false } |
| 46 | + - GUID: _ZL2f1v |
| 47 | + AllocSites: [] |
| 48 | + CallSites: |
| 49 | + - - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true } |
| 50 | + - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false } |
| 51 | + - GUID: _ZL2f2v |
| 52 | + AllocSites: [] |
| 53 | + CallSites: |
| 54 | + - - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true } |
| 55 | + - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false } |
| 56 | + - GUID: _Z2f3v |
| 57 | + AllocSites: |
| 58 | + - Callstack: |
| 59 | + - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false } |
| 60 | + - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true } |
| 61 | + - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false } |
| 62 | + - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false } |
| 63 | + MemInfoBlock: |
| 64 | + AllocCount: 1 |
| 65 | + TotalSize: 4 |
| 66 | + TotalLifetime: 0 |
| 67 | + TotalLifetimeAccessDensity: 0 |
| 68 | + CallSites: [] |
| 69 | +... |
| 70 | +;--- memprof-dump-matched-call-site.ll |
| 71 | +; CHECK: MemProf notcold context with id 3894143216621363392 has total profiled size 4 is matched |
| 72 | +; CHECK: MemProf callsite match for inline call stack 4745611964195289084 10616861955219347331 |
| 73 | +; CHECK: MemProf callsite match for inline call stack 5401059281181789382 |
| 74 | + |
| 75 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" |
| 76 | +target triple = "x86_64-unknown-linux-gnu" |
| 77 | + |
| 78 | +define ptr @_Z2f3v() { |
| 79 | +entry: |
| 80 | + %call = call ptr @_Znam(i64 0), !dbg !3 |
| 81 | + ret ptr null |
| 82 | +} |
| 83 | + |
| 84 | +declare ptr @_Znam(i64) |
| 85 | + |
| 86 | +define i32 @main() { |
| 87 | +entry: |
| 88 | + call void @_ZL2f1v(), !dbg !7 |
| 89 | + ret i32 0 |
| 90 | +} |
| 91 | + |
| 92 | +define void @_ZL2f1v() { |
| 93 | +entry: |
| 94 | + %call.i = call ptr @_Z2f3v(), !dbg !9 |
| 95 | + ret void |
| 96 | +} |
| 97 | + |
| 98 | +!llvm.dbg.cu = !{!0} |
| 99 | +!llvm.module.flags = !{!2} |
| 100 | + |
| 101 | +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1) |
| 102 | +!1 = !DIFile(filename: "match.cc", directory: "/") |
| 103 | +!2 = !{i32 2, !"Debug Info Version", i32 3} |
| 104 | +!3 = !DILocation(line: 11, column: 47, scope: !4) |
| 105 | +!4 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 11, type: !5, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 106 | +!5 = !DISubroutineType(types: !6) |
| 107 | +!6 = !{} |
| 108 | +!7 = !DILocation(line: 18, column: 3, scope: !8) |
| 109 | +!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 17, type: !5, scopeLine: 17, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 110 | +!9 = !DILocation(line: 13, column: 28, scope: !10, inlinedAt: !11) |
| 111 | +!10 = distinct !DISubprogram(name: "f2", linkageName: "_ZL2f2v", scope: !1, file: !1, line: 13, type: !5, scopeLine: 13, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 112 | +!11 = distinct !DILocation(line: 15, column: 54, scope: !12) |
| 113 | +!12 = distinct !DISubprogram(name: "f1", linkageName: "_ZL2f1v", scope: !1, file: !1, line: 15, type: !13, scopeLine: 15, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 114 | +!13 = !DISubroutineType(cc: DW_CC_nocall, types: !6) |
0 commit comments