brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.8 KiB · 4aacde8 Raw
168 lines · plain
1; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/entry_counts_cold.prof -S | FileCheck %s2; ModuleID = 'temp.bc'3source_filename = "temp.c"4target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"5target triple = "x86_64-apple-macosx10.14.0"6 7; Function Attrs: nounwind ssp uwtable8; CHECK: define i32 @top({{.*}} !prof [[TOP:![0-9]+]] 9define i32 @top(ptr %p) #0 !dbg !8 {10entry:11  %p.addr = alloca ptr, align 812  store ptr %p, ptr %p.addr, align 8, !tbaa !1513  call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !14, metadata !DIExpression()), !dbg !1914  %0 = load ptr, ptr %p.addr, align 8, !dbg !20, !tbaa !1515  %call = call i32 @foo(ptr %0), !dbg !2116; foo is inlined17; CHECK-NOT: call i32 @foo18; CHECK: call i32 @bar19  %1 = load ptr, ptr %p.addr, align 8, !dbg !22, !tbaa !1520  %2 = load i32, ptr %1, align 4, !dbg !24, !tbaa !2521  %tobool = icmp ne i32 %2, 0, !dbg !2422  br i1 %tobool, label %if.then, label %if.end, !dbg !2723 24if.then:                                          ; preds = %entry25  %3 = load ptr, ptr %p.addr, align 8, !dbg !28, !tbaa !1526; bar is not inlined27; CHECK: call i32 @bar28  %call1 = call i32 @bar(ptr %3), !dbg !2929  br label %if.end, !dbg !2930 31if.end:                                           ; preds = %if.then, %entry32  ret i32 0, !dbg !3033}34 35; Function Attrs: nounwind readnone speculatable36declare void @llvm.dbg.declare(metadata, metadata, metadata) #137 38; Function Attrs: nounwind ssp uwtable39; CHECK: define i32 @foo({{.*}} !prof [[FOO:![0-9]+]] 40define i32 @foo(ptr %p) #0 !dbg !31 {41entry:42  %p.addr = alloca ptr, align 843  %a = alloca i32, align 444  store ptr %p, ptr %p.addr, align 8, !tbaa !1545  call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !33, metadata !DIExpression()), !dbg !3546  call void @llvm.lifetime.start.p0(ptr %a) #4, !dbg !3647  call void @llvm.dbg.declare(metadata ptr %a, metadata !34, metadata !DIExpression()), !dbg !3748  %0 = load ptr, ptr %p.addr, align 8, !dbg !38, !tbaa !1549  %arrayidx = getelementptr inbounds i32, ptr %0, i64 3, !dbg !3850  %1 = load i32, ptr %arrayidx, align 4, !dbg !38, !tbaa !2551  %2 = load ptr, ptr %p.addr, align 8, !dbg !39, !tbaa !1552  %arrayidx1 = getelementptr inbounds i32, ptr %2, i64 2, !dbg !3953  %3 = load i32, ptr %arrayidx1, align 4, !dbg !40, !tbaa !2554  %add = add nsw i32 %3, %1, !dbg !4055  store i32 %add, ptr %arrayidx1, align 4, !dbg !40, !tbaa !2556  %4 = load ptr, ptr %p.addr, align 8, !dbg !41, !tbaa !1557  %call = call i32 @bar(ptr %4), !dbg !4258  store i32 %call, ptr %a, align 4, !dbg !43, !tbaa !2559  %5 = load i32, ptr %a, align 4, !dbg !44, !tbaa !2560  %add2 = add nsw i32 %5, 1, !dbg !4561  call void @llvm.lifetime.end.p0(ptr %a) #4, !dbg !4662  ret i32 %add2, !dbg !4763}64 65; Function Attrs: nounwind ssp uwtable66; CHECK: define i32 @bar({{.*}} !prof [[BAR:![0-9]+]] 67define i32 @bar(ptr %p) #0 !dbg !48 {68entry:69  %p.addr = alloca ptr, align 870  store ptr %p, ptr %p.addr, align 8, !tbaa !1571  call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !50, metadata !DIExpression()), !dbg !5172  ; CHECK: call void (...) @baz{{.*}} !prof [[BAZ:![0-9]+]]73  call void (...) @baz(), !dbg !5274  %0 = load ptr, ptr %p.addr, align 8, !dbg !53, !tbaa !1575  %arrayidx = getelementptr inbounds i32, ptr %0, i64 2, !dbg !5376  %1 = load i32, ptr %arrayidx, align 4, !dbg !53, !tbaa !2577  %2 = load ptr, ptr %p.addr, align 8, !dbg !54, !tbaa !1578  %arrayidx1 = getelementptr inbounds i32, ptr %2, i64 1, !dbg !5479  %3 = load i32, ptr %arrayidx1, align 4, !dbg !55, !tbaa !2580  %add = add nsw i32 %3, %1, !dbg !5581  store i32 %add, ptr %arrayidx1, align 4, !dbg !55, !tbaa !2582  %4 = load ptr, ptr %p.addr, align 8, !dbg !56, !tbaa !1583  %arrayidx2 = getelementptr inbounds i32, ptr %4, i64 3, !dbg !5684  %5 = load i32, ptr %arrayidx2, align 4, !dbg !56, !tbaa !2585  ret i32 %5, !dbg !5786}87 88; Function Attrs: argmemonly nounwind89declare void @llvm.lifetime.start.p0(ptr nocapture) #290 91; Function Attrs: argmemonly nounwind92declare void @llvm.lifetime.end.p0(ptr nocapture) #293 94declare void @baz(...)95 96attributes #0 = { nounwind ssp uwtable "use-sample-profile" }97attributes #1 = { nounwind readnone speculatable }98attributes #2 = { argmemonly nounwind }99attributes #4 = { nounwind }100 101!llvm.dbg.cu = !{!0}102!llvm.module.flags = !{!3, !4, !5, !6}103!llvm.ident = !{!7}104 105; CHECK: [[TOP]] = !{!"function_entry_count", i64 101}106; CHECK: [[FOO]] = !{!"function_entry_count", i64 151}107; CHECK: [[BAR]] = !{!"function_entry_count", i64 303}108; CHECK: [[BAZ]] = !{!"branch_weights", i32 303}109 110!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: GNU)111!1 = !DIFile(filename: "temp.c", directory: "llvm/test/Transforms/SampleProfile")112!2 = !{}113!3 = !{i32 2, !"Dwarf Version", i32 4}114!4 = !{i32 2, !"Debug Info Version", i32 3}115!5 = !{i32 1, !"wchar_size", i32 4}116!6 = !{i32 7, !"PIC Level", i32 2}117!7 = !{!"clang version 8.0.0"}118!8 = distinct !DISubprogram(name: "top", scope: !1, file: !1, line: 5, type: !9, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)119!9 = !DISubroutineType(types: !10)120!10 = !{!11, !12}121!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)122!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)123!13 = !{!14}124!14 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 5, type: !12)125!15 = !{!16, !16, i64 0}126!16 = !{!"any pointer", !17, i64 0}127!17 = !{!"omnipotent char", !18, i64 0}128!18 = !{!"Simple C/C++ TBAA"}129!19 = !DILocation(line: 5, column: 14, scope: !8)130!20 = !DILocation(line: 6, column: 7, scope: !8)131!21 = !DILocation(line: 6, column: 3, scope: !8)132!22 = !DILocation(line: 7, column: 8, scope: !23)133!23 = distinct !DILexicalBlock(scope: !8, file: !1, line: 7, column: 7)134!24 = !DILocation(line: 7, column: 7, scope: !23)135!25 = !{!26, !26, i64 0}136!26 = !{!"int", !17, i64 0}137!27 = !DILocation(line: 7, column: 7, scope: !8)138!28 = !DILocation(line: 8, column: 9, scope: !23)139!29 = !DILocation(line: 8, column: 5, scope: !23)140!30 = !DILocation(line: 9, column: 3, scope: !8)141!31 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 12, type: !9, scopeLine: 12, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !32)142!32 = !{!33, !34}143!33 = !DILocalVariable(name: "p", arg: 1, scope: !31, file: !1, line: 12, type: !12)144!34 = !DILocalVariable(name: "a", scope: !31, file: !1, line: 13, type: !11)145!35 = !DILocation(line: 12, column: 14, scope: !31)146!36 = !DILocation(line: 13, column: 3, scope: !31)147!37 = !DILocation(line: 13, column: 7, scope: !31)148!38 = !DILocation(line: 14, column: 11, scope: !31)149!39 = !DILocation(line: 14, column: 3, scope: !31)150!40 = !DILocation(line: 14, column: 8, scope: !31)151!41 = !DILocation(line: 15, column: 11, scope: !31)152!42 = !DILocation(line: 15, column: 7, scope: !31)153!43 = !DILocation(line: 15, column: 5, scope: !31)154!44 = !DILocation(line: 16, column: 10, scope: !31)155!45 = !DILocation(line: 16, column: 11, scope: !31)156!46 = !DILocation(line: 17, column: 1, scope: !31)157!47 = !DILocation(line: 16, column: 3, scope: !31)158!48 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 19, type: !9, scopeLine: 19, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !49)159!49 = !{!50}160!50 = !DILocalVariable(name: "p", arg: 1, scope: !48, file: !1, line: 19, type: !12)161!51 = !DILocation(line: 19, column: 15, scope: !48)162!52 = !DILocation(line: 20, column: 3, scope: !48)163!53 = !DILocation(line: 21, column: 11, scope: !48)164!54 = !DILocation(line: 21, column: 3, scope: !48)165!55 = !DILocation(line: 21, column: 8, scope: !48)166!56 = !DILocation(line: 22, column: 10, scope: !48)167!57 = !DILocation(line: 22, column: 3, scope: !48)168