xref: /llvm-project/llvm/test/Transforms/CodeExtractor/ExtractedFnEntryCount.ll (revision 0ca8ddd84d416b2b2b831fbc75ac8dbb77a12928)
1*0ca8ddd8SRoman Lebedev; RUN: opt < %s -passes=partial-inliner -skip-partial-inlining-cost-analysis -S | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christopher; This test checks to make sure that the CodeExtractor
4cee313d2SEric Christopher;  properly sets the entry count for the function that is
5cee313d2SEric Christopher;  extracted based on the root block being extracted and also
6cee313d2SEric Christopher;  takes into consideration if the block has edges coming from
7cee313d2SEric Christopher;  a block that is also being extracted.
8cee313d2SEric Christopher
9cee313d2SEric Christopherdefine i32 @inlinedFunc(i1 %cond) !prof !1 {
10cee313d2SEric Christopherentry:
11cee313d2SEric Christopher  br i1 %cond, label %if.then, label %return, !prof !2
12cee313d2SEric Christopherif.then:
13cee313d2SEric Christopher  br i1 %cond, label %if.then, label %return, !prof !3
14cee313d2SEric Christopherreturn:             ; preds = %entry
15cee313d2SEric Christopher  ret i32 0
16cee313d2SEric Christopher}
17cee313d2SEric Christopher
18cee313d2SEric Christopher
19cee313d2SEric Christopherdefine internal i32 @dummyCaller(i1 %cond) !prof !1 {
20cee313d2SEric Christopherentry:
21cee313d2SEric Christopher  %val = call i32 @inlinedFunc(i1 %cond)
22cee313d2SEric Christopher  ret i32 %val
23cee313d2SEric Christopher}
24cee313d2SEric Christopher
25cee313d2SEric Christopher; CHECK: @inlinedFunc.1.if.then(i1 %cond) !prof [[COUNT1:![0-9]+]]
26cee313d2SEric Christopher
27cee313d2SEric Christopher
28cee313d2SEric Christopher!llvm.module.flags = !{!0}
29cee313d2SEric Christopher; CHECK: [[COUNT1]] = !{!"function_entry_count", i64 250}
30cee313d2SEric Christopher!0 = !{i32 1, !"MaxFunctionCount", i32 1000}
31cee313d2SEric Christopher!1 = !{!"function_entry_count", i64 1000}
32cee313d2SEric Christopher!2 = !{!"branch_weights", i32 250, i32 750}
33cee313d2SEric Christopher!3 = !{!"branch_weights", i32 125, i32 125}
34