86 lines · plain
1; Ensure MisExpect does not crash when given branches with zero weights2 3; RUN: opt < %s -passes="sample-profile" -sample-profile-file=%S/Inputs/misexpect.prof -pgo-warn-misexpect -S 2>&1 | FileCheck %s4 5define i32 @main() #0 !dbg !36 {6 ; CHECK-LABEL: @main(7; CHECK-NEXT: for.cond:8; CHECK-NEXT: %0 = load i32, ptr null, align 4, !dbg !449; CHECK-NEXT: br i1 false, label %for.body, label %for.end, !prof !4910; CHECK: for.body:11; CHECK-NEXT: ret i32 012; CHECK: for.end:13; CHECK-NEXT: ret i32 014; NOT: warning:15for.cond:16 %0 = load i32, ptr null, align 4, !dbg !4317 br i1 false, label %for.body, label %for.end, !prof !4818 19for.body: ; preds = %for.cond20 ret i32 021 22for.end: ; preds = %for.cond23 ret i32 024}25 26; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn27declare void @llvm.dbg.declare(metadata, metadata, metadata) #128 29attributes #0 = { "use-sample-profile" }30attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }31 32!llvm.dbg.cu = !{!0}33!llvm.module.flags = !{!5, !6, !7}34 35!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)36!1 = !DIFile(filename: "test.cc", directory: "/ssd/llvm_commit")37!2 = !{}38!3 = !{!4}39!4 = !DIBasicType(name: "double", size: 64, align: 64, encoding: DW_ATE_float)40!5 = !{i32 2, !"Dwarf Version", i32 4}41!6 = !{i32 2, !"Debug Info Version", i32 3}42!7 = !{i32 1, !"ProfileSummary", !8}43!8 = !{!9, !10, !11, !12, !13, !14, !15, !16, !17, !18}44!9 = !{!"ProfileFormat", !"SampleProfile"}45!10 = !{!"TotalCount", i64 0}46!11 = !{!"MaxCount", i64 0}47!12 = !{!"MaxInternalCount", i64 0}48!13 = !{!"MaxFunctionCount", i64 0}49!14 = !{!"NumCounts", i64 9}50!15 = !{!"NumFunctions", i64 1}51!16 = !{!"IsPartialProfile", i64 0}52!17 = !{!"PartialProfileRatio", double 0.000000e+00}53!18 = !{!"DetailedSummary", !19}54!19 = !{!20, !21, !22, !23, !24, !25, !26, !27, !28, !29, !30, !31, !32, !33, !34, !35}55!20 = !{i32 10000, i64 0, i32 0}56!21 = !{i32 100000, i64 0, i32 0}57!22 = !{i32 200000, i64 0, i32 0}58!23 = !{i32 300000, i64 0, i32 0}59!24 = !{i32 400000, i64 0, i32 0}60!25 = !{i32 500000, i64 0, i32 0}61!26 = !{i32 600000, i64 0, i32 0}62!27 = !{i32 700000, i64 0, i32 0}63!28 = !{i32 800000, i64 0, i32 0}64!29 = !{i32 900000, i64 0, i32 0}65!30 = !{i32 950000, i64 0, i32 0}66!31 = !{i32 990000, i64 0, i32 0}67!32 = !{i32 999000, i64 0, i32 0}68!33 = !{i32 999900, i64 0, i32 0}69!34 = !{i32 999990, i64 0, i32 0}70!35 = !{i32 999999, i64 0, i32 0}71!36 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 4, type: !37, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)72!37 = !DISubroutineType(types: !38)73!38 = !{!39, !39, !40}74!39 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)75!40 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !41, size: 64, align: 64)76!41 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !42, size: 64, align: 64)77!42 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)78!43 = !DILocation(line: 11, column: 22, scope: !44)79!44 = distinct !DILexicalBlock(scope: !45, file: !1, line: 11, column: 6)80!45 = distinct !DILexicalBlock(scope: !46, file: !1, line: 11, column: 6)81!46 = distinct !DILexicalBlock(scope: !47, file: !1, line: 9, column: 21)82!47 = distinct !DILexicalBlock(scope: !36, file: !1, line: 9, column: 8)83; These branch weights shouldn't be removed by these passes84; CHECK: !{{[0-9]+}} = !{!"branch_weights", i32 0, i32 0}85!48 = !{!"branch_weights", i32 0, i32 0}86