brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.0 KiB · a7667fc Raw
245 lines · plain
1; Test that misexpect diagnostics are issued in sample profiling2; RUN: opt < %s -passes="function(lower-expect),sample-profile" -sample-profile-file=%S/Inputs/misexpect.prof -pgo-warn-misexpect -S 2>&1  | FileCheck %s --check-prefix=WARNING3 4; Test that if expect intrinsics are not lowered, then no diagnostics are issued5; RUN: opt < %s -passes="sample-profile" -sample-profile-file=%S/Inputs/misexpect.prof -pgo-warn-misexpect -S 2>&1  | FileCheck %s --check-prefix=NONE6 7; Original C++ code for this test case:8;9; #include <stdio.h>10; #include <stdlib.h>11 12; int main(int argc, char *argv[]) {13;   if (argc < 2)14;     return 1;15;   double result;16;   int limit = atoi(argv[1]);17;   if (limit > 100) {18;     double s = 23.041968 * atoi(argv[2]);19;     for (int u = 0; u < limit; u++) {20;       double x = s;21;       s = x + 3.049 + (double)u;22;       s -= s + 3.94 / x * 0.32;23;     }24;     result = s;25;   } else {26;     result = atoi(argv[2]);27;   }28;   printf("result is %lf\n", result);29;   return 0;30; }31 32; WARNING-DAG: warning: test.cc:9:14: 20.06%33; WARNING-DAG: warning: test.cc:11:24: 92.74%34 35; NONE-NOT: warning: test.cc:9:14: 20.06%36; NONE-NOT: warning: test.cc:11:24: 92.74%37 38@.str = private unnamed_addr constant [15 x i8] c"result is %lf\0A\00", align 139 40; Function Attrs: uwtable41define i32 @main(i32 %argc, ptr %argv) #0 !dbg !6 {42 43entry:44  %retval = alloca i32, align 445  %argc.addr = alloca i32, align 446  %argv.addr = alloca ptr, align 847  %result = alloca double, align 848  %limit = alloca i32, align 449  %s = alloca double, align 850  %u = alloca i32, align 451  %x = alloca double, align 852  store i32 0, ptr %retval, align 453  store i32 %argc, ptr %argc.addr, align 454  call void @llvm.dbg.declare(metadata ptr %argc.addr, metadata !16, metadata !17), !dbg !1855  store ptr %argv, ptr %argv.addr, align 856  call void @llvm.dbg.declare(metadata ptr %argv.addr, metadata !19, metadata !17), !dbg !2057  %0 = load i32, ptr %argc.addr, align 4, !dbg !2158  %cmp = icmp slt i32 %0, 2, !dbg !2359  br i1 %cmp, label %if.then, label %if.end, !dbg !2460 61if.then:                                          ; preds = %entry62  store i32 1, ptr %retval, align 4, !dbg !2563  br label %return, !dbg !2564 65if.end:                                           ; preds = %entry66  call void @llvm.dbg.declare(metadata ptr %result, metadata !26, metadata !17), !dbg !2767  call void @llvm.dbg.declare(metadata ptr %limit, metadata !28, metadata !17), !dbg !2968  %1 = load ptr, ptr %argv.addr, align 8, !dbg !3069  %arrayidx = getelementptr inbounds ptr, ptr %1, i64 1, !dbg !3070  %2 = load ptr, ptr %arrayidx, align 8, !dbg !3071  %call = call i32 @atoi(ptr %2), !dbg !3172  store i32 %call, ptr %limit, align 4, !dbg !2973  %3 = load i32, ptr %limit, align 4, !dbg !3274  %exp = call i32 @llvm.expect.i32(i32 %3, i32 0)75  %tobool = icmp ne i32 %exp, 0, !dbg !3476  br i1 %tobool, label %if.then.2, label %if.else, !dbg !3577 78if.then.2:                                        ; preds = %if.end79  call void @llvm.dbg.declare(metadata ptr %s, metadata !36, metadata !17), !dbg !3880  %4 = load ptr, ptr %argv.addr, align 8, !dbg !3981  %arrayidx3 = getelementptr inbounds ptr, ptr %4, i64 2, !dbg !3982  %5 = load ptr, ptr %arrayidx3, align 8, !dbg !3983  %call4 = call i32 @atoi(ptr %5), !dbg !4084  %conv = sitofp i32 %call4 to double, !dbg !4085  %mul = fmul double 0x40370ABE6A337A81, %conv, !dbg !4186  store double %mul, ptr %s, align 8, !dbg !3887  call void @llvm.dbg.declare(metadata ptr %u, metadata !42, metadata !17), !dbg !4488  store i32 0, ptr %u, align 4, !dbg !4489  br label %for.cond, !dbg !4590 91for.cond:                                         ; preds = %for.inc, %if.then.292  %6 = load i32, ptr %u, align 4, !dbg !4693  %7 = load i32, ptr %limit, align 4, !dbg !4894  %expval = call i32 @llvm.expect.i32(i32 %6, i32 1)95  %cmp5 = icmp ne i32 %expval, 0, !dbg !4996  br i1 %cmp5, label %for.body, label %for.end, !dbg !5097 98for.body:                                         ; preds = %for.cond99  call void @llvm.dbg.declare(metadata ptr %x, metadata !51, metadata !17), !dbg !53100  %8 = load double, ptr %s, align 8, !dbg !54101  store double %8, ptr %x, align 8, !dbg !53102  %9 = load double, ptr %x, align 8, !dbg !55103  %add = fadd double %9, 3.049000e+00, !dbg !56104  %10 = load i32, ptr %u, align 4, !dbg !57105  %conv6 = sitofp i32 %10 to double, !dbg !57106  %add7 = fadd double %add, %conv6, !dbg !58107  store double %add7, ptr %s, align 8, !dbg !59108  %11 = load double, ptr %s, align 8, !dbg !60109  %12 = load double, ptr %x, align 8, !dbg !61110  %div = fdiv double 3.940000e+00, %12, !dbg !62111  %mul8 = fmul double %div, 3.200000e-01, !dbg !63112  %add9 = fadd double %11, %mul8, !dbg !64113  %13 = load double, ptr %s, align 8, !dbg !65114  %sub = fsub double %13, %add9, !dbg !65115  store double %sub, ptr %s, align 8, !dbg !65116  br label %for.inc, !dbg !66117 118for.inc:                                          ; preds = %for.body119  %14 = load i32, ptr %u, align 4, !dbg !67120  %inc = add nsw i32 %14, 1, !dbg !67121  store i32 %inc, ptr %u, align 4, !dbg !67122  br label %for.cond, !dbg !68123 124for.end:                                          ; preds = %for.cond125  %15 = load double, ptr %s, align 8, !dbg !69126  store double %15, ptr %result, align 8, !dbg !70127  br label %if.end.13, !dbg !71128 129if.else:                                          ; preds = %if.end130  %16 = load ptr, ptr %argv.addr, align 8, !dbg !72131  %arrayidx10 = getelementptr inbounds ptr, ptr %16, i64 2, !dbg !72132  %17 = load ptr, ptr %arrayidx10, align 8, !dbg !72133  %call11 = call i32 @atoi(ptr %17), !dbg !74134  %conv12 = sitofp i32 %call11 to double, !dbg !74135  store double %conv12, ptr %result, align 8, !dbg !75136  br label %if.end.13137 138if.end.13:                                        ; preds = %if.else, %for.end139  %18 = load double, ptr %result, align 8, !dbg !76140  %call14 = call i32 (ptr, ...) @printf(ptr @.str, double %18), !dbg !77141  store i32 0, ptr %retval, align 4, !dbg !78142  br label %return, !dbg !78143 144return:                                           ; preds = %if.end.13, %if.then145  %19 = load i32, ptr %retval, align 4, !dbg !79146  ret i32 %19, !dbg !79147}148 149; Function Attrs: nounwind readnone150declare void @llvm.dbg.declare(metadata, metadata, metadata)151 152; Function Attrs: nounwind readonly153declare i32 @atoi(ptr)154 155declare i32 @printf(ptr, ...)156 157; Function Attrs: nounwind readnone willreturn158declare i32 @llvm.expect.i32(i32, i32)159 160attributes #0 = { uwtable "use-sample-profile" }161 162!llvm.dbg.cu = !{!0}163!llvm.module.flags = !{!13, !14}164!llvm.ident = !{!15}165 166!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)167!1 = !DIFile(filename: "test.cc", directory: "/ssd/llvm_commit")168!2 = !{}169!3 = !{!4}170!4 = !DIBasicType(name: "double", size: 64, align: 64, encoding: DW_ATE_float)171!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, retainedNodes: !2)172!7 = !DISubroutineType(types: !8)173!8 = !{!9, !9, !10}174!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)175!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, align: 64)176!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64, align: 64)177!12 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)178!13 = !{i32 2, !"Dwarf Version", i32 4}179!14 = !{i32 2, !"Debug Info Version", i32 3}180!15 = !{!"clang version 3.8.0 (trunk 248211) (llvm/trunk 248217)"}181!16 = !DILocalVariable(name: "argc", arg: 1, scope: !6, file: !1, line: 4, type: !9)182!17 = !DIExpression()183!18 = !DILocation(line: 4, column: 15, scope: !6)184!19 = !DILocalVariable(name: "argv", arg: 2, scope: !6, file: !1, line: 4, type: !10)185!20 = !DILocation(line: 4, column: 27, scope: !6)186!21 = !DILocation(line: 5, column: 8, scope: !22)187!22 = distinct !DILexicalBlock(scope: !6, file: !1, line: 5, column: 8)188!23 = !DILocation(line: 5, column: 13, scope: !22)189!24 = !DILocation(line: 5, column: 8, scope: !6)190!25 = !DILocation(line: 6, column: 6, scope: !22)191!26 = !DILocalVariable(name: "result", scope: !6, file: !1, line: 7, type: !4)192!27 = !DILocation(line: 7, column: 11, scope: !6)193!28 = !DILocalVariable(name: "limit", scope: !6, file: !1, line: 8, type: !9)194!29 = !DILocation(line: 8, column: 8, scope: !6)195!30 = !DILocation(line: 8, column: 21, scope: !6)196!31 = !DILocation(line: 8, column: 16, scope: !6)197!32 = !DILocation(line: 9, column: 8, scope: !33)198!33 = distinct !DILexicalBlock(scope: !6, file: !1, line: 9, column: 8)199!34 = !DILocation(line: 9, column: 14, scope: !33)200!35 = !DILocation(line: 9, column: 8, scope: !6)201!36 = !DILocalVariable(name: "s", scope: !37, file: !1, line: 10, type: !4)202!37 = distinct !DILexicalBlock(scope: !33, file: !1, line: 9, column: 21)203!38 = !DILocation(line: 10, column: 13, scope: !37)204!39 = !DILocation(line: 10, column: 34, scope: !37)205!40 = !DILocation(line: 10, column: 29, scope: !37)206!41 = !DILocation(line: 10, column: 27, scope: !37)207!42 = !DILocalVariable(name: "u", scope: !43, file: !1, line: 11, type: !9)208!43 = distinct !DILexicalBlock(scope: !37, file: !1, line: 11, column: 6)209!44 = !DILocation(line: 11, column: 15, scope: !43)210!45 = !DILocation(line: 11, column: 11, scope: !43)211!46 = !DILocation(line: 11, column: 22, scope: !47)212!47 = distinct !DILexicalBlock(scope: !43, file: !1, line: 11, column: 6)213!48 = !DILocation(line: 11, column: 26, scope: !47)214!49 = !DILocation(line: 11, column: 24, scope: !47)215!50 = !DILocation(line: 11, column: 6, scope: !43)216!51 = !DILocalVariable(name: "x", scope: !52, file: !1, line: 12, type: !4)217!52 = distinct !DILexicalBlock(scope: !47, file: !1, line: 11, column: 38)218!53 = !DILocation(line: 12, column: 15, scope: !52)219!54 = !DILocation(line: 12, column: 19, scope: !52)220!55 = !DILocation(line: 13, column: 12, scope: !52)221!56 = !DILocation(line: 13, column: 14, scope: !52)222!57 = !DILocation(line: 13, column: 32, scope: !52)223!58 = !DILocation(line: 13, column: 22, scope: !52)224!59 = !DILocation(line: 13, column: 10, scope: !52)225!60 = !DILocation(line: 14, column: 13, scope: !52)226!61 = !DILocation(line: 14, column: 24, scope: !52)227!62 = !DILocation(line: 14, column: 22, scope: !52)228!63 = !DILocation(line: 14, column: 26, scope: !52)229!64 = !DILocation(line: 14, column: 15, scope: !52)230!65 = !DILocation(line: 14, column: 10, scope: !52)231!66 = !DILocation(line: 15, column: 6, scope: !52)232!67 = !DILocation(line: 11, column: 34, scope: !47)233!68 = !DILocation(line: 11, column: 6, scope: !47)234!69 = !DILocation(line: 16, column: 15, scope: !37)235!70 = !DILocation(line: 16, column: 13, scope: !37)236!71 = !DILocation(line: 17, column: 4, scope: !37)237!72 = !DILocation(line: 18, column: 20, scope: !73)238!73 = distinct !DILexicalBlock(scope: !33, file: !1, line: 17, column: 11)239!74 = !DILocation(line: 18, column: 15, scope: !73)240!75 = !DILocation(line: 18, column: 13, scope: !73)241!76 = !DILocation(line: 20, column: 30, scope: !6)242!77 = !DILocation(line: 20, column: 4, scope: !6)243!78 = !DILocation(line: 21, column: 4, scope: !6)244!79 = !DILocation(line: 22, column: 2, scope: !6)245