brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · ba53c57 Raw
130 lines · plain
1;; Tests memprof when contains loop unroll of allocation, where the unrolled2;; allocations have the same context but different allocation types.3 4;; Avoid failures on big-endian systems that can't read the profile properly5; REQUIRES: x86_64-linux6 7; Generate the profile and the IR.8; RUN: split-file %s %t9 10;; Generate indexed profile11; RUN: llvm-profdata merge %t/memprof_loop_unroll.yaml -o %t.memprofdata12 13;; Set the minimum lifetime threshold to 0 to ensure that one context is14;; considered cold (the other will be notcold).15; RUN: opt < %t/memprof_loop_unroll.ll -passes='memprof-use<profile-filename=%t.memprofdata>' -S -memprof-report-hinted-sizes -memprof-ave-lifetime-cold-threshold=0 2>&1 | FileCheck %s16 17;; Conservatively annotate as not cold.18; CHECK: MemProf hinting: Total size for full allocation context hash {{.*}} and single alloc type notcold: 419; CHECK: call {{.*}} @_Znam{{.*}} #[[ATTR:[0-9]+]]20; CHECK: attributes #[[ATTR]] = { builtin allocsize(0) "memprof"="notcold" }21; CHECK-NOT: stackIds: ()22 23;--- memprof_loop_unroll.yaml24---25HeapProfileRecords:26  - GUID:            0x7f8d88fcc70a347b27    AllocSites:28      - Callstack:29          - { Function: 0x7f8d88fcc70a347b, LineOffset: 2, Column: 16, IsInlineFrame: false }30          - { Function: 0xdb956436e78dd5fa, LineOffset: 1, Column: 5, IsInlineFrame: false }31        MemInfoBlock:32          AllocCount:      133          TotalSize:       434          TotalLifetime:   235          TotalLifetimeAccessDensity: 1250000000036      - Callstack:37          - { Function: 0x7f8d88fcc70a347b, LineOffset: 2, Column: 16, IsInlineFrame: false }38          - { Function: 0xdb956436e78dd5fa, LineOffset: 1, Column: 5, IsInlineFrame: false }39        MemInfoBlock:40          AllocCount:      141          TotalSize:       442          TotalLifetime:   243          TotalLifetimeAccessDensity: 044  - GUID:            0xdb956436e78dd5fa45    CallSites:46      - Frames:47          - { Function: 0xdb956436e78dd5fa, LineOffset: 1, Column: 5, IsInlineFrame: false }48...49 50;--- memprof_loop_unroll.ll51; ModuleID = 'memprof_loop_unroll_b.cc'52source_filename = "memprof_loop_unroll_b.cc"53target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"54target triple = "x86_64-unknown-linux-gnu"55 56@a = external global [2 x ptr], align 1657 58; Function Attrs: mustprogress noinline optnone uwtable59define dso_local void @_Z3foov() #0 !dbg !10 {60entry:61  %i = alloca i32, align 462  store i32 0, ptr %i, align 4, !dbg !1363  br label %for.cond, !dbg !1464 65for.cond:                                         ; preds = %for.inc, %entry66  %0 = load i32, ptr %i, align 4, !dbg !1567  %cmp = icmp slt i32 %0, 2, !dbg !1768  br i1 %cmp, label %for.body, label %for.end, !dbg !1869 70for.body:                                         ; preds = %for.cond71  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 4) #2, !dbg !1972  %1 = load i32, ptr %i, align 4, !dbg !2073  %idxprom = sext i32 %1 to i64, !dbg !2174  %arrayidx = getelementptr inbounds [2 x ptr], ptr @a, i64 0, i64 %idxprom, !dbg !2175  store ptr %call, ptr %arrayidx, align 8, !dbg !2276  br label %for.inc, !dbg !2377 78for.inc:                                          ; preds = %for.body79  %2 = load i32, ptr %i, align 4, !dbg !2480  %inc = add nsw i32 %2, 1, !dbg !2481  store i32 %inc, ptr %i, align 4, !dbg !2482  br label %for.cond, !dbg !26, !llvm.loop !2783 84for.end:                                          ; preds = %for.cond85  ret void, !dbg !3086}87 88; Function Attrs: nobuiltin allocsize(0)89declare noundef nonnull ptr @_Znam(i64 noundef) #190 91attributes #0 = { mustprogress noinline optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }92attributes #1 = { nobuiltin allocsize(0) "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }93attributes #2 = { builtin allocsize(0) }94 95!llvm.dbg.cu = !{!0}96!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}97!llvm.ident = !{!9}98 99!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 18.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)100!1 = !DIFile(filename: "memprof_loop_unroll_b.cc", directory: "/", checksumkind: CSK_MD5, checksum: "00276e590d606451dc54f3ff5f4bba25")101!2 = !{i32 7, !"Dwarf Version", i32 5}102!3 = !{i32 2, !"Debug Info Version", i32 3}103!4 = !{i32 1, !"wchar_size", i32 4}104!5 = !{i32 8, !"PIC Level", i32 2}105!6 = !{i32 7, !"PIE Level", i32 2}106!7 = !{i32 7, !"uwtable", i32 2}107!8 = !{i32 7, !"frame-pointer", i32 2}108!9 = !{!"clang version 18.0.0"}109!10 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)110!11 = !DISubroutineType(types: !12)111!12 = !{}112!13 = !DILocation(line: 5, column: 14, scope: !10)113!14 = !DILocation(line: 5, column: 10, scope: !10)114!15 = !DILocation(line: 5, column: 21, scope: !16)115!16 = !DILexicalBlockFile(scope: !10, file: !1, discriminator: 2)116!17 = !DILocation(line: 5, column: 23, scope: !16)117!18 = !DILocation(line: 5, column: 5, scope: !16)118!19 = !DILocation(line: 6, column: 16, scope: !10)119!20 = !DILocation(line: 6, column: 11, scope: !10)120!21 = !DILocation(line: 6, column: 9, scope: !10)121!22 = !DILocation(line: 6, column: 14, scope: !10)122!23 = !DILocation(line: 7, column: 5, scope: !10)123!24 = !DILocation(line: 5, column: 28, scope: !25)124!25 = !DILexicalBlockFile(scope: !10, file: !1, discriminator: 4)125!26 = !DILocation(line: 5, column: 5, scope: !25)126!27 = distinct !{!27, !28, !23, !29}127!28 = !DILocation(line: 5, column: 5, scope: !10)128!29 = !{!"llvm.loop.mustprogress"}129!30 = !DILocation(line: 8, column: 1, scope: !10)130