xref: /llvm-project/llvm/test/Transforms/GlobalOpt/PowerPC/coldcc_coldsites.ll (revision 51d4c7ceea61b5d83ba52398b5ca6d58d7551044)
1; RUN: opt -strip-debug -S < %s | opt -passes=globalopt -mtriple=powerpc64le-unknown-linux-gnu -ppc-enable-coldcc -S | FileCheck %s -check-prefix=COLDCC
2; RUN: opt -strip-debug -S < %s | opt -passes=globalopt -S | FileCheck %s -check-prefix=CHECK
3; RUN: opt -passes=globalopt -mtriple=powerpc64le-unknown-linux-gnu -ppc-enable-coldcc -S < %s | FileCheck %s -check-prefix=COLDCC
4; RUN: opt -passes=globalopt -S < %s | FileCheck %s -check-prefix=CHECK
5
6define signext i32 @caller(i32 signext %a, i32 signext %b, i32 signext %lim, i32 signext %i, ptr %k) local_unnamed_addr #0 !prof !30 {
7entry:
8; COLDCC: call coldcc signext i32 @callee
9; CHECK: call fastcc signext i32 @callee
10  %add = add nsw i32 %b, %a
11  %sub = add nsw i32 %lim, -1
12  %cmp = icmp eq i32 %sub, %i
13  br i1 %cmp, label %if.then, label %if.end, !prof !31
14
15if.then:                                          ; preds = %entry
16  call void @llvm.dbg.declare(metadata ptr %k, metadata !101, metadata !DIExpression()), !dbg !122
17  %call = tail call signext i32 @callee(i32 signext %a, i32 signext %b)
18  br label %if.end
19
20if.end:                                           ; preds = %if.then, %entry
21  %f.0 = phi i32 [ %call, %if.then ], [ %add, %entry ]
22  ret i32 %f.0
23}
24
25define internal signext i32 @callee(i32 signext %a, i32 signext %b) unnamed_addr #0 {
26entry:
27  %0 = tail call i32 asm "add $0, $1, $2", "=r,r,r,~{r6},~{r7},~{r8},~{r9}"(i32 %a, i32 %b) #1, !srcloc !32
28  %mul = mul nsw i32 %a, 3
29  %mul1 = shl i32 %0, 1
30  %add = add nsw i32 %mul1, %mul
31  ret i32 %add
32}
33
34define signext i32 @main() local_unnamed_addr #0 !prof !33 {
35entry:
36  br label %for.body
37
38for.cond.cleanup:                                 ; preds = %for.body
39  %add.lcssa = phi i32 [ %add, %for.body ]
40  ret i32 %add.lcssa
41
42for.body:                                         ; preds = %for.body, %entry
43  %i.011 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
44  %ret.010 = phi i32 [ 0, %entry ], [ %add, %for.body ]
45  %call = tail call signext i32 @caller(i32 signext 4, i32 signext 5, i32 signext 10000000, i32 signext %i.011)
46  %add = add nsw i32 %call, %ret.010
47  %inc = add nuw nsw i32 %i.011, 1
48  %exitcond = icmp eq i32 %inc, 10000000
49  br i1 %exitcond, label %for.cond.cleanup, label %for.body, !prof !34
50}
51
52; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
53declare void @llvm.dbg.declare(metadata, metadata, metadata)  #2
54
55attributes #0 = { noinline }
56attributes #2 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
57
58!llvm.dbg.cu = !{!117}
59!llvm.module.flags = !{!100}
60
61!0 = !{i32 1, !"ProfileSummary", !1}
62!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
63!2 = !{!"ProfileFormat", !"InstrProf"}
64!3 = !{!"TotalCount", i64 20000003}
65!4 = !{!"MaxCount", i64 10000000}
66!5 = !{!"MaxInternalCount", i64 10000000}
67!6 = !{!"MaxFunctionCount", i64 10000000}
68!7 = !{!"NumCounts", i64 5}
69!8 = !{!"NumFunctions", i64 3}
70!9 = !{!"DetailedSummary", !10}
71!10 = !{!11, !12, !13, !14, !15, !16, !16, !17, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26}
72!11 = !{i32 10000, i64 10000000, i32 2}
73!12 = !{i32 100000, i64 10000000, i32 2}
74!13 = !{i32 200000, i64 10000000, i32 2}
75!14 = !{i32 300000, i64 10000000, i32 2}
76!15 = !{i32 400000, i64 10000000, i32 2}
77!16 = !{i32 500000, i64 10000000, i32 2}
78!17 = !{i32 600000, i64 10000000, i32 2}
79!18 = !{i32 700000, i64 10000000, i32 2}
80!19 = !{i32 800000, i64 10000000, i32 2}
81!20 = !{i32 900000, i64 10000000, i32 2}
82!21 = !{i32 950000, i64 10000000, i32 2}
83!22 = !{i32 990000, i64 10000000, i32 2}
84!23 = !{i32 999000, i64 10000000, i32 2}
85!24 = !{i32 999900, i64 10000000, i32 2}
86!25 = !{i32 999990, i64 10000000, i32 2}
87!26 = !{i32 999999, i64 10000000, i32 2}
88!30 = !{!"function_entry_count", i64 10000000}
89!31 = !{!"branch_weights", i32 2, i32 10000000}
90!32 = !{i32 59}
91!33 = !{!"function_entry_count", i64 1}
92!34 = !{!"branch_weights", i32 2, i32 10000001}
93
94!100 = !{i32 2, !"Debug Info Version", i32 3}
95!101 = !DILocalVariable(name: "k", arg: 1, scope: !102, file: !103, line: 13, type: !119)
96!102 = distinct !DISubprogram(name: "h", scope: !103, file: !103, line: 13, type: !104, scopeLine: 13, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !117, retainedNodes: !121)
97!103 = !DIFile(filename: "foo2.c", directory: "/bar")
98!104 = !DISubroutineType(types: !105)
99!105 = !{!119}
100!117 = distinct !DICompileUnit(language: DW_LANG_C99, file: !103, producer: "clang version 16", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !118, globals: !120, splitDebugInlining: false, nameTableKind: None)
101!118 = !{!119}
102!119 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
103!120 = !{}
104!121 = !{!101}
105!122 = !DILocation(line: 13, column: 27, scope: !102)
106