13155e307SPaul Kirth; Ensure MisExpect does not crash when given branches with zero weights 23155e307SPaul Kirth 33155e307SPaul Kirth; RUN: opt < %s -passes="sample-profile" -sample-profile-file=%S/Inputs/misexpect.prof -pgo-warn-misexpect -S 2>&1 | FileCheck %s 43155e307SPaul Kirth 53155e307SPaul Kirthdefine i32 @main() #0 !dbg !36 { 63155e307SPaul Kirth ; CHECK-LABEL: @main( 73155e307SPaul Kirth; CHECK-NEXT: for.cond: 8*0d2271bbSMatt Arsenault; CHECK-NEXT: %0 = load i32, ptr null, align 4, !dbg !44 93155e307SPaul Kirth; CHECK-NEXT: br i1 false, label %for.body, label %for.end, !prof !49 103155e307SPaul Kirth; CHECK: for.body: 113155e307SPaul Kirth; CHECK-NEXT: ret i32 0 123155e307SPaul Kirth; CHECK: for.end: 133155e307SPaul Kirth; CHECK-NEXT: ret i32 0 143155e307SPaul Kirth; NOT: warning: 153155e307SPaul Kirthfor.cond: 16*0d2271bbSMatt Arsenault %0 = load i32, ptr null, align 4, !dbg !43 173155e307SPaul Kirth br i1 false, label %for.body, label %for.end, !prof !48 183155e307SPaul Kirth 193155e307SPaul Kirthfor.body: ; preds = %for.cond 203155e307SPaul Kirth ret i32 0 213155e307SPaul Kirth 223155e307SPaul Kirthfor.end: ; preds = %for.cond 233155e307SPaul Kirth ret i32 0 243155e307SPaul Kirth} 253155e307SPaul Kirth 263155e307SPaul Kirth; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn 273155e307SPaul Kirthdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1 283155e307SPaul Kirth 293155e307SPaul Kirthattributes #0 = { "use-sample-profile" } 303155e307SPaul Kirthattributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn } 313155e307SPaul Kirth 323155e307SPaul Kirth!llvm.dbg.cu = !{!0} 333155e307SPaul Kirth!llvm.module.flags = !{!5, !6, !7} 343155e307SPaul Kirth 353155e307SPaul Kirth!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) 363155e307SPaul Kirth!1 = !DIFile(filename: "test.cc", directory: "/ssd/llvm_commit") 373155e307SPaul Kirth!2 = !{} 383155e307SPaul Kirth!3 = !{!4} 393155e307SPaul Kirth!4 = !DIBasicType(name: "double", size: 64, align: 64, encoding: DW_ATE_float) 403155e307SPaul Kirth!5 = !{i32 2, !"Dwarf Version", i32 4} 413155e307SPaul Kirth!6 = !{i32 2, !"Debug Info Version", i32 3} 423155e307SPaul Kirth!7 = !{i32 1, !"ProfileSummary", !8} 433155e307SPaul Kirth!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18} 443155e307SPaul Kirth!9 = !{!"ProfileFormat", !"SampleProfile"} 453155e307SPaul Kirth!10 = !{!"TotalCount", i64 0} 463155e307SPaul Kirth!11 = !{!"MaxCount", i64 0} 473155e307SPaul Kirth!12 = !{!"MaxInternalCount", i64 0} 483155e307SPaul Kirth!13 = !{!"MaxFunctionCount", i64 0} 493155e307SPaul Kirth!14 = !{!"NumCounts", i64 9} 503155e307SPaul Kirth!15 = !{!"NumFunctions", i64 1} 513155e307SPaul Kirth!16 = !{!"IsPartialProfile", i64 0} 523155e307SPaul Kirth!17 = !{!"PartialProfileRatio", double 0.000000e+00} 533155e307SPaul Kirth!18 = !{!"DetailedSummary", !19} 543155e307SPaul Kirth!19 = !{!20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35} 553155e307SPaul Kirth!20 = !{i32 10000, i64 0, i32 0} 563155e307SPaul Kirth!21 = !{i32 100000, i64 0, i32 0} 573155e307SPaul Kirth!22 = !{i32 200000, i64 0, i32 0} 583155e307SPaul Kirth!23 = !{i32 300000, i64 0, i32 0} 593155e307SPaul Kirth!24 = !{i32 400000, i64 0, i32 0} 603155e307SPaul Kirth!25 = !{i32 500000, i64 0, i32 0} 613155e307SPaul Kirth!26 = !{i32 600000, i64 0, i32 0} 623155e307SPaul Kirth!27 = !{i32 700000, i64 0, i32 0} 633155e307SPaul Kirth!28 = !{i32 800000, i64 0, i32 0} 643155e307SPaul Kirth!29 = !{i32 900000, i64 0, i32 0} 653155e307SPaul Kirth!30 = !{i32 950000, i64 0, i32 0} 663155e307SPaul Kirth!31 = !{i32 990000, i64 0, i32 0} 673155e307SPaul Kirth!32 = !{i32 999000, i64 0, i32 0} 683155e307SPaul Kirth!33 = !{i32 999900, i64 0, i32 0} 693155e307SPaul Kirth!34 = !{i32 999990, i64 0, i32 0} 703155e307SPaul Kirth!35 = !{i32 999999, i64 0, i32 0} 713155e307SPaul Kirth!36 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !37, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) 723155e307SPaul Kirth!37 = !DISubroutineType(types: !38) 733155e307SPaul Kirth!38 = !{!39, !39, !40} 743155e307SPaul Kirth!39 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 753155e307SPaul Kirth!40 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !41, size: 64, align: 64) 763155e307SPaul Kirth!41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !42, size: 64, align: 64) 773155e307SPaul Kirth!42 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 783155e307SPaul Kirth!43 = !DILocation(line: 11, column: 22, scope: !44) 793155e307SPaul Kirth!44 = distinct !DILexicalBlock(scope: !45, file: !1, line: 11, column: 6) 803155e307SPaul Kirth!45 = distinct !DILexicalBlock(scope: !46, file: !1, line: 11, column: 6) 813155e307SPaul Kirth!46 = distinct !DILexicalBlock(scope: !47, file: !1, line: 9, column: 21) 823155e307SPaul Kirth!47 = distinct !DILexicalBlock(scope: !36, file: !1, line: 9, column: 8) 833155e307SPaul Kirth; These branch weights shouldn't be removed by these passes 843155e307SPaul Kirth; CHECK: !{{[0-9]+}} = !{!"branch_weights", i32 0, i32 0} 853155e307SPaul Kirth!48 = !{!"branch_weights", i32 0, i32 0} 86