brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 2dcaa9d Raw
124 lines · plain
1; Tests that the compiler dumps an allocation site with multiple inlined frames.2;3; The test case is generated from:4;5; // main6; // |7; // f1 (noinline)8; // |9; // f210; // |11; // f312; // |13; // new14;15; char *f1() { return new char[3]; }16; char *f2() { return f1(); }17; __attribute__((noinline)) char *f3() { return f2(); }18;19; int main() {20;   f3();21;   return 0;22; }23;24; Here we expect to match the allocation site to encompass 3 frames.25 26; REQUIRES: x86_64-linux27; RUN: split-file %s %t28; RUN: llvm-profdata merge %t/memprof-dump-matched-alloc-site.yaml -o %t/memprof-dump-matched-alloc-site.memprofdata29; RUN: opt < %t/memprof-dump-matched-alloc-site.ll -passes='memprof-use<profile-filename=%t/memprof-dump-matched-alloc-site.memprofdata>' -memprof-print-match-info -S 2>&1 | FileCheck %s30 31;--- memprof-dump-matched-alloc-site.yaml32---33HeapProfileRecords:34  - GUID:            _Z2f2v35    AllocSites:36      - Callstack:37          - { Function: _Z2f1v, LineOffset: 0, Column: 21, IsInlineFrame: true }38          - { Function: _Z2f2v, LineOffset: 0, Column: 21, IsInlineFrame: true }39          - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false }40          - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }41        MemInfoBlock:42          AllocCount:      143          TotalSize:       344          TotalLifetime:   045          TotalLifetimeAccessDensity: 046    CallSites:47      - Frames:48          - { Function: _Z2f1v, LineOffset: 0, Column: 21, IsInlineFrame: true }49          - { Function: _Z2f2v, LineOffset: 0, Column: 21, IsInlineFrame: true }50          - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false }51  - GUID:            _Z2f1v52    AllocSites:53      - Callstack:54          - { Function: _Z2f1v, LineOffset: 0, Column: 21, IsInlineFrame: true }55          - { Function: _Z2f2v, LineOffset: 0, Column: 21, IsInlineFrame: true }56          - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false }57          - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }58        MemInfoBlock:59          AllocCount:      160          TotalSize:       361          TotalLifetime:   062          TotalLifetimeAccessDensity: 063    CallSites:       []64  - GUID:            _Z2f3v65    AllocSites:66      - Callstack:67          - { Function: _Z2f1v, LineOffset: 0, Column: 21, IsInlineFrame: true }68          - { Function: _Z2f2v, LineOffset: 0, Column: 21, IsInlineFrame: true }69          - { Function: _Z2f3v, LineOffset: 0, Column: 47, IsInlineFrame: false }70          - { Function: main, LineOffset: 1, Column: 3, IsInlineFrame: false }71        MemInfoBlock:72          AllocCount:      173          TotalSize:       374          TotalLifetime:   075          TotalLifetimeAccessDensity: 076    CallSites:77      # Kept empty here because this section is irrelevant for this test.78...79;--- memprof-dump-matched-alloc-site.ll80; CHECK: MemProf notcold context with id 5736731103568718490 has total profiled size 3 is matched with 1 frames81; CHECK: MemProf notcold context with id 5736731103568718490 has total profiled size 3 is matched with 2 frames82; CHECK: MemProf notcold context with id 5736731103568718490 has total profiled size 3 is matched with 3 frames83 84target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"85target triple = "x86_64-unknown-linux-gnu"86 87define ptr @_Z2f1v() {88entry:89  %call = call ptr @_Znam(i64 0), !dbg !390  ret ptr %call91}92 93declare ptr @_Znam(i64)94 95define ptr @_Z2f2v() {96entry:97  %call.i = call ptr @_Znam(i64 0), !dbg !798  ret ptr %call.i99}100 101define ptr @_Z2f3v() {102entry:103  %call.i.i = call ptr @_Znam(i64 0), !dbg !10104  ret ptr %call.i.i105}106 107!llvm.dbg.cu = !{!0}108!llvm.module.flags = !{!2}109 110!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)111!1 = !DIFile(filename: "memprof-dump-matched-alloc-site.cc", directory: "/")112!2 = !{i32 2, !"Debug Info Version", i32 3}113!3 = !DILocation(line: 1, column: 21, scope: !4)114!4 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !5, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)115!5 = !DISubroutineType(types: !6)116!6 = !{}117!7 = !DILocation(line: 1, column: 21, scope: !4, inlinedAt: !8)118!8 = distinct !DILocation(line: 2, column: 21, scope: !9)119!9 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !5, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)120!10 = !DILocation(line: 1, column: 21, scope: !4, inlinedAt: !11)121!11 = distinct !DILocation(line: 2, column: 21, scope: !9, inlinedAt: !12)122!12 = distinct !DILocation(line: 3, column: 47, scope: !13)123!13 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !1, file: !1, line: 3, type: !5, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)124