118 lines · plain
1; Tests that the compiler dumps call site matches upon request.2;3; The test case is generated from:4;5; // main6; // |7; // f1 (noinline)8; // |9; // f210; // |11; // f3 (noinline)12; // |13; // new14;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, because32; it directly calls new after inlining.33 34; REQUIRES: x86_64-linux35; RUN: split-file %s %t36; RUN: llvm-profdata merge %t/memprof-dump-matched-call-site.yaml -o %t/memprof-dump-matched-call-site.memprofdata37; 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 %s38 39;--- memprof-dump-matched-call-site.yaml40---41HeapProfileRecords:42 - GUID: main43 AllocSites: []44 CallSites:45 - Frames:46 - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }47 - GUID: _ZL2f1v48 AllocSites: []49 CallSites:50 - Frames:51 - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true }52 - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false }53 - GUID: _ZL2f2v54 AllocSites: []55 CallSites:56 - Frames:57 - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true }58 - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false }59 - GUID: _Z2f3v60 AllocSites:61 - Callstack:62 - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false }63 - { Function: _ZL2f2v, LineOffset: 0, Column: 28, IsInlineFrame: true }64 - { Function: _ZL2f1v, LineOffset: 0, Column: 54, IsInlineFrame: false }65 - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }66 MemInfoBlock:67 AllocCount: 168 TotalSize: 469 TotalLifetime: 070 TotalLifetimeAccessDensity: 071 CallSites: []72...73;--- memprof-dump-matched-call-site.ll74; CHECK: MemProf notcold context with id 3894143216621363392 has total profiled size 4 is matched with 1 frames75; CHECK: MemProf callsite match for inline call stack 4745611964195289084 1061686195521934733176; CHECK: MemProf callsite match for inline call stack 540105928118178938277 78target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"79target triple = "x86_64-unknown-linux-gnu"80 81define ptr @_Z2f3v() {82entry:83 %call = call ptr @_Znam(i64 0), !dbg !384 ret ptr null85}86 87declare ptr @_Znam(i64)88 89define i32 @main() {90entry:91 call void @_ZL2f1v(), !dbg !792 ret i32 093}94 95define void @_ZL2f1v() {96entry:97 %call.i = call ptr @_Z2f3v(), !dbg !998 ret void99}100 101!llvm.dbg.cu = !{!0}102!llvm.module.flags = !{!2}103 104!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)105!1 = !DIFile(filename: "match.cc", directory: "/")106!2 = !{i32 2, !"Debug Info Version", i32 3}107!3 = !DILocation(line: 11, column: 47, scope: !4)108!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)109!5 = !DISubroutineType(types: !6)110!6 = !{}111!7 = !DILocation(line: 18, column: 3, scope: !8)112!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 17, type: !5, scopeLine: 17, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)113!9 = !DILocation(line: 13, column: 28, scope: !10, inlinedAt: !11)114!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)115!11 = distinct !DILocation(line: 15, column: 54, scope: !12)116!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)117!13 = !DISubroutineType(cc: DW_CC_nocall, types: !6)118