brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.3 KiB · 71defe6 Raw
167 lines · plain
1; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profsampleacc.extbinary.afdo -profile-summary-cutoff-hot=900000 -profile-sample-accurate -S | FileCheck %s --check-prefix=CALL_SUM_IS_HOT2 3; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list.text %S/Inputs/profsampleacc.extbinary.afdo -o %t.symlist.afdo4; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-summary-cutoff-hot=600000 -profile-accurate-for-symsinlist -S | FileCheck %s --check-prefix=PROFSYMLIST5; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=2 -S | FileCheck %s --check-prefix=PSLCUTOFF26; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=3 -S | FileCheck %s --check-prefix=PSLCUTOFF37;8; If -profile-accurate-for-symsinlist and -profile-sample-accurate both present,9; -profile-sample-accurate will override -profile-accurate-for-symsinlist.10; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profsampleacc.extbinary.afdo -profile-summary-cutoff-hot=900000 -profile-sample-accurate -profile-accurate-for-symsinlist -S | FileCheck %s --check-prefix=CALL_SUM_IS_HOT11;12; Original C++ test case13;14; #include <stdio.h>15;16; int sum(int x, int y) {17;   return x + y;18; }19;20; int main() {21;   int s, i = 0;22;   while (i++ < 20000 * 20000)23;     if (i != 100) s = sum(i, s); else s = 30;24;   printf("sum is %d\n", s);25;   return 0;26; }27;28@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 129 30; Check _Z3sumii's function entry count will be 0 when31; profile-sample-accurate is enabled.32; CALL_SUM_IS_HOT: define i32 @_Z3sumii{{.*}}!prof ![[ZERO_ID:[0-9]+]]33;34; Check _Z3sumii's function entry count will be nonzero when35; profile-sample-accurate is enabled because the callsite is warm and not36; inlined so its function entry count is adjusted to nonzero.37; CALL_SUM_IS_WARM: define i32 @_Z3sumii{{.*}}!prof ![[NONZERO_ID:[0-9]+]]38;39; Check _Z3sumii's function entry count will be initialized to -1 when40; profile-accurate-for-profsymlist is enabled and _Z3sumii exists in the41; profile symbol list because it also shows up in the profile as inline42; instance.43; PROFSYMLIST: define i32 @_Z3sumii{{.*}}!prof ![[UNKNOWN_ID:[0-9]+]]44;45; Function Attrs: nounwind uwtable46define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !4 {47entry:48  %x.addr = alloca i32, align 449  %y.addr = alloca i32, align 450  store i32 %x, ptr %x.addr, align 451  store i32 %y, ptr %y.addr, align 452  %0 = load i32, ptr %x.addr, align 4, !dbg !1153  %1 = load i32, ptr %y.addr, align 4, !dbg !1154  %add = add nsw i32 %0, %1, !dbg !1155  ret i32 %add, !dbg !1156}57 58; Check -profile-symbol-list-cutoff=3 will include _Z3toov into profile59; symbol list and -profile-symbol-list-cutoff=2 will not.60; PSLCUTOFF2: define i32 @_Z3toov{{.*}}!prof ![[TOO_ID:[0-9]+]]61; PSLCUTOFF3: define i32 @_Z3toov{{.*}}!prof ![[TOO_ID:[0-9]+]]62define i32 @_Z3toov(i32 %x, i32 %y) #0 {63entry:64  %add = add nsw i32 %x, %y65  ret i32 %add66}67 68; Function Attrs: uwtable69define i32 @main() #0 !dbg !7 {70entry:71  %retval = alloca i32, align 472  %s = alloca i32, align 473  %i = alloca i32, align 474  store i32 0, ptr %retval75  store i32 0, ptr %i, align 4, !dbg !1276  br label %while.cond, !dbg !1377 78while.cond:                                       ; preds = %if.end, %entry79  %0 = load i32, ptr %i, align 4, !dbg !1480  %inc = add nsw i32 %0, 1, !dbg !1481  store i32 %inc, ptr %i, align 4, !dbg !1482  %cmp = icmp slt i32 %0, 400000000, !dbg !1483  br i1 %cmp, label %while.body, label %while.end, !dbg !1484 85while.body:                                       ; preds = %while.cond86  %1 = load i32, ptr %i, align 4, !dbg !1687  %cmp1 = icmp ne i32 %1, 100, !dbg !1688  br i1 %cmp1, label %if.then, label %if.else, !dbg !1689 90; With the hot cutoff being set to 600000, the inline instance of _Z3sumii91; in main is neither hot nor cold. Check it won't be inlined when92; profile-sample-accurate is enabled.93; CALL_SUM_IS_WARM: if.then:94; CALL_SUM_IS_WARM: call i32 @_Z3sumii95; CALL_SUM_IS_WARM: if.else:96;97; With the hot cutoff being set to 900000, the inline instance of _Z3sumii98; in main is hot. Check the callsite of _Z3sumii will be inlined when99; profile-sample-accurate is enabled.100; CALL_SUM_IS_HOT: if.then:101; CALL_SUM_IS_HOT-NOT: call i32 @_Z3sumii102; CALL_SUM_IS_HOT: if.else:103;104; Check _Z3sumii will be inlined when profile-accurate-for-profsymlist is105; enabled106; PROFSYMLIST: if.then:107; PROFSYMLIST-NOT: call i32 @_Z3sumii108; PROFSYMLIST: if.else:109if.then:                                          ; preds = %while.body110  %2 = load i32, ptr %i, align 4, !dbg !18111  %3 = load i32, ptr %s, align 4, !dbg !18112  %call = call i32 @_Z3sumii(i32 %2, i32 %3), !dbg !18113  store i32 %call, ptr %s, align 4, !dbg !18114  br label %if.end, !dbg !18115 116if.else:                                          ; preds = %while.body117  store i32 30, ptr %s, align 4, !dbg !20118  br label %if.end119 120if.end:                                           ; preds = %if.else, %if.then121  br label %while.cond, !dbg !22122 123while.end:                                        ; preds = %while.cond124  %4 = load i32, ptr %s, align 4, !dbg !24125  %call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %4), !dbg !24126  ret i32 0, !dbg !25127}128 129declare i32 @printf(ptr, ...) #2130 131attributes #0 = { "use-sample-profile" }132 133!llvm.dbg.cu = !{!0}134!llvm.module.flags = !{!8, !9}135!llvm.ident = !{!10}136 137; CALL_SUM_IS_HOT: ![[ZERO_ID]] = !{!"function_entry_count", i64 0}138; CALL_SUM_IS_WARM: ![[NONZERO_ID]] = !{!"function_entry_count", i64 5179}139; PROFSYMLIST: ![[UNKNOWN_ID]] = !{!"function_entry_count", i64 -1}140; PSLCUTOFF2: ![[TOO_ID]] = !{!"function_entry_count", i64 -1}141; PSLCUTOFF3: ![[TOO_ID]] = !{!"function_entry_count", i64 0}142!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)143!1 = !DIFile(filename: "calls.cc", directory: ".")144!2 = !{}145!4 = distinct !DISubprogram(name: "sum", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2)146!5 = !DIFile(filename: "calls.cc", directory: ".")147!6 = !DISubroutineType(types: !2)148!7 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !1, scope: !5, type: !6, retainedNodes: !2)149!8 = !{i32 2, !"Dwarf Version", i32 4}150!9 = !{i32 1, !"Debug Info Version", i32 3}151!10 = !{!"clang version 3.5 "}152!11 = !DILocation(line: 4, scope: !4)153!12 = !DILocation(line: 8, scope: !7)154!13 = !DILocation(line: 9, scope: !7)155!14 = !DILocation(line: 9, scope: !15)156!15 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !7)157!16 = !DILocation(line: 10, scope: !17)158!17 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !7)159!18 = !DILocation(line: 10, scope: !19)160!19 = !DILexicalBlockFile(discriminator: 2, file: !1, scope: !17)161!20 = !DILocation(line: 10, scope: !21)162!21 = !DILexicalBlockFile(discriminator: 4, file: !1, scope: !17)163!22 = !DILocation(line: 10, scope: !23)164!23 = !DILexicalBlockFile(discriminator: 6, file: !1, scope: !17)165!24 = !DILocation(line: 11, scope: !7)166!25 = !DILocation(line: 12, scope: !7)167