diff options
Diffstat (limited to 'test/Transforms/SampleProfile')
24 files changed, 472 insertions, 271 deletions
diff --git a/test/Transforms/SampleProfile/Inputs/fnptr.binprof b/test/Transforms/SampleProfile/Inputs/fnptr.binprof Binary files differindex a074f53db945d..420fd8f86d00f 100644 --- a/test/Transforms/SampleProfile/Inputs/fnptr.binprof +++ b/test/Transforms/SampleProfile/Inputs/fnptr.binprof diff --git a/test/Transforms/SampleProfile/Inputs/inline-act.prof b/test/Transforms/SampleProfile/Inputs/inline-act.prof new file mode 100644 index 0000000000000..655739f378884 --- /dev/null +++ b/test/Transforms/SampleProfile/Inputs/inline-act.prof @@ -0,0 +1,3 @@ +_Z3bari:100:0 + 1: _Z3fooi:100 + 2: 100 diff --git a/test/Transforms/SampleProfile/Inputs/inline-combine.prof b/test/Transforms/SampleProfile/Inputs/inline-combine.prof new file mode 100644 index 0000000000000..8d1c0b8103ce1 --- /dev/null +++ b/test/Transforms/SampleProfile/Inputs/inline-combine.prof @@ -0,0 +1,2 @@ +foo:1000:1000 + 1: bar:1000 diff --git a/test/Transforms/SampleProfile/Inputs/propagate.prof b/test/Transforms/SampleProfile/Inputs/propagate.prof index ee9c6d62dfd1c..f298752d03cb0 100644 --- a/test/Transforms/SampleProfile/Inputs/propagate.prof +++ b/test/Transforms/SampleProfile/Inputs/propagate.prof @@ -1,17 +1,22 @@ -_Z3fooiil:58139:0 +_Z3fooiil:33168:0 0: 0 1: 0 2: 0 - 4: 1 - 5: 10 - 6: 2 - 7: 5 - 8: 3 - 9: 0 - 10: 0 - 11: 6339 - 12: 16191 - 13: 8141 - 16: 1 + 4: 0 + 4.1: 302 + 4.2: 315 + 5: 302 + 6: 200 + 7: 308 + 8: 227 + 9: 227 + 10: 227 + 11: 83 + 11.1: 7553 + 11.2: 7479 + 12: 7479 + 13: 7479 + 16: 305 18: 0 19: 0 + 65533: 308 diff --git a/test/Transforms/SampleProfile/Inputs/summary.prof b/test/Transforms/SampleProfile/Inputs/summary.prof new file mode 100644 index 0000000000000..49a5b57d5e64b --- /dev/null +++ b/test/Transforms/SampleProfile/Inputs/summary.prof @@ -0,0 +1,4 @@ +bar:100:3 + 1: 100 +foo:200:1 + 1: 200 diff --git a/test/Transforms/SampleProfile/branch.ll b/test/Transforms/SampleProfile/branch.ll index 1700749f0be90..ac68fd857bd27 100644 --- a/test/Transforms/SampleProfile/branch.ll +++ b/test/Transforms/SampleProfile/branch.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/branch.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/branch.prof | opt -analyze -branch-prob | FileCheck %s ; Original C++ code for this test case: ; @@ -157,13 +158,12 @@ attributes #4 = { nounwind readonly } !llvm.module.flags = !{!13, !14} !llvm.ident = !{!15} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 248211) (llvm/trunk 248217)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !5) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 248211) (llvm/trunk 248217)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !3) !1 = !DIFile(filename: "test.cc", directory: "/ssd/llvm_commit") !2 = !{} !3 = !{!4} !4 = !DIBasicType(name: "double", size: 64, align: 64, encoding: DW_ATE_float) -!5 = !{!6} -!6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!6 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !7 = !DISubroutineType(types: !8) !8 = !{!9, !9, !10} !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) diff --git a/test/Transforms/SampleProfile/calls.ll b/test/Transforms/SampleProfile/calls.ll index 53ea9297d7d03..0105019c73eab 100644 --- a/test/Transforms/SampleProfile/calls.ll +++ b/test/Transforms/SampleProfile/calls.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/calls.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/calls.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes="function(instcombine),sample-profile" -sample-profile-file=%S/Inputs/calls.prof | opt -analyze -branch-prob | FileCheck %s ; Original C++ test case ; @@ -16,11 +17,6 @@ ; return 0; ; } ; -; Note that this test is missing the llvm.dbg.cu annotation. This emulates -; the effect of the user having only used -fprofile-sample-use without -; -gmlt when invoking the driver. In those cases, we need to track source -; location information but we do not have to generate debug info in the -; final binary. @.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 1 ; Function Attrs: nounwind uwtable @@ -63,8 +59,8 @@ while.body: ; preds = %while.cond ; both branches out of while.body had the same weight. In reality, ; the edge while.body->if.then is taken most of the time. ; -; CHECK: edge while.body -> if.then probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] ; CHECK: edge while.body -> if.else probability is 0x00000000 / 0x80000000 = 0.00% +; CHECK: edge while.body -> if.then probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] if.then: ; preds = %while.body @@ -89,17 +85,17 @@ while.end: ; preds = %while.cond declare i32 @printf(i8*, ...) #2 +!llvm.dbg.cu = !{!0} !llvm.module.flags = !{!8, !9} !llvm.ident = !{!10} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!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) !1 = !DIFile(filename: "calls.cc", directory: ".") !2 = !{} -!3 = !{!4, !7} -!4 = distinct !DISubprogram(name: "sum", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !5, type: !6, variables: !2) +!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, variables: !2) !5 = !DIFile(filename: "calls.cc", directory: ".") !6 = !DISubroutineType(types: !2) -!7 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !1, scope: !5, type: !6, variables: !2) +!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, variables: !2) !8 = !{i32 2, !"Dwarf Version", i32 4} !9 = !{i32 1, !"Debug Info Version", i32 3} !10 = !{!"clang version 3.5 "} diff --git a/test/Transforms/SampleProfile/cov-zero-samples.ll b/test/Transforms/SampleProfile/cov-zero-samples.ll index d81e6438ee01d..dc3e6de8c3c9a 100644 --- a/test/Transforms/SampleProfile/cov-zero-samples.ll +++ b/test/Transforms/SampleProfile/cov-zero-samples.ll @@ -1,6 +1,7 @@ -; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/cov-zero-samples.prof -sample-profile-check-record-coverage=100 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s +; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/cov-zero-samples.prof -sample-profile-check-record-coverage=100 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s +; RUN: opt < %s -passes="function(instcombine),sample-profile" -sample-profile-file=%S/Inputs/cov-zero-samples.prof -sample-profile-check-record-coverage=100 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s ; -; CHECK: remark: cov-zero-samples.cc:9:25: Applied 404065 samples from profile (offset: 2.1) +; CHECK: remark: cov-zero-samples.cc:9:29: Applied 404065 samples from profile (offset: 2.1) ; CHECK: remark: cov-zero-samples.cc:10:9: Applied 443089 samples from profile (offset: 3) ; CHECK: remark: cov-zero-samples.cc:10:36: Applied 0 samples from profile (offset: 3.1) ; CHECK: remark: cov-zero-samples.cc:11:12: Applied 404066 samples from profile (offset: 4) @@ -86,15 +87,14 @@ declare i32 @printf(i8*, ...) !llvm.module.flags = !{!15, !16} !llvm.ident = !{!17} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 253667) (llvm/trunk 253670)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, globals: !11) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 253667) (llvm/trunk 253670)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, globals: !11) !1 = !DIFile(filename: "cov-zero-samples.cc", directory: ".") !2 = !{} -!3 = !{!4, !8} -!4 = distinct !DISubprogram(name: "never_called", linkageName: "_Z12never_calledi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "never_called", linkageName: "_Z12never_calledi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!8 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !9 = !DISubroutineType(types: !10) !10 = !{!7} !11 = !{!12} diff --git a/test/Transforms/SampleProfile/coverage-warning.ll b/test/Transforms/SampleProfile/coverage-warning.ll index 14a2710b08106..4b8349d0af976 100644 --- a/test/Transforms/SampleProfile/coverage-warning.ll +++ b/test/Transforms/SampleProfile/coverage-warning.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/coverage-warning.prof -sample-profile-check-record-coverage=90 -sample-profile-check-sample-coverage=100 -o /dev/null 2>&1 | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/coverage-warning.prof -sample-profile-check-record-coverage=90 -sample-profile-check-sample-coverage=100 -o /dev/null 2>&1 | FileCheck %s define i32 @foo(i32 %i) !dbg !4 { ; The profile has samples for line locations that are no longer present. ; Coverage does not reach 90%, so we should get this warning: @@ -30,11 +31,10 @@ return: ; preds = %if.end, %if.then !llvm.module.flags = !{!6, !7} !llvm.ident = !{!8} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251524) (llvm/trunk 251531)", isOptimized: false, runtimeVersion: 0, emissionKind: 2, enums: !2, subprograms: !3) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251524) (llvm/trunk 251531)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2) !1 = !DIFile(filename: "coverage-warning.c", directory: ".") !2 = !{} -!3 = !{!4} -!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !2) !6 = !{i32 2, !"Dwarf Version", i32 4} !7 = !{i32 2, !"Debug Info Version", i32 3} diff --git a/test/Transforms/SampleProfile/discriminator.ll b/test/Transforms/SampleProfile/discriminator.ll index 0915fc884f820..862c2ee43c53f 100644 --- a/test/Transforms/SampleProfile/discriminator.ll +++ b/test/Transforms/SampleProfile/discriminator.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/discriminator.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/discriminator.prof | opt -analyze -branch-prob | FileCheck %s ; Original code ; @@ -66,11 +67,10 @@ while.end: ; preds = %while.cond !llvm.module.flags = !{!7, !8} !llvm.ident = !{!9} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 ", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5 ", isOptimized: false, emissionKind: NoDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) !1 = !DIFile(filename: "discriminator.c", directory: ".") !2 = !{} -!3 = !{!4} -!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !2) +!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !2) !5 = !DIFile(filename: "discriminator.c", directory: ".") !6 = !DISubroutineType(types: !2) !7 = !{i32 2, !"Dwarf Version", i32 4} diff --git a/test/Transforms/SampleProfile/entry_counts.ll b/test/Transforms/SampleProfile/entry_counts.ll index 50cd575295a92..1f7aceb8abb17 100644 --- a/test/Transforms/SampleProfile/entry_counts.ll +++ b/test/Transforms/SampleProfile/entry_counts.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/entry_counts.prof -S | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/entry_counts.prof -S | FileCheck %s ; According to the profile, function empty() was called 13,293 times. ; CHECK: {{.*}} = !{!"function_entry_count", i64 13293} @@ -8,15 +9,21 @@ entry: ret void, !dbg !9 } +; This function does not have profile, check if function_entry_count is 0 +; CHECK: {{.*}} = !{!"function_entry_count", i64 0} +define void @no_profile() { +entry: + ret void +} + !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!6, !7} !llvm.ident = !{!8} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 237249) (llvm/trunk 237261)", isOptimized: false, runtimeVersion: 0, emissionKind: 2, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 237249) (llvm/trunk 237261)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2, retainedTypes: !2, globals: !2, imports: !2) !1 = !DIFile(filename: "entry_counts.c", directory: ".") !2 = !{} -!3 = !{!4} -!4 = distinct !DISubprogram(name: "empty", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "empty", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !2) !6 = !{i32 2, !"Dwarf Version", i32 4} !7 = !{i32 2, !"Debug Info Version", i32 3} diff --git a/test/Transforms/SampleProfile/fnptr.ll b/test/Transforms/SampleProfile/fnptr.ll index 7b07ca9679bbe..b41fec7aed1ae 100644 --- a/test/Transforms/SampleProfile/fnptr.ll +++ b/test/Transforms/SampleProfile/fnptr.ll @@ -5,12 +5,15 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/fnptr.prof | opt -analyze -branch-prob | FileCheck %s ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/fnptr.binprof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/fnptr.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/fnptr.binprof | opt -analyze -branch-prob | FileCheck %s + ; CHECK: edge for.body3 -> if.then probability is 0x1a4f3959 / 0x80000000 = 20.55% ; CHECK: edge for.body3 -> if.else probability is 0x65b0c6a7 / 0x80000000 = 79.45% -; CHECK: edge for.inc -> for.inc12 probability is 0x33d4a4c1 / 0x80000000 = 40.49% -; CHECK: edge for.inc -> for.body3 probability is 0x4c2b5b3f / 0x80000000 = 59.51% -; CHECK: edge for.inc12 -> for.end14 probability is 0x3f06d04e / 0x80000000 = 49.24% -; CHECK: edge for.inc12 -> for.cond1.preheader probability is 0x40f92fb2 / 0x80000000 = 50.76% +; CHECK: edge for.inc -> for.inc12 probability is 0x20dc8dc9 / 0x80000000 = 25.67% +; CHECK: edge for.inc -> for.body3 probability is 0x5f237237 / 0x80000000 = 74.33% +; CHECK: edge for.inc12 -> for.end14 probability is 0x00000000 / 0x80000000 = 0.00% +; CHECK: edge for.inc12 -> for.cond1.preheader probability is 0x80000000 / 0x80000000 = 100.00% ; Original C++ test case. ; @@ -126,21 +129,22 @@ declare i32 @printf(i8* nocapture readonly, ...) #1 !llvm.module.flags = !{!0} !llvm.ident = !{!1} +!llvm.dbg.cu = !{!26} !0 = !{i32 2, !"Debug Info Version", i32 3} !1 = !{!"clang version 3.6.0 "} !2 = !DILocation(line: 9, column: 3, scope: !3) -!3 = distinct !DISubprogram(name: "foo", line: 8, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 8, file: !4, scope: !5, type: !6, variables: !7) +!3 = distinct !DISubprogram(name: "foo", line: 8, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !26, scopeLine: 8, file: !4, scope: !5, type: !6, variables: !7) !4 = !DIFile(filename: "fnptr.cc", directory: ".") !5 = !DIFile(filename: "fnptr.cc", directory: ".") !6 = !DISubroutineType(types: !7) !7 = !{} !8 = !DILocation(line: 9, column: 14, scope: !3) !9 = !DILocation(line: 13, column: 3, scope: !10) -!10 = distinct !DISubprogram(name: "bar", line: 12, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 12, file: !4, scope: !5, type: !6, variables: !7) +!10 = distinct !DISubprogram(name: "bar", line: 12, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !26, scopeLine: 12, file: !4, scope: !5, type: !6, variables: !7) !11 = !DILocation(line: 13, column: 14, scope: !10) !12 = !DILocation(line: 19, column: 3, scope: !13) -!13 = distinct !DISubprogram(name: "main", line: 16, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 16, file: !4, scope: !5, type: !6, variables: !7) +!13 = distinct !DISubprogram(name: "main", line: 16, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !26, scopeLine: 16, file: !4, scope: !5, type: !6, variables: !7) !14 = !DILocation(line: 20, column: 5, scope: !13) !15 = !DILocation(line: 21, column: 15, scope: !13) !16 = !DILocation(line: 22, column: 11, scope: !13) @@ -153,3 +157,4 @@ declare i32 @printf(i8* nocapture readonly, ...) #1 !23 = !{!"branch_weights", i32 0, i32 534} !24 = !DILocation(line: 27, column: 3, scope: !13) !25 = !DILocation(line: 28, column: 3, scope: !13) +!26 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: FullDebug, file: !4) diff --git a/test/Transforms/SampleProfile/gcc-simple.ll b/test/Transforms/SampleProfile/gcc-simple.ll index 1ae927158c119..cbd105ebc3b4c 100644 --- a/test/Transforms/SampleProfile/gcc-simple.ll +++ b/test/Transforms/SampleProfile/gcc-simple.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/gcc-simple.afdo -S | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/gcc-simple.afdo -S | FileCheck %s ; XFAIL: powerpc64-, s390x, mips-, mips64-, sparc ; Original code: ; @@ -144,16 +145,15 @@ attributes #3 = { nounwind } !llvm.module.flags = !{!13, !14} !llvm.ident = !{!15} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 247554) (llvm/trunk 247557)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 247554) (llvm/trunk 247557)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) !1 = !DIFile(filename: "discriminator.cc", directory: "/usr/local/google/home/dnovillo/llvm/test/autofdo") !2 = !{} -!3 = !{!4, !9} -!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fool", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fool", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !8} !7 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed) !8 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed) -!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !10, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !10, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !10 = !DISubroutineType(types: !11) !11 = !{!12} !12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) diff --git a/test/Transforms/SampleProfile/inline-act.ll b/test/Transforms/SampleProfile/inline-act.ll new file mode 100644 index 0000000000000..6383dfbddf95a --- /dev/null +++ b/test/Transforms/SampleProfile/inline-act.ll @@ -0,0 +1,72 @@ +; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline-act.prof + +; Sample profile should have non-empty ACT passed to inliner + +; int t; +; bool foo(int value) { +; switch(value) { +; case 0: +; case 1: +; case 3: +; return true; +; default: +; return false; +; } +; } +; void bar(int i) { +; if (foo(i)) +; t *= 2; +; } + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@t = global i32 0, align 4 + +; Function Attrs: nounwind uwtable +define zeroext i1 @_Z3fooi(i32) #0 { + %switch.tableidx = sub i32 %0, 0 + %2 = icmp ult i32 %switch.tableidx, 4 + br i1 %2, label %switch.lookup, label %3 + +switch.lookup: ; preds = %1 + %switch.cast = trunc i32 %switch.tableidx to i4 + %switch.shiftamt = mul i4 %switch.cast, 1 + %switch.downshift = lshr i4 -5, %switch.shiftamt + %switch.masked = trunc i4 %switch.downshift to i1 + ret i1 %switch.masked + +; <label>:3: ; preds = %1 + ret i1 false +} + +; Function Attrs: nounwind uwtable +define void @_Z3bari(i32) #0 !dbg !9 { + %2 = call zeroext i1 @_Z3fooi(i32 %0), !dbg !10 + br i1 %2, label %3, label %6, !dbg !10 + +; <label>:3: ; preds = %1 + %4 = load i32, i32* @t, align 4 + %5 = shl nsw i32 %4, 1 + store i32 %5, i32* @t, align 4 + br label %6 + +; <label>:6: ; preds = %3, %1 + ret void +} + +attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3} +!llvm.ident = !{!4} + +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 272227) (llvm/trunk 272226)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) +!1 = !DIFile(filename: "test.cc", directory: "./") +!2 = !{} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = !{!"clang version 3.9.0 (trunk 272227) (llvm/trunk 272226)"} +!6 = !DISubroutineType(types: !2) +!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 14, type: !6, isLocal: false, isDefinition: true, scopeLine: 14, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2) +!10 = !DILocation(line: 15, column: 7, scope: !9) +!11 = !DILocation(line: 16, column: 7, scope: !9) diff --git a/test/Transforms/SampleProfile/inline-combine.ll b/test/Transforms/SampleProfile/inline-combine.ll new file mode 100644 index 0000000000000..bcc1770bfae16 --- /dev/null +++ b/test/Transforms/SampleProfile/inline-combine.ll @@ -0,0 +1,47 @@ +; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/inline-combine.prof -S | FileCheck %s +; RUN: opt < %s -passes="function(instcombine),sample-profile" -sample-profile-file=%S/Inputs/inline-combine.prof -S | FileCheck %s + +%"class.llvm::FoldingSetNodeID" = type { %"class.llvm::SmallVector" } +%"class.llvm::SmallVector" = type { %"class.llvm::SmallVectorImpl.base", %"struct.llvm::SmallVectorStorage" } +%"class.llvm::SmallVectorImpl.base" = type { %"class.llvm::SmallVectorTemplateBase.base" } +%"class.llvm::SmallVectorTemplateBase.base" = type { %"class.llvm::SmallVectorTemplateCommon.base" } +%"class.llvm::SmallVectorTemplateCommon.base" = type <{ %"class.llvm::SmallVectorBase", %"struct.llvm::AlignedCharArrayUnion" }> +%"class.llvm::SmallVectorBase" = type { i8*, i8*, i8* } +%"struct.llvm::AlignedCharArrayUnion" = type { %"struct.llvm::AlignedCharArray" } +%"struct.llvm::AlignedCharArray" = type { [4 x i8] } +%"struct.llvm::SmallVectorStorage" = type { [31 x %"struct.llvm::AlignedCharArrayUnion"] } +%"class.llvm::SmallVectorImpl" = type { %"class.llvm::SmallVectorTemplateBase.base", [4 x i8] } + +$foo = comdat any + +$bar = comdat any + +define void @foo(%"class.llvm::FoldingSetNodeID"* %this) comdat align 2 !dbg !3 { + %1 = alloca %"class.llvm::FoldingSetNodeID"*, align 8 + store %"class.llvm::FoldingSetNodeID"* %this, %"class.llvm::FoldingSetNodeID"** %1, align 8 + %2 = load %"class.llvm::FoldingSetNodeID"*, %"class.llvm::FoldingSetNodeID"** %1, align 8 + %3 = getelementptr inbounds %"class.llvm::FoldingSetNodeID", %"class.llvm::FoldingSetNodeID"* %2, i32 0, i32 0 +; the call should have been inlined after sample-profile pass +; CHECK-NOT: call + call void bitcast (void (%"class.llvm::SmallVectorImpl"*)* @bar to void (%"class.llvm::SmallVector"*)*)(%"class.llvm::SmallVector"* %3), !dbg !7 + ret void +} + +define void @bar(%"class.llvm::SmallVectorImpl"* %this) comdat align 2 !dbg !8 { + ret void +} + +!llvm.module.flags = !{!0, !1} +!llvm.ident = !{!2} +!llvm.dbg.cu = !{!9} + +!0 = !{i32 2, !"Dwarf Version", i32 4} +!1 = !{i32 1, !"Debug Info Version", i32 3} +!2 = !{!"clang version 3.5 "} +!3 = distinct !DISubprogram(name: "foo", scope: !4, file: !4, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !9, variables: !6) +!4 = !DIFile(filename: "test.cc", directory: ".") +!5 = !DISubroutineType(types: !6) +!6 = !{} +!7 = !DILocation(line: 4, scope: !3) +!8 = distinct !DISubprogram(name: "bar", scope: !4, file: !4, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !9, variables: !6) +!9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: FullDebug, file: !4) diff --git a/test/Transforms/SampleProfile/inline-coverage.ll b/test/Transforms/SampleProfile/inline-coverage.ll index 7248540b4f7ca..c88e7f865fa2f 100644 --- a/test/Transforms/SampleProfile/inline-coverage.ll +++ b/test/Transforms/SampleProfile/inline-coverage.ll @@ -1,4 +1,5 @@ -; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline-coverage.prof -sample-profile-check-record-coverage=100 -sample-profile-check-sample-coverage=110 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s +; RUN: opt < %s -instcombine -sample-profile -sample-profile-file=%S/Inputs/inline-coverage.prof -sample-profile-check-record-coverage=100 -sample-profile-check-sample-coverage=110 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s +; RUN: opt < %s -passes="function(instcombine),sample-profile" -sample-profile-file=%S/Inputs/inline-coverage.prof -sample-profile-check-record-coverage=100 -sample-profile-check-sample-coverage=110 -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s ; ; Original code: ; @@ -16,7 +17,7 @@ ; 12 } ; ; CHECK: remark: coverage.cc:10:12: inlined hot callee '_Z3fool' with 172746 samples into 'main' -; CHECK: remark: coverage.cc:9:19: Applied 23478 samples from profile (offset: 2.1) +; CHECK: remark: coverage.cc:9:21: Applied 23478 samples from profile (offset: 2.1) ; CHECK: remark: coverage.cc:10:16: Applied 23478 samples from profile (offset: 3) ; CHECK: remark: coverage.cc:4:10: Applied 31878 samples from profile (offset: 1) ; CHECK: remark: coverage.cc:11:10: Applied 0 samples from profile (offset: 4) @@ -90,16 +91,15 @@ for.end: ; preds = %for.cond !llvm.module.flags = !{!13, !14} !llvm.ident = !{!15} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 251738) (llvm/trunk 251737)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 251738) (llvm/trunk 251737)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) !1 = !DIFile(filename: "coverage.cc", directory: ".") !2 = !{} -!3 = !{!4, !9} -!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fool", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fool", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !8} !7 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed) !8 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed) -!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !10, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!9 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !10, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !10 = !DISubroutineType(types: !11) !11 = !{!12} !12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) diff --git a/test/Transforms/SampleProfile/inline-hint.ll b/test/Transforms/SampleProfile/inline-hint.ll deleted file mode 100644 index 16c4e64ec5bb9..0000000000000 --- a/test/Transforms/SampleProfile/inline-hint.ll +++ /dev/null @@ -1,38 +0,0 @@ -; RUN: opt %s -sample-profile -sample-profile-file=%S/Inputs/inline-hint.prof -pass-remarks=sample-profile -o /dev/null 2>&1 | FileCheck %s -; -; CHECK: Applied cold hint to globally cold function '_Z7cold_fnRxi' with 0.1 -define void @_Z7cold_fnRxi() !dbg !4 { -entry: - ret void, !dbg !29 -} - -; CHECK: Applied inline hint to globally hot function '_Z6hot_fnRxi' with 70.0 -define void @_Z6hot_fnRxi() #0 !dbg !10 { -entry: - ret void, !dbg !38 -} - -!llvm.module.flags = !{!17, !18} -!llvm.ident = !{!19} - -!1 = !DIFile(filename: "inline-hint.cc", directory: ".") -!2 = !{} -!3 = !{!4, !10, !11, !14} -!4 = distinct !DISubprogram(name: "cold_fn", linkageName: "_Z7cold_fnRxi", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!5 = !DISubroutineType(types: !6) -!6 = !{null, !7, !9} -!7 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !8, size: 64, align: 64) -!8 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed) -!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!10 = distinct !DISubprogram(name: "hot_fn", linkageName: "_Z6hot_fnRxi", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!11 = distinct !DISubprogram(name: "compute", linkageName: "_Z7computex", scope: !1, file: !1, line: 11, type: !12, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!12 = !DISubroutineType(types: !13) -!13 = !{!8, !8} -!14 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 21, type: !15, isLocal: false, isDefinition: true, scopeLine: 21, flags: DIFlagPrototyped, isOptimized: false, variables: !2) -!15 = !DISubroutineType(types: !16) -!16 = !{!9} -!17 = !{i32 2, !"Dwarf Version", i32 4} -!18 = !{i32 2, !"Debug Info Version", i32 3} -!19 = !{!"clang version 3.8.0 (trunk 254067) (llvm/trunk 254079)"} -!29 = !DILocation(line: 5, column: 1, scope: !4) -!38 = !DILocation(line: 9, column: 1, scope: !10) diff --git a/test/Transforms/SampleProfile/inline.ll b/test/Transforms/SampleProfile/inline.ll index 590a20f9d1d1b..ed353834137bd 100644 --- a/test/Transforms/SampleProfile/inline.ll +++ b/test/Transforms/SampleProfile/inline.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline.prof -sample-profile-inline-hot-threshold=1 -S | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline.prof -sample-profile-inline-hot-threshold=1 -S | FileCheck %s ; Original C++ test case ; @@ -77,17 +78,17 @@ while.end: ; preds = %while.cond declare i32 @printf(i8*, ...) #2 +!llvm.dbg.cu = !{!0} !llvm.module.flags = !{!8, !9} !llvm.ident = !{!10} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!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) !1 = !DIFile(filename: "calls.cc", directory: ".") !2 = !{} -!3 = !{!4, !7} -!4 = distinct !DISubprogram(name: "sum", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !5, type: !6, variables: !2) +!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, variables: !2) !5 = !DIFile(filename: "calls.cc", directory: ".") !6 = !DISubroutineType(types: !2) -!7 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !1, scope: !5, type: !6, variables: !2) +!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, variables: !2) !8 = !{i32 2, !"Dwarf Version", i32 4} !9 = !{i32 1, !"Debug Info Version", i32 3} !10 = !{!"clang version 3.5 "} diff --git a/test/Transforms/SampleProfile/nolocinfo.ll b/test/Transforms/SampleProfile/nolocinfo.ll index 08bca20984dd8..bd6a10b33f2c0 100644 --- a/test/Transforms/SampleProfile/nolocinfo.ll +++ b/test/Transforms/SampleProfile/nolocinfo.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/nolocinfo.prof -S -pass-remarks=sample-profile 2>&1 | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/nolocinfo.prof -S -pass-remarks=sample-profile 2>&1 | FileCheck %s define i32 @foo(i32 %i) !dbg !4 { entry: @@ -23,11 +24,10 @@ if.end: !llvm.module.flags = !{!8, !9} !llvm.ident = !{!10} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251335) (llvm/trunk 251344)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3) +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251335) (llvm/trunk 251344)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) !1 = !DIFile(filename: "nolocinfo.c", directory: ".") !2 = !{} -!3 = !{!4} -!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) diff --git a/test/Transforms/SampleProfile/offset.ll b/test/Transforms/SampleProfile/offset.ll index 499b2826402dc..c8d52408e8647 100644 --- a/test/Transforms/SampleProfile/offset.ll +++ b/test/Transforms/SampleProfile/offset.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/offset.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/offset.prof | opt -analyze -branch-prob | FileCheck %s ; Original C++ code for this test case: ; @@ -54,11 +55,10 @@ attributes #1 = { nounwind readnone } !llvm.module.flags = !{!8, !9} !llvm.ident = !{!10} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 250750)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 250750)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) !1 = !DIFile(filename: "a.cc", directory: "/tmp") !2 = !{} -!3 = !{!4} -!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, variables: !2) +!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 5, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) !5 = !DISubroutineType(types: !6) !6 = !{!7, !7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) diff --git a/test/Transforms/SampleProfile/propagate.ll b/test/Transforms/SampleProfile/propagate.ll index eef7b162eb7a5..a5796695ca047 100644 --- a/test/Transforms/SampleProfile/propagate.ll +++ b/test/Transforms/SampleProfile/propagate.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/propagate.prof | opt -analyze -branch-prob | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/propagate.prof | opt -analyze -branch-prob | FileCheck %s ; Original C++ code for this test case: ; @@ -15,7 +16,7 @@ ; y++; ; x += 3; ; } else { -; for (unsigned j = 0; j < i; j++) { +; for (unsigned j = 0; j < 100; j++) { ; x += j; ; y -= 3; ; } @@ -28,216 +29,289 @@ ; int main() { ; int x = 5678; ; int y = 1234; -; long N = 999999; +; long N = 9999999; ; printf("foo(%d, %d, %ld) = %ld\n", x, y, N, foo(x, y, N)); ; return 0; ; } ; ModuleID = 'propagate.cc' -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" @.str = private unnamed_addr constant [24 x i8] c"foo(%d, %d, %ld) = %ld\0A\00", align 1 ; Function Attrs: nounwind uwtable -define i64 @_Z3fooiil(i32 %x, i32 %y, i64 %N) #0 !dbg !4 { +define i64 @_Z3fooiil(i32 %x, i32 %y, i64 %N) #0 !dbg !6 { entry: %retval = alloca i64, align 8 %x.addr = alloca i32, align 4 %y.addr = alloca i32, align 4 %N.addr = alloca i64, align 8 %i = alloca i64, align 8 - %j = alloca i32, align 4 + %j = alloca i64, align 8 store i32 %x, i32* %x.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !11, metadata !12), !dbg !13 store i32 %y, i32* %y.addr, align 4 + call void @llvm.dbg.declare(metadata i32* %y.addr, metadata !14, metadata !12), !dbg !15 store i64 %N, i64* %N.addr, align 8 - %0 = load i32, i32* %x.addr, align 4, !dbg !11 - %1 = load i32, i32* %y.addr, align 4, !dbg !11 - %cmp = icmp slt i32 %0, %1, !dbg !11 - br i1 %cmp, label %if.then, label %if.else, !dbg !11 + call void @llvm.dbg.declare(metadata i64* %N.addr, metadata !16, metadata !12), !dbg !17 + %0 = load i32, i32* %x.addr, align 4, !dbg !18 + %1 = load i32, i32* %y.addr, align 4, !dbg !20 + %cmp = icmp slt i32 %0, %1, !dbg !21 + br i1 %cmp, label %if.then, label %if.else, !dbg !22 if.then: ; preds = %entry - %2 = load i32, i32* %y.addr, align 4, !dbg !13 - %3 = load i32, i32* %x.addr, align 4, !dbg !13 - %sub = sub nsw i32 %2, %3, !dbg !13 - %conv = sext i32 %sub to i64, !dbg !13 - store i64 %conv, i64* %retval, !dbg !13 - br label %return, !dbg !13 + %2 = load i32, i32* %y.addr, align 4, !dbg !23 + %3 = load i32, i32* %x.addr, align 4, !dbg !25 + %sub = sub nsw i32 %2, %3, !dbg !26 + %conv = sext i32 %sub to i64, !dbg !23 + store i64 %conv, i64* %retval, align 8, !dbg !27 + br label %return, !dbg !27 if.else: ; preds = %entry - store i64 0, i64* %i, align 8, !dbg !15 - br label %for.cond, !dbg !15 + call void @llvm.dbg.declare(metadata i64* %i, metadata !28, metadata !12), !dbg !31 + store i64 0, i64* %i, align 8, !dbg !31 + br label %for.cond, !dbg !32 -for.cond: ; preds = %for.inc16, %if.else - %4 = load i64, i64* %i, align 8, !dbg !15 - %5 = load i64, i64* %N.addr, align 8, !dbg !15 - %cmp1 = icmp slt i64 %4, %5, !dbg !15 - br i1 %cmp1, label %for.body, label %for.end18, !dbg !15 -; CHECK: edge for.cond -> for.body probability is 0x745d1746 / 0x80000000 = 90.91% [HOT edge] -; CHECK: edge for.cond -> for.end18 probability is 0x0ba2e8ba / 0x80000000 = 9.09% +for.cond: ; preds = %for.inc17, %if.else + %4 = load i64, i64* %i, align 8, !dbg !33 + %5 = load i64, i64* %N.addr, align 8, !dbg !36 + %cmp1 = icmp slt i64 %4, %5, !dbg !37 + br i1 %cmp1, label %for.body, label %for.end19, !dbg !38 for.body: ; preds = %for.cond - %6 = load i64, i64* %i, align 8, !dbg !18 - %7 = load i64, i64* %N.addr, align 8, !dbg !18 - %div = sdiv i64 %7, 3, !dbg !18 - %cmp2 = icmp sgt i64 %6, %div, !dbg !18 - br i1 %cmp2, label %if.then3, label %if.end, !dbg !18 -; CHECK: edge for.body -> if.then3 probability is 0x1999999a / 0x80000000 = 20.00% -; CHECK: edge for.body -> if.end probability is 0x66666666 / 0x80000000 = 80.00% + %6 = load i64, i64* %i, align 8, !dbg !39 + %7 = load i64, i64* %N.addr, align 8, !dbg !42 + %div = sdiv i64 %7, 3, !dbg !43 + %cmp2 = icmp sgt i64 %6, %div, !dbg !44 + br i1 %cmp2, label %if.then3, label %if.end, !dbg !45 +; CHECK: edge for.body -> if.then3 probability is 0x51451451 / 0x80000000 = 63.49% +; CHECK: edge for.body -> if.end probability is 0x2ebaebaf / 0x80000000 = 36.51% if.then3: ; preds = %for.body - %8 = load i32, i32* %x.addr, align 4, !dbg !21 - %dec = add nsw i32 %8, -1, !dbg !21 - store i32 %dec, i32* %x.addr, align 4, !dbg !21 - br label %if.end, !dbg !21 + %8 = load i32, i32* %x.addr, align 4, !dbg !46 + %dec = add nsw i32 %8, -1, !dbg !46 + store i32 %dec, i32* %x.addr, align 4, !dbg !46 + br label %if.end, !dbg !47 if.end: ; preds = %if.then3, %for.body - %9 = load i64, i64* %i, align 8, !dbg !22 - %10 = load i64, i64* %N.addr, align 8, !dbg !22 - %div4 = sdiv i64 %10, 4, !dbg !22 - %cmp5 = icmp sgt i64 %9, %div4, !dbg !22 - br i1 %cmp5, label %if.then6, label %if.else7, !dbg !22 -; CHECK: edge if.end -> if.then6 probability is 0x000f801f / 0x80000000 = 0.05% -; CHECK: edge if.end -> if.else7 probability is 0x7ff07fe1 / 0x80000000 = 99.95% [HOT edge] + %9 = load i64, i64* %i, align 8, !dbg !48 + %10 = load i64, i64* %N.addr, align 8, !dbg !50 + %div4 = sdiv i64 %10, 4, !dbg !51 + %cmp5 = icmp sgt i64 %9, %div4, !dbg !52 + br i1 %cmp5, label %if.then6, label %if.else7, !dbg !53 +; CHECK: edge if.end -> if.then6 probability is 0x5dbaa1dc / 0x80000000 = 73.23% +; CHECK: edge if.end -> if.else7 probability is 0x22455e24 / 0x80000000 = 26.77% if.then6: ; preds = %if.end - %11 = load i32, i32* %y.addr, align 4, !dbg !24 - %inc = add nsw i32 %11, 1, !dbg !24 - store i32 %inc, i32* %y.addr, align 4, !dbg !24 - %12 = load i32, i32* %x.addr, align 4, !dbg !26 - %add = add nsw i32 %12, 3, !dbg !26 - store i32 %add, i32* %x.addr, align 4, !dbg !26 - br label %if.end15, !dbg !27 + %11 = load i32, i32* %y.addr, align 4, !dbg !54 + %inc = add nsw i32 %11, 1, !dbg !54 + store i32 %inc, i32* %y.addr, align 4, !dbg !54 + %12 = load i32, i32* %x.addr, align 4, !dbg !56 + %add = add nsw i32 %12, 3, !dbg !56 + store i32 %add, i32* %x.addr, align 4, !dbg !56 + br label %if.end16, !dbg !57 if.else7: ; preds = %if.end - store i32 0, i32* %j, align 4, !dbg !28 - br label %for.cond8, !dbg !28 + call void @llvm.dbg.declare(metadata i64* %j, metadata !58, metadata !12), !dbg !62 + store i64 0, i64* %j, align 8, !dbg !62 + br label %for.cond8, !dbg !63 for.cond8: ; preds = %for.inc, %if.else7 - %13 = load i32, i32* %j, align 4, !dbg !28 - %conv9 = zext i32 %13 to i64, !dbg !28 - %14 = load i64, i64* %i, align 8, !dbg !28 - %cmp10 = icmp slt i64 %conv9, %14, !dbg !28 - br i1 %cmp10, label %for.body11, label %for.end, !dbg !28 -; CHECK: edge for.cond8 -> for.body11 probability is 0x5bfc7472 / 0x80000000 = 71.86% -; CHECK: edge for.cond8 -> for.end probability is 0x24038b8e / 0x80000000 = 28.14% - -for.body11: ; preds = %for.cond8 - %15 = load i32, i32* %j, align 4, !dbg !31 - %16 = load i32, i32* %x.addr, align 4, !dbg !31 - %add12 = add i32 %16, %15, !dbg !31 - store i32 %add12, i32* %x.addr, align 4, !dbg !31 - %17 = load i32, i32* %y.addr, align 4, !dbg !33 - %sub13 = sub nsw i32 %17, 3, !dbg !33 - store i32 %sub13, i32* %y.addr, align 4, !dbg !33 - br label %for.inc, !dbg !34 - -for.inc: ; preds = %for.body11 - %18 = load i32, i32* %j, align 4, !dbg !28 - %inc14 = add i32 %18, 1, !dbg !28 - store i32 %inc14, i32* %j, align 4, !dbg !28 - br label %for.cond8, !dbg !28 + %13 = load i64, i64* %j, align 8, !dbg !64 + %cmp9 = icmp slt i64 %13, 100, !dbg !67 + br i1 %cmp9, label %for.body10, label %for.end, !dbg !68 +; CHECK: edge for.cond8 -> for.body10 probability is 0x7e985735 / 0x80000000 = 98.90% [HOT edge] +; CHECK: edge for.cond8 -> for.end probability is 0x0167a8cb / 0x80000000 = 1.10% + + +for.body10: ; preds = %for.cond8 + %14 = load i64, i64* %j, align 8, !dbg !69 + %15 = load i32, i32* %x.addr, align 4, !dbg !71 + %conv11 = sext i32 %15 to i64, !dbg !71 + %add12 = add nsw i64 %conv11, %14, !dbg !71 + %conv13 = trunc i64 %add12 to i32, !dbg !71 + store i32 %conv13, i32* %x.addr, align 4, !dbg !71 + %16 = load i32, i32* %y.addr, align 4, !dbg !72 + %sub14 = sub nsw i32 %16, 3, !dbg !72 + store i32 %sub14, i32* %y.addr, align 4, !dbg !72 + br label %for.inc, !dbg !73 + +for.inc: ; preds = %for.body10 + %17 = load i64, i64* %j, align 8, !dbg !74 + %inc15 = add nsw i64 %17, 1, !dbg !74 + store i64 %inc15, i64* %j, align 8, !dbg !74 + br label %for.cond8, !dbg !76 for.end: ; preds = %for.cond8 - br label %if.end15 - -if.end15: ; preds = %for.end, %if.then6 - br label %for.inc16, !dbg !35 - -for.inc16: ; preds = %if.end15 - %19 = load i64, i64* %i, align 8, !dbg !15 - %inc17 = add nsw i64 %19, 1, !dbg !15 - store i64 %inc17, i64* %i, align 8, !dbg !15 - br label %for.cond, !dbg !15 - -for.end18: ; preds = %for.cond - br label %if.end19 - -if.end19: ; preds = %for.end18 - %20 = load i32, i32* %y.addr, align 4, !dbg !36 - %21 = load i32, i32* %x.addr, align 4, !dbg !36 - %mul = mul nsw i32 %20, %21, !dbg !36 - %conv20 = sext i32 %mul to i64, !dbg !36 - store i64 %conv20, i64* %retval, !dbg !36 - br label %return, !dbg !36 - -return: ; preds = %if.end19, %if.then - %22 = load i64, i64* %retval, !dbg !37 - ret i64 %22, !dbg !37 + br label %if.end16 + +if.end16: ; preds = %for.end, %if.then6 + br label %for.inc17, !dbg !77 + +for.inc17: ; preds = %if.end16 + %18 = load i64, i64* %i, align 8, !dbg !78 + %inc18 = add nsw i64 %18, 1, !dbg !78 + store i64 %inc18, i64* %i, align 8, !dbg !78 + br label %for.cond, !dbg !80 + +for.end19: ; preds = %for.cond + br label %if.end20 + +if.end20: ; preds = %for.end19 + %19 = load i32, i32* %y.addr, align 4, !dbg !81 + %20 = load i32, i32* %x.addr, align 4, !dbg !82 + %mul = mul nsw i32 %19, %20, !dbg !83 + %conv21 = sext i32 %mul to i64, !dbg !81 + store i64 %conv21, i64* %retval, align 8, !dbg !84 + br label %return, !dbg !84 + +return: ; preds = %if.end20, %if.then + %21 = load i64, i64* %retval, align 8, !dbg !85 + ret i64 %21, !dbg !85 } -; Function Attrs: uwtable -define i32 @main() #1 !dbg !7 { +; Function Attrs: nounwind readnone +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 + +; Function Attrs: norecurse uwtable +define i32 @main() #2 !dbg !86 { entry: %retval = alloca i32, align 4 %x = alloca i32, align 4 %y = alloca i32, align 4 %N = alloca i64, align 8 - store i32 0, i32* %retval - store i32 5678, i32* %x, align 4, !dbg !38 - store i32 1234, i32* %y, align 4, !dbg !39 - store i64 999999, i64* %N, align 8, !dbg !40 - %0 = load i32, i32* %x, align 4, !dbg !41 - %1 = load i32, i32* %y, align 4, !dbg !41 - %2 = load i64, i64* %N, align 8, !dbg !41 - %3 = load i32, i32* %x, align 4, !dbg !41 - %4 = load i32, i32* %y, align 4, !dbg !41 - %5 = load i64, i64* %N, align 8, !dbg !41 - %call = call i64 @_Z3fooiil(i32 %3, i32 %4, i64 %5), !dbg !41 - %call1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i32 0, i32 0), i32 %0, i32 %1, i64 %2, i64 %call), !dbg !41 - ret i32 0, !dbg !42 + store i32 0, i32* %retval, align 4 + call void @llvm.dbg.declare(metadata i32* %x, metadata !89, metadata !12), !dbg !90 + store i32 5678, i32* %x, align 4, !dbg !90 + call void @llvm.dbg.declare(metadata i32* %y, metadata !91, metadata !12), !dbg !92 + store i32 1234, i32* %y, align 4, !dbg !92 + call void @llvm.dbg.declare(metadata i64* %N, metadata !93, metadata !12), !dbg !94 + store i64 9999999, i64* %N, align 8, !dbg !94 + %0 = load i32, i32* %x, align 4, !dbg !95 + %1 = load i32, i32* %y, align 4, !dbg !96 + %2 = load i64, i64* %N, align 8, !dbg !97 + %3 = load i32, i32* %x, align 4, !dbg !98 + %4 = load i32, i32* %y, align 4, !dbg !99 + %5 = load i64, i64* %N, align 8, !dbg !100 + %call = call i64 @_Z3fooiil(i32 %3, i32 %4, i64 %5), !dbg !101 + %call1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i32 0, i32 0), i32 %0, i32 %1, i64 %2, i64 %call), !dbg !102 + ret i32 0, !dbg !104 } -declare i32 @printf(i8*, ...) #2 +declare i32 @printf(i8*, ...) #3 -attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone } +attributes #2 = { norecurse uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #3 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } !llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!8, !9} -!llvm.ident = !{!10} +!llvm.module.flags = !{!3, !4} +!llvm.ident = !{!5} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 266819)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) !1 = !DIFile(filename: "propagate.cc", directory: ".") !2 = !{} -!3 = !{!4, !7} -!4 = distinct !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 3, file: !1, scope: !5, type: !6, variables: !2) -!5 = !DIFile(filename: "propagate.cc", directory: ".") -!6 = !DISubroutineType(types: !{null}) -!7 = distinct !DISubprogram(name: "main", line: 24, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 24, file: !1, scope: !5, type: !6, variables: !2) -!8 = !{i32 2, !"Dwarf Version", i32 4} -!9 = !{i32 1, !"Debug Info Version", i32 3} -!10 = !{!"clang version 3.5 "} -!11 = !DILocation(line: 4, scope: !12) -!12 = distinct !DILexicalBlock(line: 4, column: 0, file: !1, scope: !4) -!13 = !DILocation(line: 5, scope: !14) -!14 = distinct !DILexicalBlock(line: 4, column: 0, file: !1, scope: !12) -!15 = !DILocation(line: 7, scope: !16) -!16 = distinct !DILexicalBlock(line: 7, column: 0, file: !1, scope: !17) -!17 = distinct !DILexicalBlock(line: 6, column: 0, file: !1, scope: !12) -!18 = !DILocation(line: 8, scope: !19) -!19 = distinct !DILexicalBlock(line: 8, column: 0, file: !1, scope: !20) -!20 = distinct !DILexicalBlock(line: 7, column: 0, file: !1, scope: !16) -!21 = !DILocation(line: 9, scope: !19) -!22 = !DILocation(line: 10, scope: !23) -!23 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !20) -!24 = !DILocation(line: 11, scope: !25) -!25 = distinct !DILexicalBlock(line: 10, column: 0, file: !1, scope: !23) -!26 = !DILocation(line: 12, scope: !25) -!27 = !DILocation(line: 13, scope: !25) -!28 = !DILocation(line: 14, scope: !29) -!29 = distinct !DILexicalBlock(line: 14, column: 0, file: !1, scope: !30) -!30 = distinct !DILexicalBlock(line: 13, column: 0, file: !1, scope: !23) -!31 = !DILocation(line: 15, scope: !32) -!32 = distinct !DILexicalBlock(line: 14, column: 0, file: !1, scope: !29) -!33 = !DILocation(line: 16, scope: !32) -!34 = !DILocation(line: 17, scope: !32) -!35 = !DILocation(line: 19, scope: !20) -!36 = !DILocation(line: 21, scope: !4) -!37 = !DILocation(line: 22, scope: !4) -!38 = !DILocation(line: 25, scope: !7) -!39 = !DILocation(line: 26, scope: !7) -!40 = !DILocation(line: 27, scope: !7) -!41 = !DILocation(line: 28, scope: !7) -!42 = !DILocation(line: 29, scope: !7) +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{!"clang version 3.9.0 (trunk 266819)"} +!6 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooiil", scope: !1, file: !1, line: 3, type: !7, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!7 = !DISubroutineType(types: !8) +!8 = !{!9, !10, !10, !9} +!9 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed) +!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) +!11 = !DILocalVariable(name: "x", arg: 1, scope: !6, file: !1, line: 3, type: !10) +!12 = !DIExpression() +!13 = !DILocation(line: 3, column: 14, scope: !6) +!14 = !DILocalVariable(name: "y", arg: 2, scope: !6, file: !1, line: 3, type: !10) +!15 = !DILocation(line: 3, column: 21, scope: !6) +!16 = !DILocalVariable(name: "N", arg: 3, scope: !6, file: !1, line: 3, type: !9) +!17 = !DILocation(line: 3, column: 29, scope: !6) +!18 = !DILocation(line: 4, column: 7, scope: !19) +!19 = distinct !DILexicalBlock(scope: !6, file: !1, line: 4, column: 7) +!20 = !DILocation(line: 4, column: 11, scope: !19) +!21 = !DILocation(line: 4, column: 9, scope: !19) +!22 = !DILocation(line: 4, column: 7, scope: !6) +!23 = !DILocation(line: 5, column: 12, scope: !24) +!24 = distinct !DILexicalBlock(scope: !19, file: !1, line: 4, column: 14) +!25 = !DILocation(line: 5, column: 16, scope: !24) +!26 = !DILocation(line: 5, column: 14, scope: !24) +!27 = !DILocation(line: 5, column: 5, scope: !24) +!28 = !DILocalVariable(name: "i", scope: !29, file: !1, line: 7, type: !9) +!29 = distinct !DILexicalBlock(scope: !30, file: !1, line: 7, column: 5) +!30 = distinct !DILexicalBlock(scope: !19, file: !1, line: 6, column: 10) +!31 = !DILocation(line: 7, column: 15, scope: !29) +!32 = !DILocation(line: 7, column: 10, scope: !29) +!33 = !DILocation(line: 7, column: 22, scope: !34) +!34 = !DILexicalBlockFile(scope: !35, file: !1, discriminator: 1) +!35 = distinct !DILexicalBlock(scope: !29, file: !1, line: 7, column: 5) +!36 = !DILocation(line: 7, column: 26, scope: !34) +!37 = !DILocation(line: 7, column: 24, scope: !34) +!38 = !DILocation(line: 7, column: 5, scope: !34) +!39 = !DILocation(line: 8, column: 11, scope: !40) +!40 = distinct !DILexicalBlock(scope: !41, file: !1, line: 8, column: 11) +!41 = distinct !DILexicalBlock(scope: !35, file: !1, line: 7, column: 34) +!42 = !DILocation(line: 8, column: 15, scope: !40) +!43 = !DILocation(line: 8, column: 17, scope: !40) +!44 = !DILocation(line: 8, column: 13, scope: !40) +!45 = !DILocation(line: 8, column: 11, scope: !41) +!46 = !DILocation(line: 9, column: 10, scope: !40) +!47 = !DILocation(line: 9, column: 9, scope: !40) +!48 = !DILocation(line: 10, column: 11, scope: !49) +!49 = distinct !DILexicalBlock(scope: !41, file: !1, line: 10, column: 11) +!50 = !DILocation(line: 10, column: 15, scope: !49) +!51 = !DILocation(line: 10, column: 17, scope: !49) +!52 = !DILocation(line: 10, column: 13, scope: !49) +!53 = !DILocation(line: 10, column: 11, scope: !41) +!54 = !DILocation(line: 11, column: 10, scope: !55) +!55 = distinct !DILexicalBlock(scope: !49, file: !1, line: 10, column: 22) +!56 = !DILocation(line: 12, column: 11, scope: !55) +!57 = !DILocation(line: 13, column: 7, scope: !55) +!58 = !DILocalVariable(name: "j", scope: !59, file: !1, line: 14, type: !61) +!59 = distinct !DILexicalBlock(scope: !60, file: !1, line: 14, column: 9) +!60 = distinct !DILexicalBlock(scope: !49, file: !1, line: 13, column: 14) +!61 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed) +!62 = !DILocation(line: 14, column: 24, scope: !59) +!63 = !DILocation(line: 14, column: 14, scope: !59) +!64 = !DILocation(line: 14, column: 31, scope: !65) +!65 = !DILexicalBlockFile(scope: !66, file: !1, discriminator: 1) +!66 = distinct !DILexicalBlock(scope: !59, file: !1, line: 14, column: 9) +!67 = !DILocation(line: 14, column: 33, scope: !65) +!68 = !DILocation(line: 14, column: 9, scope: !65) +!69 = !DILocation(line: 15, column: 16, scope: !70) +!70 = distinct !DILexicalBlock(scope: !66, file: !1, line: 14, column: 45) +!71 = !DILocation(line: 15, column: 13, scope: !70) +!72 = !DILocation(line: 16, column: 13, scope: !70) +!73 = !DILocation(line: 17, column: 9, scope: !70) +!74 = !DILocation(line: 14, column: 41, scope: !75) +!75 = !DILexicalBlockFile(scope: !66, file: !1, discriminator: 2) +!76 = !DILocation(line: 14, column: 9, scope: !75) +!77 = !DILocation(line: 19, column: 5, scope: !41) +!78 = !DILocation(line: 7, column: 30, scope: !79) +!79 = !DILexicalBlockFile(scope: !35, file: !1, discriminator: 2) +!80 = !DILocation(line: 7, column: 5, scope: !79) +!81 = !DILocation(line: 21, column: 10, scope: !6) +!82 = !DILocation(line: 21, column: 14, scope: !6) +!83 = !DILocation(line: 21, column: 12, scope: !6) +!84 = !DILocation(line: 21, column: 3, scope: !6) +!85 = !DILocation(line: 22, column: 1, scope: !6) +!86 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 24, type: !87, isLocal: false, isDefinition: true, scopeLine: 24, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!87 = !DISubroutineType(types: !88) +!88 = !{!10} +!89 = !DILocalVariable(name: "x", scope: !86, file: !1, line: 25, type: !10) +!90 = !DILocation(line: 25, column: 7, scope: !86) +!91 = !DILocalVariable(name: "y", scope: !86, file: !1, line: 26, type: !10) +!92 = !DILocation(line: 26, column: 7, scope: !86) +!93 = !DILocalVariable(name: "N", scope: !86, file: !1, line: 27, type: !9) +!94 = !DILocation(line: 27, column: 8, scope: !86) +!95 = !DILocation(line: 28, column: 38, scope: !86) +!96 = !DILocation(line: 28, column: 41, scope: !86) +!97 = !DILocation(line: 28, column: 44, scope: !86) +!98 = !DILocation(line: 28, column: 51, scope: !86) +!99 = !DILocation(line: 28, column: 54, scope: !86) +!100 = !DILocation(line: 28, column: 57, scope: !86) +!101 = !DILocation(line: 28, column: 47, scope: !86) +!102 = !DILocation(line: 28, column: 3, scope: !103) +!103 = !DILexicalBlockFile(scope: !86, file: !1, discriminator: 1) +!104 = !DILocation(line: 29, column: 3, scope: !86) diff --git a/test/Transforms/SampleProfile/remarks.ll b/test/Transforms/SampleProfile/remarks.ll index a0e6a9deb8a85..908e4f8b10b4c 100644 --- a/test/Transforms/SampleProfile/remarks.ll +++ b/test/Transforms/SampleProfile/remarks.ll @@ -1,4 +1,5 @@ ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile 2>&1 | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile 2>&1 | FileCheck %s ; ; Original test case. ; @@ -124,11 +125,10 @@ attributes #4 = { nounwind } !llvm.module.flags = !{!16, !17} !llvm.ident = !{!18} -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 251041) (llvm/trunk 251053)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3) +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 251041) (llvm/trunk 251053)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2) !1 = !DIFile(filename: "remarks.cc", directory: ".") !2 = !{} -!3 = !{!4, !13} -!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, variables: !8) +!4 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !8) !5 = !DISubroutineType(types: !6) !6 = !{!7} !7 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed) @@ -137,7 +137,7 @@ attributes #4 = { nounwind } !10 = !DILocalVariable(name: "i", scope: !11, file: !1, line: 5, type: !12) !11 = distinct !DILexicalBlock(scope: !4, file: !1, line: 5, column: 3) !12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) -!13 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 13, type: !14, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, variables: !2) +!13 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 13, type: !14, isLocal: false, isDefinition: true, scopeLine: 13, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2) !14 = !DISubroutineType(types: !15) !15 = !{!12} !16 = !{i32 2, !"Dwarf Version", i32 4} diff --git a/test/Transforms/SampleProfile/summary.ll b/test/Transforms/SampleProfile/summary.ll new file mode 100644 index 0000000000000..49b1d2c36333a --- /dev/null +++ b/test/Transforms/SampleProfile/summary.ll @@ -0,0 +1,14 @@ +; Test that we annotate entire program's summary to IR. +; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/summary.prof -S | FileCheck %s + +define i32 @bar() #0 !dbg !1 { +entry: + ret i32 1, !dbg !2 +} + +; CHECK-DAG: {{![0-9]+}} = !{i32 1, !"ProfileSummary", {{![0-9]+}}} +; CHECK-DAG: {{![0-9]+}} = !{!"NumFunctions", i64 2} +; CHECK-DAG: {{![0-9]+}} = !{!"MaxFunctionCount", i64 3} + +!1 = distinct !DISubprogram(name: "bar") +!2 = !DILocation(line: 2, scope: !2) diff --git a/test/Transforms/SampleProfile/syntax.ll b/test/Transforms/SampleProfile/syntax.ll index debbc7c87ddb9..7114dfa615746 100644 --- a/test/Transforms/SampleProfile/syntax.ll +++ b/test/Transforms/SampleProfile/syntax.ll @@ -7,6 +7,15 @@ ; RUN: not opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_samples.prof 2>&1 | FileCheck -check-prefix=BAD-SAMPLES %s ; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/bad_mangle.prof 2>&1 >/dev/null +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/syntax.prof 2>&1 | FileCheck -check-prefix=NO-DEBUG %s +; RUN: not opt < %s -passes=sample-profile -sample-profile-file=missing.prof 2>&1 | FileCheck -check-prefix=MISSING-FILE %s +; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/bad_fn_header.prof 2>&1 | FileCheck -check-prefix=BAD-FN-HEADER %s +; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/bad_sample_line.prof 2>&1 | FileCheck -check-prefix=BAD-SAMPLE-LINE %s +; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/bad_line_values.prof 2>&1 | FileCheck -check-prefix=BAD-LINE-VALUES %s +; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/bad_discriminator_value.prof 2>&1 | FileCheck -check-prefix=BAD-DISCRIMINATOR-VALUE %s +; RUN: not opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/bad_samples.prof 2>&1 | FileCheck -check-prefix=BAD-SAMPLES %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/bad_mangle.prof 2>&1 >/dev/null + define void @empty() { entry: ret void |