|
| 1 | +; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | FileCheck %s |
| 2 | +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" |
| 3 | + |
| 4 | +@A = external dso_local constant i32, align 4 |
| 5 | +@B = external dso_local constant i32, align 4 |
| 6 | + |
| 7 | +; CHECK: define dso_local i32 @bar(i32 %x, i32 %y, ptr %z) !prof ![[BAR_PROF:[0-9]]] { |
| 8 | +define dso_local i32 @bar(i32 %x, i32 %y, ptr %z) !prof !0 { |
| 9 | +entry: |
| 10 | + %tobool = icmp ne i32 %x, 0 |
| 11 | +; CHECK: br i1 %tobool, label %if.then, label %if.else, !prof ![[BRANCH_PROF:[0-9]]] |
| 12 | + br i1 %tobool, label %if.then, label %if.else, !prof !1 |
| 13 | + |
| 14 | +if.then: |
| 15 | +; CHECK: if.then: |
| 16 | +; CHECK: call i32 @foo.specialized.1(i32 %x, ptr @A) |
| 17 | + %call = call i32 @foo(i32 %x, ptr @A) |
| 18 | + br label %return |
| 19 | + |
| 20 | +if.else: |
| 21 | +; CHECK: if.else: |
| 22 | +; CHECK: call i32 @foo.specialized.2(i32 %y, ptr @B) |
| 23 | + %call1 = call i32 @foo(i32 %y, ptr @B) |
| 24 | + br label %return |
| 25 | + |
| 26 | +; CHECK: return: |
| 27 | +; CHECK: %call2 = call i32 @foo(i32 %x, ptr %z) |
| 28 | +return: |
| 29 | + %retval.0 = phi i32 [ %call, %if.then ], [ %call1, %if.else ] |
| 30 | + %call2 = call i32 @foo(i32 %x, ptr %z); |
| 31 | + %add = add i32 %retval.0, %call2 |
| 32 | + ret i32 %add |
| 33 | +} |
| 34 | + |
| 35 | +; CHECK: define internal i32 @foo(i32 %x, ptr %b) !prof ![[FOO_UNSPEC_PROF:[0-9]]] |
| 36 | +; CHECK: define internal i32 @foo.specialized.1(i32 %x, ptr %b) !prof ![[FOO_SPEC_1_PROF:[0-9]]] |
| 37 | +; CHECK: define internal i32 @foo.specialized.2(i32 %x, ptr %b) !prof ![[FOO_SPEC_2_PROF:[0-9]]] |
| 38 | +define internal i32 @foo(i32 %x, ptr %b) !prof !2 { |
| 39 | +entry: |
| 40 | + %0 = load i32, ptr %b, align 4 |
| 41 | + %add = add nsw i32 %x, %0 |
| 42 | + ret i32 %add |
| 43 | +} |
| 44 | + |
| 45 | +; CHECK: ![[BAR_PROF]] = !{!"function_entry_count", i64 1000} |
| 46 | +; CHECK: ![[BRANCH_PROF]] = !{!"branch_weights", i32 1, i32 3} |
| 47 | +; CHECK: ![[FOO_UNSPEC_PROF]] = !{!"function_entry_count", i64 234} |
| 48 | +; CHECK: ![[FOO_SPEC_1_PROF]] = !{!"function_entry_count", i64 250} |
| 49 | +; CHECK: ![[FOO_SPEC_2_PROF]] = !{!"function_entry_count", i64 750} |
| 50 | +!0 = !{!"function_entry_count", i64 1000} |
| 51 | +!1 = !{!"branch_weights", i32 1, i32 3} |
| 52 | +!2 = !{!"function_entry_count", i64 1234} |
0 commit comments