brintos

brintos / llvm-project-archived public Read only

0
0
Text · 13.3 KiB · 9665559 Raw
269 lines · plain
1; Test misexpect diagnostics handle swich statements, and report source locations correctly2 3; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata4; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata5 6; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING7; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK8; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH9; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED10 11; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT12 13; WARNING-DAG: warning: misexpect-switch.c:26:30: 0.00%14; WARNING-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.15 16; REMARK-NOT: warning: misexpect-switch.c:26:30: 0.00%17; REMARK-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.18 19; BOTH-DAG: warning: misexpect-switch.c:26:30: 0.00%20; BOTH-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.21 22; DISABLED-NOT: warning: misexpect-switch.c:26:30: 0.00%23; DISABLED-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.24 25; DISABLED-NOT: warning: misexpect-switch.c:26:30: 0.00%26; DISABLED-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.27 28; CORRECT-NOT: warning: {{.*}}29; CORRECT-NOT: remark: {{.*}}30 31; ModuleID = 'misexpect-switch.c'32source_filename = "misexpect-switch.c"33target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"34target triple = "x86_64-unknown-linux-gnu"35 36@inner_loop = dso_local constant i32 1000, align 4, !dbg !037@outer_loop = dso_local constant i32 20, align 4, !dbg !638@arry_size = dso_local constant i32 25, align 4, !dbg !1039@arry = dso_local global [25 x i32] zeroinitializer, align 16, !dbg !1240 41; Function Attrs: nounwind uwtable42define dso_local void @init_arry() !dbg !21 {43entry:44  %i = alloca i32, align 445  call void @llvm.lifetime.start.p0(ptr %i), !dbg !2646  call void @llvm.dbg.declare(metadata ptr %i, metadata !25, metadata !DIExpression()), !dbg !2747  store i32 0, ptr %i, align 4, !dbg !28, !tbaa !3048  br label %for.cond, !dbg !3449 50for.cond:                                         ; preds = %for.inc, %entry51  %0 = load i32, ptr %i, align 4, !dbg !35, !tbaa !3052  %cmp = icmp slt i32 %0, 25, !dbg !3753  br i1 %cmp, label %for.body, label %for.end, !dbg !3854 55for.body:                                         ; preds = %for.cond56  %call = call i32 @rand(), !dbg !3957  %rem = srem i32 %call, 10, !dbg !4158  %1 = load i32, ptr %i, align 4, !dbg !42, !tbaa !3059  %idxprom = sext i32 %1 to i64, !dbg !4360  %arrayidx = getelementptr inbounds [25 x i32], ptr @arry, i64 0, i64 %idxprom, !dbg !4361  store i32 %rem, ptr %arrayidx, align 4, !dbg !44, !tbaa !3062  br label %for.inc, !dbg !4563 64for.inc:                                          ; preds = %for.body65  %2 = load i32, ptr %i, align 4, !dbg !46, !tbaa !3066  %inc = add nsw i32 %2, 1, !dbg !4667  store i32 %inc, ptr %i, align 4, !dbg !46, !tbaa !3068  br label %for.cond, !dbg !47, !llvm.loop !4869 70for.end:                                          ; preds = %for.cond71  call void @llvm.lifetime.end.p0(ptr %i), !dbg !5072  ret void, !dbg !5073}74 75; Function Attrs: argmemonly nounwind willreturn76declare void @llvm.lifetime.start.p0(ptr nocapture)77 78; Function Attrs: nounwind readnone speculatable willreturn79declare void @llvm.dbg.declare(metadata, metadata, metadata)80 81; Function Attrs: nounwind82declare dso_local i32 @rand()83 84; Function Attrs: argmemonly nounwind willreturn85declare void @llvm.lifetime.end.p0(ptr nocapture)86 87; Function Attrs: nounwind uwtable88define dso_local i32 @main() !dbg !51 {89entry:90  %retval = alloca i32, align 491  %val = alloca i32, align 492  %j = alloca i32, align 493  %condition = alloca i32, align 494  store i32 0, ptr %retval, align 495  call void @init_arry(), !dbg !6296  call void @llvm.lifetime.start.p0(ptr %val), !dbg !6397  call void @llvm.dbg.declare(metadata ptr %val, metadata !55, metadata !DIExpression()), !dbg !6498  store i32 0, ptr %val, align 4, !dbg !64, !tbaa !3099  call void @llvm.lifetime.start.p0(ptr %j), !dbg !65100  call void @llvm.dbg.declare(metadata ptr %j, metadata !56, metadata !DIExpression()), !dbg !66101  store i32 0, ptr %j, align 4, !dbg !67, !tbaa !30102  br label %for.cond, !dbg !68103 104for.cond:                                         ; preds = %for.inc, %entry105  %0 = load i32, ptr %j, align 4, !dbg !69, !tbaa !30106  %cmp = icmp slt i32 %0, 20000, !dbg !70107  br i1 %cmp, label %for.body, label %for.end, !dbg !71108 109for.body:                                         ; preds = %for.cond110  call void @llvm.lifetime.start.p0(ptr %condition), !dbg !72111  call void @llvm.dbg.declare(metadata ptr %condition, metadata !57, metadata !DIExpression()), !dbg !73112  %call = call i32 @rand(), !dbg !74113  %rem = srem i32 %call, 5, !dbg !75114  store i32 %rem, ptr %condition, align 4, !dbg !73, !tbaa !30115  %1 = load i32, ptr %condition, align 4, !dbg !76, !tbaa !30116  %conv = zext i32 %1 to i64, !dbg !76117  %expval = call i64 @llvm.expect.i64(i64 %conv, i64 0), !dbg !77118  switch i64 %expval, label %sw.default [119    i64 0, label %sw.bb120    i64 1, label %sw.bb2121    i64 2, label %sw.bb2122    i64 3, label %sw.bb2123    i64 4, label %sw.bb3124  ], !dbg !78125 126sw.bb:                                            ; preds = %for.body127  %call1 = call i32 @sum(ptr @arry, i32 25), !dbg !79128  %2 = load i32, ptr %val, align 4, !dbg !81, !tbaa !30129  %add = add nsw i32 %2, %call1, !dbg !81130  store i32 %add, ptr %val, align 4, !dbg !81, !tbaa !30131  br label %sw.epilog, !dbg !82132 133sw.bb2:                                           ; preds = %for.body, %for.body, %for.body134  br label %sw.epilog, !dbg !83135 136sw.bb3:                                           ; preds = %for.body137  %call4 = call i32 @random_sample(ptr @arry, i32 25), !dbg !84138  %3 = load i32, ptr %val, align 4, !dbg !85, !tbaa !30139  %add5 = add nsw i32 %3, %call4, !dbg !85140  store i32 %add5, ptr %val, align 4, !dbg !85, !tbaa !30141  br label %sw.epilog, !dbg !86142 143sw.default:                                       ; preds = %for.body144  unreachable, !dbg !87145 146sw.epilog:                                        ; preds = %sw.bb3, %sw.bb2, %sw.bb147  call void @llvm.lifetime.end.p0(ptr %condition), !dbg !88148  br label %for.inc, !dbg !89149 150for.inc:                                          ; preds = %sw.epilog151  %4 = load i32, ptr %j, align 4, !dbg !90, !tbaa !30152  %inc = add nsw i32 %4, 1, !dbg !90153  store i32 %inc, ptr %j, align 4, !dbg !90, !tbaa !30154  br label %for.cond, !dbg !91, !llvm.loop !92155 156for.end:                                          ; preds = %for.cond157  call void @llvm.lifetime.end.p0(ptr %j), !dbg !94158  call void @llvm.lifetime.end.p0(ptr %val), !dbg !94159  ret i32 0, !dbg !95160}161 162; Function Attrs: nounwind readnone willreturn163declare i64 @llvm.expect.i64(i64, i64)164 165declare dso_local i32 @sum(ptr, i32)166 167declare dso_local i32 @random_sample(ptr, i32)168 169!llvm.dbg.cu = !{!2}170!llvm.module.flags = !{!17, !18, !19}171!llvm.ident = !{!20}172 173!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())174!1 = distinct !DIGlobalVariable(name: "inner_loop", scope: !2, file: !3, line: 7, type: !8, isLocal: false, isDefinition: true)175!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, nameTableKind: None)176!3 = !DIFile(filename: "misexpect-switch.c", directory: ".")177!4 = !{}178!5 = !{!0, !6, !10, !12}179!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())180!7 = distinct !DIGlobalVariable(name: "outer_loop", scope: !2, file: !3, line: 8, type: !8, isLocal: false, isDefinition: true)181!8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !9)182!9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)183!10 = !DIGlobalVariableExpression(var: !11, expr: !DIExpression())184!11 = distinct !DIGlobalVariable(name: "arry_size", scope: !2, file: !3, line: 9, type: !8, isLocal: false, isDefinition: true)185!12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression())186!13 = distinct !DIGlobalVariable(name: "arry", scope: !2, file: !3, line: 11, type: !14, isLocal: false, isDefinition: true)187!14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !9, size: 800, elements: !15)188!15 = !{!16}189!16 = !DISubrange(count: 25)190!17 = !{i32 2, !"Dwarf Version", i32 4}191!18 = !{i32 2, !"Debug Info Version", i32 3}192!19 = !{i32 1, !"wchar_size", i32 4}193!20 = !{!"clang version 10.0.0"}194!21 = distinct !DISubprogram(name: "init_arry", scope: !3, file: !3, line: 13, type: !22, scopeLine: 13, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !24)195!22 = !DISubroutineType(types: !23)196!23 = !{null}197!24 = !{!25}198!25 = !DILocalVariable(name: "i", scope: !21, file: !3, line: 14, type: !9)199!26 = !DILocation(line: 14, column: 3, scope: !21)200!27 = !DILocation(line: 14, column: 7, scope: !21)201!28 = !DILocation(line: 15, column: 10, scope: !29)202!29 = distinct !DILexicalBlock(scope: !21, file: !3, line: 15, column: 3)203!30 = !{!31, !31, i64 0}204!31 = !{!"int", !32, i64 0}205!32 = !{!"omnipotent char", !33, i64 0}206!33 = !{!"Simple C/C++ TBAA"}207!34 = !DILocation(line: 15, column: 8, scope: !29)208!35 = !DILocation(line: 15, column: 15, scope: !36)209!36 = distinct !DILexicalBlock(scope: !29, file: !3, line: 15, column: 3)210!37 = !DILocation(line: 15, column: 17, scope: !36)211!38 = !DILocation(line: 15, column: 3, scope: !29)212!39 = !DILocation(line: 16, column: 15, scope: !40)213!40 = distinct !DILexicalBlock(scope: !36, file: !3, line: 15, column: 35)214!41 = !DILocation(line: 16, column: 22, scope: !40)215!42 = !DILocation(line: 16, column: 10, scope: !40)216!43 = !DILocation(line: 16, column: 5, scope: !40)217!44 = !DILocation(line: 16, column: 13, scope: !40)218!45 = !DILocation(line: 17, column: 3, scope: !40)219!46 = !DILocation(line: 15, column: 30, scope: !36)220!47 = !DILocation(line: 15, column: 3, scope: !36)221!48 = distinct !{!48, !38, !49}222!49 = !DILocation(line: 17, column: 3, scope: !29)223!50 = !DILocation(line: 18, column: 1, scope: !21)224!51 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 20, type: !52, scopeLine: 20, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !54)225!52 = !DISubroutineType(types: !53)226!53 = !{!9}227!54 = !{!55, !56, !57}228!55 = !DILocalVariable(name: "val", scope: !51, file: !3, line: 22, type: !9)229!56 = !DILocalVariable(name: "j", scope: !51, file: !3, line: 23, type: !9)230!57 = !DILocalVariable(name: "condition", scope: !58, file: !3, line: 25, type: !61)231!58 = distinct !DILexicalBlock(scope: !59, file: !3, line: 24, column: 49)232!59 = distinct !DILexicalBlock(scope: !60, file: !3, line: 24, column: 3)233!60 = distinct !DILexicalBlock(scope: !51, file: !3, line: 24, column: 3)234!61 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)235!62 = !DILocation(line: 21, column: 3, scope: !51)236!63 = !DILocation(line: 22, column: 3, scope: !51)237!64 = !DILocation(line: 22, column: 7, scope: !51)238!65 = !DILocation(line: 23, column: 3, scope: !51)239!66 = !DILocation(line: 23, column: 7, scope: !51)240!67 = !DILocation(line: 24, column: 10, scope: !60)241!68 = !DILocation(line: 24, column: 8, scope: !60)242!69 = !DILocation(line: 24, column: 15, scope: !59)243!70 = !DILocation(line: 24, column: 17, scope: !59)244!71 = !DILocation(line: 24, column: 3, scope: !60)245!72 = !DILocation(line: 25, column: 5, scope: !58)246!73 = !DILocation(line: 25, column: 14, scope: !58)247!74 = !DILocation(line: 25, column: 26, scope: !58)248!75 = !DILocation(line: 25, column: 33, scope: !58)249!76 = !DILocation(line: 26, column: 30, scope: !58)250!77 = !DILocation(line: 26, column: 13, scope: !58)251!78 = !DILocation(line: 26, column: 5, scope: !58)252!79 = !DILocation(line: 28, column: 14, scope: !80)253!80 = distinct !DILexicalBlock(scope: !58, file: !3, line: 26, column: 45)254!81 = !DILocation(line: 28, column: 11, scope: !80)255!82 = !DILocation(line: 29, column: 7, scope: !80)256!83 = !DILocation(line: 33, column: 7, scope: !80)257!84 = !DILocation(line: 35, column: 14, scope: !80)258!85 = !DILocation(line: 35, column: 11, scope: !80)259!86 = !DILocation(line: 36, column: 7, scope: !80)260!87 = !DILocation(line: 38, column: 7, scope: !80)261!88 = !DILocation(line: 40, column: 3, scope: !59)262!89 = !DILocation(line: 40, column: 3, scope: !58)263!90 = !DILocation(line: 24, column: 44, scope: !59)264!91 = !DILocation(line: 24, column: 3, scope: !59)265!92 = distinct !{!92, !71, !93}266!93 = !DILocation(line: 40, column: 3, scope: !60)267!94 = !DILocation(line: 43, column: 1, scope: !51)268!95 = !DILocation(line: 42, column: 3, scope: !51)269