brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · 60b73bb Raw
126 lines · plain
1; Note that this needs new pass manager for now. Passing `-sample-profile-top-down-load` to legacy pass manager is a no-op.2 3; Test we aren't doing specialization for inlining with default source order4; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-top-down-load=false -S | FileCheck -check-prefix=DEFAULT %s5 6; Test we specialize based on call path with context-sensitive profile while inlining with '-sample-profile-top-down-load'7; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-topdown.prof -sample-profile-merge-inlinee -sample-profile-top-down-load=true -S | FileCheck -check-prefix=TOPDOWN  %s8 9 10@.str = private unnamed_addr constant [11 x i8] c"sum is %d\0A\00", align 111 12define i32 @_Z3sumii(i32 %x, i32 %y) #0 !dbg !6 {13entry:14  %x.addr = alloca i32, align 415  %y.addr = alloca i32, align 416  store i32 %x, ptr %x.addr, align 417  store i32 %y, ptr %y.addr, align 418  %tmp = load i32, ptr %x.addr, align 4, !dbg !819  %tmp1 = load i32, ptr %y.addr, align 4, !dbg !820  %add = add nsw i32 %tmp, %tmp1, !dbg !821  %tmp2 = load i32, ptr %x.addr, align 4, !dbg !822  %tmp3 = load i32, ptr %y.addr, align 4, !dbg !823  %call = call i32 @_Z3subii(i32 %tmp2, i32 %tmp3), !dbg !824  ret i32 %add, !dbg !825}26 27define i32 @_Z3subii(i32 %x, i32 %y) #0 !dbg !9 {28entry:29  %x.addr = alloca i32, align 430  %y.addr = alloca i32, align 431  store i32 %x, ptr %x.addr, align 432  store i32 %y, ptr %y.addr, align 433  %tmp = load i32, ptr %x.addr, align 4, !dbg !1034  %tmp1 = load i32, ptr %y.addr, align 4, !dbg !1035  %add = sub nsw i32 %tmp, %tmp1, !dbg !1036  ret i32 %add, !dbg !1137}38 39define i32 @main() #0 !dbg !12 {40entry:41  %retval = alloca i32, align 442  %s = alloca i32, align 443  %i = alloca i32, align 444  store i32 0, ptr %retval45  store i32 0, ptr %i, align 4, !dbg !1346  br label %while.cond, !dbg !1447 48while.cond:                                       ; preds = %if.end, %entry49  %tmp = load i32, ptr %i, align 4, !dbg !1550  %inc = add nsw i32 %tmp, 1, !dbg !1551  store i32 %inc, ptr %i, align 4, !dbg !1552  %cmp = icmp slt i32 %tmp, 400000000, !dbg !1553  br i1 %cmp, label %while.body, label %while.end, !dbg !1554 55while.body:                                       ; preds = %while.cond56  %tmp1 = load i32, ptr %i, align 4, !dbg !1757  %cmp1 = icmp ne i32 %tmp1, 100, !dbg !1758  br i1 %cmp1, label %if.then, label %if.else, !dbg !1759 60if.then:                                          ; preds = %while.body61  %tmp2 = load i32, ptr %i, align 4, !dbg !1962  %tmp3 = load i32, ptr %s, align 4, !dbg !1963  %call = call i32 @_Z3sumii(i32 %tmp2, i32 %tmp3), !dbg !1964  store i32 %call, ptr %s, align 4, !dbg !1965  br label %if.end, !dbg !1966 67if.else:                                          ; preds = %while.body68  store i32 30, ptr %s, align 4, !dbg !2169  br label %if.end70 71if.end:                                           ; preds = %if.else, %if.then72  br label %while.cond, !dbg !2373 74while.end:                                        ; preds = %while.cond75  %tmp4 = load i32, ptr %s, align 4, !dbg !2576  %call2 = call i32 (ptr, ...) @printf(ptr @.str, i32 %tmp4), !dbg !2577  ret i32 0, !dbg !2678}79 80declare i32 @printf(ptr, ...)81 82attributes #0 = { "use-sample-profile" }83 84!llvm.dbg.cu = !{!0}85!llvm.module.flags = !{!3, !4}86!llvm.ident = !{!5}87 88!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5 ", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)89!1 = !DIFile(filename: "calls.cc", directory: ".")90!2 = !{}91!3 = !{i32 2, !"Dwarf Version", i32 4}92!4 = !{i32 1, !"Debug Info Version", i32 3}93!5 = !{!"clang version 3.5 "}94!6 = distinct !DISubprogram(name: "sum", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)95!7 = !DISubroutineType(types: !2)96!8 = !DILocation(line: 4, scope: !6)97!9 = distinct !DISubprogram(name: "sub", scope: !1, file: !1, line: 20, type: !7, scopeLine: 20, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)98!10 = !DILocation(line: 20, scope: !9)99!11 = !DILocation(line: 21, scope: !9)100!12 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 7, type: !7, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)101!13 = !DILocation(line: 8, scope: !12)102!14 = !DILocation(line: 9, scope: !12)103!15 = !DILocation(line: 9, scope: !16)104!16 = !DILexicalBlockFile(scope: !12, file: !1, discriminator: 2)105!17 = !DILocation(line: 10, scope: !18)106!18 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10)107!19 = !DILocation(line: 10, scope: !20)108!20 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 2)109!21 = !DILocation(line: 10, scope: !22)110!22 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 4)111!23 = !DILocation(line: 10, scope: !24)112!24 = !DILexicalBlockFile(scope: !18, file: !1, discriminator: 6)113!25 = !DILocation(line: 11, scope: !12)114!26 = !DILocation(line: 12, scope: !12)115 116 117; DEFAULT: @_Z3sumii118; DEFAULT-NOT: call i32 @_Z3subii119; DEFAULT: @main()120; DEFAULT-NOT: call i32 @_Z3subii121 122; TOPDOWN: @_Z3sumii123; TOPDOWN-NOT: call i32 @_Z3subii124; TOPDOWN: @main()125; TOPDOWN: call i32 @_Z3subii126