brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.4 KiB · 8f1cabf Raw
166 lines · plain
1;; Test the -memprof-min-percent-max-cold-size flag for annotating only the2;; largest contexts with size info.3 4; REQUIRES: x86_64-linux5 6; RUN: split-file %s %t7 8;; Specify version 4 so that a summary is generated.9; RUN: llvm-profdata merge --memprof-version=4 %t/memprof_max_cold_threshold.yaml -o %t/memprof_max_cold_threshold.memprofdata10 11; RUN: llvm-profdata show --memory %t/memprof_max_cold_threshold.memprofdata | FileCheck %s --check-prefixes=SUMMARY12; SUMMARY: # MemProfSummary:13; SUMMARY: #   Total contexts: 514; SUMMARY: #   Total cold contexts: 415; SUMMARY: #   Total hot contexts: 016; SUMMARY: #   Maximum cold context total size: 40017; SUMMARY: #   Maximum warm context total size: 50018; SUMMARY: #   Maximum hot context total size: 019 20;; Test with various thresholds, starting with the baseline of no context size21;; info.22; RUN: opt < %t/memprof_max_cold_threshold.ll -passes='memprof-use<profile-filename=%t/memprof_max_cold_threshold.memprofdata>' -S | FileCheck %s --check-prefixes=ALL,NONE23; RUN: opt < %t/memprof_max_cold_threshold.ll -memprof-min-percent-max-cold-size=99 -passes='memprof-use<profile-filename=%t/memprof_max_cold_threshold.memprofdata>' -S | FileCheck %s --check-prefixes=ALL,THRESH9924; RUN: opt < %t/memprof_max_cold_threshold.ll -memprof-min-percent-max-cold-size=75 -passes='memprof-use<profile-filename=%t/memprof_max_cold_threshold.memprofdata>' -S | FileCheck %s --check-prefixes=ALL,THRESH7525; RUN: opt < %t/memprof_max_cold_threshold.ll -memprof-min-percent-max-cold-size=50 -passes='memprof-use<profile-filename=%t/memprof_max_cold_threshold.memprofdata>' -S | FileCheck %s --check-prefixes=ALL,THRESH5026 27;; Make sure serializing / deserializing through bitcode works28; RUN: opt < %t/memprof_max_cold_threshold.ll -memprof-min-percent-max-cold-size=75 -passes='memprof-use<profile-filename=%t/memprof_max_cold_threshold.memprofdata>' -o %t/out.bc29; RUN: llvm-dis %t/out.bc -o - | FileCheck %s --check-prefixes=ALL,THRESH7530 31;--- memprof_max_cold_threshold.yaml32---33HeapProfileRecords:34  - GUID:            _Z3foov35    AllocSites:36      - Callstack:37          - { Function: _Z3foov, LineOffset: 0, Column: 22, IsInlineFrame: false }38          - { Function: main, LineOffset: 2, Column: 5, IsInlineFrame: false }39        MemInfoBlock:40	  # Smallest cold, 25% of largest cold size41          TotalSize:                  10042          AllocCount:                 143          TotalLifetimeAccessDensity: 144          TotalLifetime:              100000045      - Callstack:46          - { Function: _Z3foov, LineOffset: 0, Column: 22, IsInlineFrame: false }47          - { Function: main, LineOffset: 3, Column: 5, IsInlineFrame: false }48        MemInfoBlock:49	  # Largest cold50          TotalSize:                  40051          AllocCount:                 152          TotalLifetimeAccessDensity: 153          TotalLifetime:              100000054      - Callstack:55          - { Function: _Z3foov, LineOffset: 0, Column: 22, IsInlineFrame: false }56          - { Function: main, LineOffset: 4, Column: 5, IsInlineFrame: false }57        MemInfoBlock:58	  # Second largest cold, 75% of largest cold size59          TotalSize:                  30060          AllocCount:                 161          TotalLifetimeAccessDensity: 162          TotalLifetime:              100000063      - Callstack:64          - { Function: _Z3foov, LineOffset: 0, Column: 22, IsInlineFrame: false }65          - { Function: main, LineOffset: 5, Column: 5, IsInlineFrame: false }66        MemInfoBlock:67	  # Second smallest cold, 50% of largest cold size68          TotalSize:                  20069          AllocCount:                 170          TotalLifetimeAccessDensity: 171          TotalLifetime:              100000072      - Callstack:73          - { Function: _Z3foov, LineOffset: 0, Column: 22, IsInlineFrame: false }74          - { Function: main, LineOffset: 6, Column: 5, IsInlineFrame: false }75        MemInfoBlock:76	  # Largest context, which is non-cold (due to short lifetime)77          TotalSize:                  50078          AllocCount:                 179          TotalLifetimeAccessDensity: 180          TotalLifetime:              181    CallSites:       []82...83;--- memprof_max_cold_threshold.ll84define dso_local ptr @_Z3foov() !dbg !4 {85entry:86  %call = call ptr @_Znam(i64 4) #0, !dbg !587; ALL: call ptr @_Znam(i64 4) {{.*}} !memprof ![[M1:[0-9]+]]88  ret ptr %call89}90 91;; No MIBs get context size info without option.92; NONE: ![[M1]] = !{![[M2:[0-9]+]], ![[M3:[0-9]+]], ![[M4:[0-9]+]], ![[M5:[0-9]+]], ![[M6:[0-9]+]]}93; NONE: ![[M2]] = !{![[C2:[0-9]+]], !"cold"}94; NONE: ![[C2]] = !{i64 590523745590780990, i64 720385627691022109}95; NONE: ![[M3]] = !{![[C3:[0-9]+]], !"cold"}96; NONE: ![[C3]] = !{i64 590523745590780990, i64 8256520048276991898}97; NONE: ![[M4]] = !{![[C4:[0-9]+]], !"cold"}98; NONE: ![[C4]] = !{i64 590523745590780990, i64 -6953100768213558995}99; NONE: ![[M5]] = !{![[C5:[0-9]+]], !"cold"}100; NONE: ![[C5]] = !{i64 590523745590780990, i64 -6435117705372285425}101; NONE: ![[M6]] = !{![[C6:[0-9]+]], !"notcold"}102; NONE: ![[C6]] = !{i64 590523745590780990, i64 -2847840206325626610}103 104; THRESH99: ![[M1]] = !{![[M2:[0-9]+]], ![[M3:[0-9]+]], ![[M4:[0-9]+]], ![[M5:[0-9]+]], ![[M6:[0-9]+]]}105; THRESH99: ![[M2]] = !{![[C2:[0-9]+]], !"cold"}106; THRESH99: ![[C2]] = !{i64 590523745590780990, i64 720385627691022109}107;; MIB with size 400 is now included with threshold 99%108; THRESH99: ![[M3]] = !{![[C3:[0-9]+]], !"cold", ![[S3:[0-9]+]]}109; THRESH99: ![[C3]] = !{i64 590523745590780990, i64 8256520048276991898}110; THRESH99: ![[S3]] = !{i64 6509573709067523871, i64 400}111; THRESH99: ![[M4]] = !{![[C4:[0-9]+]], !"cold"}112; THRESH99: ![[C4]] = !{i64 590523745590780990, i64 -6953100768213558995}113; THRESH99: ![[M5]] = !{![[C5:[0-9]+]], !"cold"}114; THRESH99: ![[C5]] = !{i64 590523745590780990, i64 -6435117705372285425}115; THRESH99: ![[M6]] = !{![[C6:[0-9]+]], !"notcold"}116; THRESH99: ![[C6]] = !{i64 590523745590780990, i64 -2847840206325626610}117 118; THRESH75: ![[M1]] = !{![[M2:[0-9]+]], ![[M3:[0-9]+]], ![[M4:[0-9]+]], ![[M5:[0-9]+]], ![[M6:[0-9]+]]}119; THRESH75: ![[M2]] = !{![[C2:[0-9]+]], !"cold"}120; THRESH75: ![[C2]] = !{i64 590523745590780990, i64 720385627691022109}121; THRESH75: ![[M3]] = !{![[C3:[0-9]+]], !"cold", ![[S3:[0-9]+]]}122; THRESH75: ![[C3]] = !{i64 590523745590780990, i64 8256520048276991898}123; THRESH75: ![[S3]] = !{i64 6509573709067523871, i64 400}124; THRESH75: ![[M4]] = !{![[C4:[0-9]+]], !"cold"}125; THRESH75: ![[C4]] = !{i64 590523745590780990, i64 -6953100768213558995}126;; MIB with size 300 is now included with threshold 75%127; THRESH75: ![[M5]] = !{![[C5:[0-9]+]], !"cold", ![[S5:[0-9]+]]}128; THRESH75: ![[C5]] = !{i64 590523745590780990, i64 -6435117705372285425}129; THRESH75: ![[S5]] = !{i64 86248815258696712, i64 300}130; THRESH75: ![[M6]] = !{![[C6:[0-9]+]], !"notcold"}131; THRESH75: ![[C6]] = !{i64 590523745590780990, i64 -2847840206325626610}132 133; THRESH50: ![[M1]] = !{![[M2:[0-9]+]], ![[M3:[0-9]+]], ![[M4:[0-9]+]], ![[M5:[0-9]+]], ![[M6:[0-9]+]]}134;; The smallest never gets context size info.135; THRESH50: ![[M2]] = !{![[C2:[0-9]+]], !"cold"}136; THRESH50: ![[C2]] = !{i64 590523745590780990, i64 720385627691022109}137; THRESH50: ![[M3]] = !{![[C3:[0-9]+]], !"cold", ![[S3:[0-9]+]]}138; THRESH50: ![[C3]] = !{i64 590523745590780990, i64 8256520048276991898}139; THRESH50: ![[S3]] = !{i64 6509573709067523871, i64 400}140;; MIB with size 200 is now included with threshold 50%141; THRESH50: ![[M4]] = !{![[C4:[0-9]+]], !"cold", ![[S4:[0-9]+]]}142; THRESH50: ![[C4]] = !{i64 590523745590780990, i64 -6953100768213558995}143; THRESH50: ![[S4]] = !{i64 -2629930016428010893, i64 200}144; THRESH50: ![[M5]] = !{![[C5:[0-9]+]], !"cold", ![[S5:[0-9]+]]}145; THRESH50: ![[C5]] = !{i64 590523745590780990, i64 -6435117705372285425}146; THRESH50: ![[S5]] = !{i64 86248815258696712, i64 300}147;; Non cold context never gets context size info148; THRESH50: ![[M6]] = !{![[C6:[0-9]+]], !"notcold"}149; THRESH50: ![[C6]] = !{i64 590523745590780990, i64 -2847840206325626610}150 151declare ptr @_Znam(i64)152 153attributes #0 = { builtin allocsize(0) }154 155!llvm.module.flags = !{!2, !3}156 157!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1)158!1 = !DIFile(filename: "t", directory: "/")159!2 = !{i32 7, !"Dwarf Version", i32 5}160!3 = !{i32 2, !"Debug Info Version", i32 3}161!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, unit: !0)162!5 = !DILocation(line: 1, column: 22, scope: !4)163!6 = !DILocation(line: 2, column: 22, scope: !4)164!7 = !DILocation(line: 3, column: 22, scope: !4)165!8 = !DILocation(line: 4, column: 22, scope: !4)166