1 ; RUN: opt -S -passes=hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
5 ; extern void sideeffect(int);
6 ; extern void __attribute__((cold)) sink();
8 ; if (cond) { //< Start outlining here.
23 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
24 target triple = "x86_64-apple-macosx10.14.0"
26 ; CHECK-LABEL: define {{.*}}@foo(
27 ; CHECK: br i1 {{.*}}, label %exit1, label %codeRepl
28 ; CHECK-LABEL: codeRepl:
29 ; CHECK: [[targetBlock:%.*]] = call i1 @foo.cold.1(
30 ; CHECK-NEXT: br i1 [[targetBlock]], label %exit1, label %[[return:.*]]
32 ; CHECK: call {{.*}}@sideeffect(i32 1)
34 ; CHECK-NEXT: ret void
35 define void @foo(i32 %cond) {
37 %tobool = icmp eq i32 %cond, 0
38 br i1 %tobool, label %exit1, label %if.then
40 if.then: ; preds = %entry
41 tail call void (...) @sink()
42 %cmp = icmp sgt i32 %cond, 10
43 br i1 %cmp, label %exit1, label %exit2
45 exit1: ; preds = %entry, %if.then
46 call void @sideeffect(i32 1)
49 exit2: ; preds = %if.then
50 call void @sideeffect(i32 2)
53 return: ; preds = %exit2, %exit1
57 ; CHECK-LABEL: define {{.*}}@foo.cold.1(
59 ; CHECK: call {{.*}}@sink
60 ; CHECK-NEXT: [[cmp:%.*]] = icmp
61 ; CHECK-NEXT: br i1 [[cmp]], label %[[exit1Stub:.*]], label %exit2
63 ; CHECK-NEXT: call {{.*}}@sideeffect(i32 2)
64 ; CHECK-NEXT: br label %[[returnStub:.*]]
65 ; CHECK: [[exit1Stub]]:
66 ; CHECK-NEXT: ret i1 true
67 ; CHECK: [[returnStub]]:
68 ; CHECK-NEXT: ret i1 false
70 declare void @sink(...) cold
72 declare void @sideeffect(i32)