149 lines · plain
1; 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 -pass-remarks-analysis=sample-profile -o /dev/null 2>&1 | FileCheck %s2; 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 -pass-remarks-analysis=sample-profile -o /dev/null 2>&1 | FileCheck %s3;4; CHECK: remark: cov-zero-samples.cc:9:29: Applied 404065 samples from profile (offset: 2.1)5; CHECK: remark: cov-zero-samples.cc:10:9: Applied 443089 samples from profile (offset: 3)6; CHECK: remark: cov-zero-samples.cc:10:36: Applied 0 samples from profile (offset: 3.1)7; CHECK: remark: cov-zero-samples.cc:11:12: Applied 404066 samples from profile (offset: 4)8; CHECK: remark: cov-zero-samples.cc:13:25: Applied 0 samples from profile (offset: 6)9; CHECK: remark: cov-zero-samples.cc:14:3: Applied 0 samples from profile (offset: 7)10; CHECK: remark: cov-zero-samples.cc:10:9: most popular destination for conditional branches at cov-zero-samples.cc:9:311; CHECK: remark: cov-zero-samples.cc:11:12: most popular destination for conditional branches at cov-zero-samples.cc:10:912;13; Coverage for this profile should be 100%14; CHECK-NOT: warning: cov-zero-samples.cc:1:15 16source_filename = "test/Transforms/SampleProfile/cov-zero-samples.ll"17 18@N = global i64 8000000000, align 8, !dbg !019@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 120 21define i32 @_Z12never_calledi(i32 %i) #1 !dbg !11 {22entry:23 ret i32 0, !dbg !1524}25 26; Function Attrs: nounwind readnone27declare void @llvm.dbg.declare(metadata, metadata, metadata) #028 29define i32 @main() #1 !dbg !17 {30entry:31 %retval = alloca i32, align 432 %sum = alloca i32, align 433 %i = alloca i64, align 834 store i32 0, ptr %retval, align 435 call void @llvm.dbg.declare(metadata ptr %sum, metadata !20, metadata !21), !dbg !2236 store i32 0, ptr %sum, align 4, !dbg !2237 call void @llvm.dbg.declare(metadata ptr %i, metadata !23, metadata !21), !dbg !2538 store i64 0, ptr %i, align 8, !dbg !2539 br label %for.cond, !dbg !2640 41for.cond: ; preds = %for.inc, %entry42 43 %0 = load i64, ptr %i, align 8, !dbg !2744 %1 = load volatile i64, ptr @N, align 8, !dbg !3045 %cmp = icmp slt i64 %0, %1, !dbg !3146 br i1 %cmp, label %for.body, label %for.end, !dbg !3247 48for.body: ; preds = %for.cond49 %2 = load i64, ptr %i, align 8, !dbg !3350 %3 = load volatile i64, ptr @N, align 8, !dbg !3651 %cmp1 = icmp sgt i64 %2, %3, !dbg !3752 br i1 %cmp1, label %if.then, label %if.end, !dbg !3853 54if.then: ; preds = %for.body55 %4 = load i64, ptr %i, align 8, !dbg !3956 %conv = trunc i64 %4 to i32, !dbg !3957 %call = call i32 @_Z12never_calledi(i32 %conv), !dbg !4158 %5 = load i32, ptr %sum, align 4, !dbg !4259 %add = add nsw i32 %5, %call, !dbg !4260 store i32 %add, ptr %sum, align 4, !dbg !4261 br label %if.end, !dbg !4362 63if.end: ; preds = %if.then, %for.body64 %6 = load i64, ptr %i, align 8, !dbg !4465 %div = sdiv i64 %6, 239, !dbg !4566 %7 = load i32, ptr %sum, align 4, !dbg !4667 %conv2 = sext i32 %7 to i64, !dbg !4668 %mul = mul nsw i64 %conv2, %div, !dbg !4669 %conv3 = trunc i64 %mul to i32, !dbg !4670 store i32 %conv3, ptr %sum, align 4, !dbg !4671 br label %for.inc, !dbg !4772 73for.inc: ; preds = %if.end74 %8 = load i64, ptr %i, align 8, !dbg !4875 %inc = add nsw i64 %8, 1, !dbg !4876 store i64 %inc, ptr %i, align 8, !dbg !4877 br label %for.cond, !dbg !5078 79for.end: ; preds = %for.cond80 %9 = load i32, ptr %sum, align 4, !dbg !5181 %call4 = call i32 (ptr, ...) @printf(ptr @.str, i32 %9), !dbg !5282 ret i32 0, !dbg !5383}84 85declare i32 @printf(ptr, ...)86 87attributes #0 = { nounwind readnone }88attributes #1 = {"use-sample-profile"}89 90!llvm.dbg.cu = !{!2}91!llvm.module.flags = !{!8, !9}92!llvm.ident = !{!10}93 94!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())95!1 = !DIGlobalVariable(name: "N", scope: !2, file: !3, line: 3, type: !6, isLocal: false, isDefinition: true)96!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.8.0 (trunk 253667) (llvm/trunk 253670)", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !4, globals: !5)97!3 = !DIFile(filename: "cov-zero-samples.cc", directory: ".")98!4 = !{}99!5 = !{!0}100!6 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7)101!7 = !DIBasicType(name: "long long int", size: 64, align: 64, encoding: DW_ATE_signed)102!8 = !{i32 2, !"Dwarf Version", i32 4}103!9 = !{i32 2, !"Debug Info Version", i32 3}104!10 = !{!"clang version 3.8.0 (trunk 253667) (llvm/trunk 253670)"}105!11 = distinct !DISubprogram(name: "never_called", linkageName: "_Z12never_calledi", scope: !3, file: !3, line: 5, type: !12, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)106!12 = !DISubroutineType(types: !13)107!13 = !{!14, !14}108!14 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)109!15 = !DILocation(line: 5, column: 27, scope: !16)110!16 = !DILexicalBlockFile(scope: !11, file: !3, discriminator: 6)111!17 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 7, type: !18, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)112!18 = !DISubroutineType(types: !19)113!19 = !{!14}114!20 = !DILocalVariable(name: "sum", scope: !17, file: !3, line: 8, type: !14)115!21 = !DIExpression()116!22 = !DILocation(line: 8, column: 7, scope: !17)117!23 = !DILocalVariable(name: "i", scope: !24, file: !3, line: 9, type: !7)118!24 = distinct !DILexicalBlock(scope: !17, file: !3, line: 9, column: 3)119!25 = !DILocation(line: 9, column: 18, scope: !24)120!26 = !DILocation(line: 9, column: 8, scope: !24)121!27 = !DILocation(line: 9, column: 25, scope: !28)122!28 = !DILexicalBlockFile(scope: !29, file: !3, discriminator: 2)123!29 = distinct !DILexicalBlock(scope: !24, file: !3, line: 9, column: 3)124!30 = !DILocation(line: 9, column: 29, scope: !28)125!31 = !DILocation(line: 9, column: 27, scope: !28)126!32 = !DILocation(line: 9, column: 3, scope: !28)127!33 = !DILocation(line: 10, column: 9, scope: !34)128!34 = distinct !DILexicalBlock(scope: !35, file: !3, line: 10, column: 9)129!35 = distinct !DILexicalBlock(scope: !29, file: !3, line: 9, column: 37)130!36 = !DILocation(line: 10, column: 13, scope: !34)131!37 = !DILocation(line: 10, column: 11, scope: !34)132!38 = !DILocation(line: 10, column: 9, scope: !35)133!39 = !DILocation(line: 10, column: 36, scope: !40)134!40 = !DILexicalBlockFile(scope: !34, file: !3, discriminator: 2)135!41 = !DILocation(line: 10, column: 23, scope: !40)136!42 = !DILocation(line: 10, column: 20, scope: !40)137!43 = !DILocation(line: 10, column: 16, scope: !40)138!44 = !DILocation(line: 11, column: 12, scope: !35)139!45 = !DILocation(line: 11, column: 14, scope: !35)140!46 = !DILocation(line: 11, column: 9, scope: !35)141!47 = !DILocation(line: 12, column: 3, scope: !35)142!48 = !DILocation(line: 9, column: 33, scope: !49)143!49 = !DILexicalBlockFile(scope: !29, file: !3, discriminator: 4)144!50 = !DILocation(line: 9, column: 3, scope: !49)145!51 = !DILocation(line: 13, column: 25, scope: !17)146!52 = !DILocation(line: 13, column: 3, scope: !17)147!53 = !DILocation(line: 14, column: 3, scope: !17)148 149