xref: /llvm-project/llvm/test/Transforms/SampleProfile/inline-act.ll (revision 0271ae65a66367d802fa6866599d11e35f68450f)
15250e7a0SFangrui Song; RUN: opt %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline-act.prof
2cee313d2SEric Christopher
3cee313d2SEric Christopher; Sample profile should have non-empty ACT passed to inliner
4cee313d2SEric Christopher
5cee313d2SEric Christopher; int t;
6cee313d2SEric Christopher; bool foo(int value) {
7cee313d2SEric Christopher;   switch(value) {
8cee313d2SEric Christopher;     case 0:
9cee313d2SEric Christopher;     case 1:
10cee313d2SEric Christopher;     case 3:
11cee313d2SEric Christopher;       return true;
12cee313d2SEric Christopher;     default:
13cee313d2SEric Christopher;       return false;
14cee313d2SEric Christopher;   }
15cee313d2SEric Christopher; }
16cee313d2SEric Christopher; void bar(int i) {
17cee313d2SEric Christopher;   if (foo(i))
18cee313d2SEric Christopher;     t *= 2;
19cee313d2SEric Christopher; }
20cee313d2SEric Christopher
21cee313d2SEric Christophertarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22cee313d2SEric Christophertarget triple = "x86_64-unknown-linux-gnu"
23cee313d2SEric Christopher
24cee313d2SEric Christopher@t = global i32 0, align 4
25cee313d2SEric Christopher
26cee313d2SEric Christopher; Function Attrs: nounwind uwtable
27cee313d2SEric Christopherdefine zeroext i1 @_Z3fooi(i32) #0 {
28cee313d2SEric Christopher  %switch.tableidx = sub i32 %0, 0
29cee313d2SEric Christopher  %2 = icmp ult i32 %switch.tableidx, 4
30cee313d2SEric Christopher  br i1 %2, label %switch.lookup, label %3
31cee313d2SEric Christopher
32cee313d2SEric Christopherswitch.lookup:                                    ; preds = %1
33cee313d2SEric Christopher  %switch.cast = trunc i32 %switch.tableidx to i4
34cee313d2SEric Christopher  %switch.shiftamt = mul i4 %switch.cast, 1
35cee313d2SEric Christopher  %switch.downshift = lshr i4 -5, %switch.shiftamt
36cee313d2SEric Christopher  %switch.masked = trunc i4 %switch.downshift to i1
37cee313d2SEric Christopher  ret i1 %switch.masked
38cee313d2SEric Christopher
39cee313d2SEric Christopher; <label>:3:                                      ; preds = %1
40cee313d2SEric Christopher  ret i1 false
41cee313d2SEric Christopher}
42cee313d2SEric Christopher
43cee313d2SEric Christopher; Function Attrs: nounwind uwtable
44cee313d2SEric Christopherdefine void @_Z3bari(i32) #0 !dbg !9 {
45cee313d2SEric Christopher  %2 = call zeroext i1 @_Z3fooi(i32 %0), !dbg !10
46cee313d2SEric Christopher  br i1 %2, label %3, label %6, !dbg !10
47cee313d2SEric Christopher
48cee313d2SEric Christopher; <label>:3:                                      ; preds = %1
49*0271ae65SFangrui Song  %4 = load i32, ptr @t, align 4
50cee313d2SEric Christopher  %5 = shl nsw i32 %4, 1
51*0271ae65SFangrui Song  store i32 %5, ptr @t, align 4
52cee313d2SEric Christopher  br label %6
53cee313d2SEric Christopher
54cee313d2SEric Christopher; <label>:6:                                      ; preds = %3, %1
55cee313d2SEric Christopher  ret void
56cee313d2SEric Christopher}
57cee313d2SEric Christopher
584ab3041aSserge-sans-pailleattributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
59cee313d2SEric Christopher
60cee313d2SEric Christopher!llvm.dbg.cu = !{!0}
61cee313d2SEric Christopher!llvm.module.flags = !{!3}
62cee313d2SEric Christopher!llvm.ident = !{!4}
63cee313d2SEric Christopher
64cee313d2SEric Christopher!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 272227) (llvm/trunk 272226)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
65cee313d2SEric Christopher!1 = !DIFile(filename: "test.cc", directory: "./")
66cee313d2SEric Christopher!2 = !{}
67cee313d2SEric Christopher!3 = !{i32 2, !"Debug Info Version", i32 3}
68cee313d2SEric Christopher!4 = !{!"clang version 3.9.0 (trunk 272227) (llvm/trunk 272226)"}
69cee313d2SEric Christopher!6 = !DISubroutineType(types: !2)
70cee313d2SEric Christopher!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 14, type: !6, isLocal: false, isDefinition: true, scopeLine: 14, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
71cee313d2SEric Christopher!10 = !DILocation(line: 15, column: 7, scope: !9)
72cee313d2SEric Christopher!11 = !DILocation(line: 16, column: 7, scope: !9)
73