brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.4 KiB · e0cd883 Raw
177 lines · plain
1; RUN: opt -S %s -passes=sample-profile -sample-profile-file=%S/Inputs/entry_counts_cold.prof -profile-sample-accurate | FileCheck %s2; ModuleID = 'temp.bc'3; This is a test similar to entry_counts_cold.ll. The key differences are:4; - we want profile-sample-accurate. Normally, that would trigger resetting function entry counts to 0, and then update5; them based on the sample profile (SampleProfile::runOnFunction).6; - we don't have debug info for the function. This means we can't match sample counts in the profile to locations in this function.7; When we attempt to update its profile info (at the end of SampleProfile::runOnModule - llvm::updateProfileCallee), we'll call8; updateProfWeight with a 0 priorEntryCount, which will result in a division by 0.9;10; We're using @bar and the call to @baz.11;12; Currently, the test just ensures opt doesn't ICE13source_filename = "temp.c"14target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"15target triple = "x86_64-apple-macosx10.14.0"16 17; Function Attrs: nounwind ssp uwtable18; CHECK: define i32 @top({{.*}} !prof [[TOP:![0-9]+]]19define i32 @top(ptr %p) #0 !dbg !8 {20entry:21  %p.addr = alloca ptr, align 822  store ptr %p, ptr %p.addr, align 8, !tbaa !1523  call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !14, metadata !DIExpression()), !dbg !1924  %0 = load ptr, ptr %p.addr, align 8, !dbg !20, !tbaa !1525  %call = call i32 @foo(ptr %0), !dbg !2126; foo is inlined27; CHECK-NOT: call i32 @foo28; CHECK: call i32 @bar29  %1 = load ptr, ptr %p.addr, align 8, !dbg !22, !tbaa !1530  %2 = load i32, ptr %1, align 4, !dbg !24, !tbaa !2531  %tobool = icmp ne i32 %2, 0, !dbg !2432  br i1 %tobool, label %if.then, label %if.end, !dbg !2733 34if.then:                                          ; preds = %entry35  %3 = load ptr, ptr %p.addr, align 8, !dbg !28, !tbaa !1536; bar is not inlined37; CHECK: call i32 @bar38  %call1 = call i32 @bar(ptr %3), !dbg !2939  br label %if.end, !dbg !2940 41if.end:                                           ; preds = %if.then, %entry42  ret i32 0, !dbg !3043}44 45; Function Attrs: nounwind readnone speculatable46declare void @llvm.dbg.declare(metadata, metadata, metadata) #147 48; Function Attrs: nounwind ssp uwtable49; CHECK: define i32 @foo({{.*}} !prof [[FOO:![0-9]+]]50define i32 @foo(ptr %p) #0 !dbg !31 {51entry:52  %p.addr = alloca ptr, align 853  %a = alloca i32, align 454  store ptr %p, ptr %p.addr, align 8, !tbaa !1555  call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !33, metadata !DIExpression()), !dbg !3556  call void @llvm.lifetime.start.p0(ptr %a) #4, !dbg !3657  call void @llvm.dbg.declare(metadata ptr %a, metadata !34, metadata !DIExpression()), !dbg !3758  %0 = load ptr, ptr %p.addr, align 8, !dbg !38, !tbaa !1559  %arrayidx = getelementptr inbounds i32, ptr %0, i64 3, !dbg !3860  %1 = load i32, ptr %arrayidx, align 4, !dbg !38, !tbaa !2561  %2 = load ptr, ptr %p.addr, align 8, !dbg !39, !tbaa !1562  %arrayidx1 = getelementptr inbounds i32, ptr %2, i64 2, !dbg !3963  %3 = load i32, ptr %arrayidx1, align 4, !dbg !40, !tbaa !2564  %add = add nsw i32 %3, %1, !dbg !4065  store i32 %add, ptr %arrayidx1, align 4, !dbg !40, !tbaa !2566  %4 = load ptr, ptr %p.addr, align 8, !dbg !41, !tbaa !1567  %call = call i32 @bar(ptr %4), !dbg !4268  store i32 %call, ptr %a, align 4, !dbg !43, !tbaa !2569  %5 = load i32, ptr %a, align 4, !dbg !44, !tbaa !2570  %add2 = add nsw i32 %5, 1, !dbg !4571  call void @llvm.lifetime.end.p0(ptr %a) #4, !dbg !4672  ret i32 %add2, !dbg !4773}74 75; Function Attrs: nounwind ssp uwtable76; CHECK: define i32 @bar(ptr %p) #0 !prof [[BAR:![0-9]+]] {77define i32 @bar(ptr %p) #0 {78entry:79  %p.addr = alloca ptr, align 880  store ptr %p, ptr %p.addr, align 8, !tbaa !1581  call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !50, metadata !DIExpression()), !dbg !5182  ; CHECK: call void (...) @baz(), !dbg !{{[0-9]+}}83  call void (...) @baz(), !dbg !52, !prof !10084  %0 = load ptr, ptr %p.addr, align 8, !dbg !53, !tbaa !1585  %arrayidx = getelementptr inbounds i32, ptr %0, i64 2, !dbg !5386  %1 = load i32, ptr %arrayidx, align 4, !dbg !53, !tbaa !2587  %2 = load ptr, ptr %p.addr, align 8, !dbg !54, !tbaa !1588  %arrayidx1 = getelementptr inbounds i32, ptr %2, i64 1, !dbg !5489  %3 = load i32, ptr %arrayidx1, align 4, !dbg !55, !tbaa !2590  %add = add nsw i32 %3, %1, !dbg !5591  store i32 %add, ptr %arrayidx1, align 4, !dbg !55, !tbaa !2592  %4 = load ptr, ptr %p.addr, align 8, !dbg !56, !tbaa !1593  %arrayidx2 = getelementptr inbounds i32, ptr %4, i64 3, !dbg !5694  %5 = load i32, ptr %arrayidx2, align 4, !dbg !56, !tbaa !2595  ret i32 %5, !dbg !5796}97 98; Function Attrs: argmemonly nounwind99declare void @llvm.lifetime.start.p0(ptr nocapture) #2100 101; Function Attrs: argmemonly nounwind102declare void @llvm.lifetime.end.p0(ptr nocapture) #2103 104declare void @baz(...)105 106attributes #0 = { nounwind ssp uwtable "use-sample-profile" }107attributes #1 = { nounwind readnone speculatable }108attributes #2 = { argmemonly nounwind }109attributes #4 = { nounwind }110 111!llvm.dbg.cu = !{!0}112!llvm.module.flags = !{!3, !4, !5, !6}113!llvm.ident = !{!7}114 115; CHECK: [[TOP]] = !{!"function_entry_count", i64 101}116; CHECK: [[FOO]] = !{!"function_entry_count", i64 151}117 118!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)119!1 = !DIFile(filename: "temp.c", directory: "llvm/test/Transforms/SampleProfile")120!2 = !{}121!3 = !{i32 2, !"Dwarf Version", i32 4}122!4 = !{i32 2, !"Debug Info Version", i32 3}123!5 = !{i32 1, !"wchar_size", i32 4}124!6 = !{i32 7, !"PIC Level", i32 2}125!7 = !{!"clang version 8.0.0"}126!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)127!9 = !DISubroutineType(types: !10)128!10 = !{!11, !12}129!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)130!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)131!13 = !{!14}132!14 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 5, type: !12)133!15 = !{!16, !16, i64 0}134!16 = !{!"any pointer", !17, i64 0}135!17 = !{!"omnipotent char", !18, i64 0}136!18 = !{!"Simple C/C++ TBAA"}137!19 = !DILocation(line: 5, column: 14, scope: !8)138!20 = !DILocation(line: 6, column: 7, scope: !8)139!21 = !DILocation(line: 6, column: 3, scope: !8)140!22 = !DILocation(line: 7, column: 8, scope: !23)141!23 = distinct !DILexicalBlock(scope: !8, file: !1, line: 7, column: 7)142!24 = !DILocation(line: 7, column: 7, scope: !23)143!25 = !{!26, !26, i64 0}144!26 = !{!"int", !17, i64 0}145!27 = !DILocation(line: 7, column: 7, scope: !8)146!28 = !DILocation(line: 8, column: 9, scope: !23)147!29 = !DILocation(line: 8, column: 5, scope: !23)148!30 = !DILocation(line: 9, column: 3, scope: !8)149!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)150!32 = !{!33, !34}151!33 = !DILocalVariable(name: "p", arg: 1, scope: !31, file: !1, line: 12, type: !12)152!34 = !DILocalVariable(name: "a", scope: !31, file: !1, line: 13, type: !11)153!35 = !DILocation(line: 12, column: 14, scope: !31)154!36 = !DILocation(line: 13, column: 3, scope: !31)155!37 = !DILocation(line: 13, column: 7, scope: !31)156!38 = !DILocation(line: 14, column: 11, scope: !31)157!39 = !DILocation(line: 14, column: 3, scope: !31)158!40 = !DILocation(line: 14, column: 8, scope: !31)159!41 = !DILocation(line: 15, column: 11, scope: !31)160!42 = !DILocation(line: 15, column: 7, scope: !31)161!43 = !DILocation(line: 15, column: 5, scope: !31)162!44 = !DILocation(line: 16, column: 10, scope: !31)163!45 = !DILocation(line: 16, column: 11, scope: !31)164!46 = !DILocation(line: 17, column: 1, scope: !31)165!47 = !DILocation(line: 16, column: 3, scope: !31)166!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)167!49 = !{!50}168!50 = !DILocalVariable(name: "p", arg: 1, scope: !48, file: !1, line: 19, type: !12)169!51 = !DILocation(line: 19, column: 15, scope: !48)170!52 = !DILocation(line: 20, column: 3, scope: !48)171!53 = !DILocation(line: 21, column: 11, scope: !48)172!54 = !DILocation(line: 21, column: 3, scope: !48)173!55 = !DILocation(line: 21, column: 8, scope: !48)174!56 = !DILocation(line: 22, column: 10, scope: !48)175!57 = !DILocation(line: 22, column: 3, scope: !48)176!100 = !{!"branch_weights", i32 5}177