33
44; RUN: rm -rf %t && split-file %s %t && cd %t
55
6- ;; Read a text profile and merge it into indexed profile .
6+ ;; Read text profiles and merge them into indexed profiles .
77; RUN: llvm-profdata merge --memprof-version=4 memprof.yaml -o memprof.profdata
8+ ; RUN: llvm-profdata merge --memprof-version=4 memprof-no-dap.yaml -o memprof-no-dap.profdata
89
910;; Run optimizer pass on an IR module without IR functions, and test that global
1011;; variables in the module could be annotated (i.e., no early return),
1112; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' -memprof-annotate-static-data-prefix \
12- ; RUN: -debug-only=memprof -stats -S funcless-module.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOG,PREFIX ,STAT
13+ ; RUN: -debug-only=memprof -stats -S funcless-module.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOG,IR ,STAT
1314
1415;; Run optimizer pass on the IR, and check the section prefix.
1516; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' -memprof-annotate-static-data-prefix \
16- ; RUN: -debug-only=memprof -stats -S input.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOG,PREFIX ,STAT
17+ ; RUN: -debug-only=memprof -stats -S input.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOG,IR ,STAT
1718
18- ;; Run optimizer pass without explicitly setting -memprof-annotate-static-data-prefix.
19- ;; The output text IR shouldn't have `section_prefix`
19+ ;; Run memprof without providing memprof data. Test that IR has module flag
20+ ;; `EnableDataAccessProf` as 0.
21+ ; RUN: opt -passes='memprof-use<profile-filename=memprof-no-dap.profdata>' -memprof-annotate-static-data-prefix \
22+ ; RUN: -debug-only=memprof -stats -S input.ll -o - 2>&1 | FileCheck %s --check-prefix=FLAG
23+
24+ ;; Run memprof without explicitly setting -memprof-annotate-static-data-prefix.
25+ ;; The output text IR shouldn't have `section_prefix` or EnableDataAccessProf module flag.
2026; RUN: opt -passes='memprof-use<profile-filename=memprof.profdata>' \
21- ; RUN: -debug-only=memprof -stats -S input.ll -o - | FileCheck %s --implicit-check-not="section_prefix"
27+ ; RUN: -debug-only=memprof -stats -S input.ll -o - | FileCheck %s --check-prefix=FLAGLESS -- implicit-check-not="section_prefix"
2228
2329; LOG: Skip annotating string literal .str
2430; LOG: Global variable var1 is annotated as hot
2935; LOG: Global variable var4 has explicit section name. Skip annotating.
3036
3137;; String literals are not annotated.
32- ; PREFIX : @.str = unnamed_addr constant [5 x i8] c"abcde"
33- ; PREFIX -NOT: section_prefix
34- ; PREFIX : @var1 = global i32 123, !section_prefix !0
38+ ; IR : @.str = unnamed_addr constant [5 x i8] c"abcde"
39+ ; IR -NOT: section_prefix
40+ ; IR : @var1 = global i32 123, !section_prefix !0
3541
3642;; @var.llvm.125 will be canonicalized to @var2 for profile look-up.
37- ; PREFIX -NEXT: @var2.llvm.125 = global i64 0, !section_prefix !0
43+ ; IR -NEXT: @var2.llvm.125 = global i64 0, !section_prefix !0
3844
3945;; @bar is not seen in hot symbol or known symbol set, so it won't get a section
4046;; prefix. Test this by testing that there is no section_prefix between @bar and
4147;; @foo.
42- ; PREFIX -NEXT: @bar = global i16 3
43- ; PREFIX -NOT: !section_prefix
48+ ; IR -NEXT: @bar = global i16 3
49+ ; IR -NOT: !section_prefix
4450
4551;; @foo is unlikely.
46- ; PREFIX-NEXT: @foo = global i8 2, !section_prefix !1
52+ ; IR-NEXT: @foo = global i8 2, !section_prefix !1
53+
54+ ; IR-NEXT: @var3 = constant [2 x i32] [i32 12345, i32 6789], section "sec1"
55+ ; IR-NEXT: @var4 = constant [1 x i64] [i64 98765] #0
4756
48- ; PREFIX-NEXT: @var3 = constant [2 x i32] [i32 12345, i32 6789], section "sec1"
49- ; PREFIX-NEXT: @var4 = constant [1 x i64] [i64 98765] #0
57+ ; IR: attributes #0 = { "rodata-section"="sec2" }
5058
51- ; PREFIX: attributes #0 = { "rodata-section"="sec2" }
59+ ; IR: !0 = !{!"section_prefix", !"hot"}
60+ ; IR-NEXT: !1 = !{!"section_prefix", !"unlikely"}
61+ ; IR-NEXT: !2 = !{i32 2, !"EnableDataAccessProf", i32 1}
5262
53- ; PREFIX : !0 = !{!"section_prefix ", !"hot" }
54- ; PREFIX-NEXT: !1 = !{!"section_prefix", !"unlikely"}
63+ ; FLAG : !{i32 2, !"EnableDataAccessProf ", i32 0 }
64+ ; FLAGLESS-NOT: EnableDataAccessProf
5565
5666; STAT: 1 memprof - Number of global vars annotated with 'unlikely' section prefix.
5767; STAT: 2 memprof - Number of global vars with user-specified section (not annotated).
@@ -72,6 +82,24 @@ DataAccessProfiles:
7282 - foo
7383 KnownColdStrHashes: [ 999 , 1001 ]
7484...
85+ ;--- memprof-no-dap.yaml
86+ ---
87+ # A memprof file with without data access profiles. The heap records are simplified
88+ # to pass profile parsing and don't need to match the IR.
89+ HeapProfileRecords:
90+ - GUID: 0xdeadbeef12345678
91+ AllocSites:
92+ - Callstack:
93+ - { Function: 0x1111111111111111 , LineOffset: 11 , Column: 10 , IsInlineFrame: true }
94+ MemInfoBlock:
95+ AllocCount: 111
96+ TotalSize: 222
97+ TotalLifetime: 333
98+ TotalLifetimeAccessDensity: 444
99+ CallSites:
100+ - Frames:
101+ - { Function: 0x5555555555555555 , LineOffset: 55 , Column: 50 , IsInlineFrame: true }
102+ ...
75103;--- input.ll
76104
77105target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
0 commit comments