1 ; RUN: opt -S -passes=hotcoldsplit -hotcoldsplit-threshold=0 < %s | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.14.0"
6 declare void @sideeffect(i64)
8 declare ptr @realloc(ptr %ptr, i64 %size)
10 declare void @free(ptr %ptr)
12 declare void @sink() cold
14 ; CHECK-LABEL: define {{.*}}@realloc2(
15 ; CHECK: call {{.*}}@sideeffect(
16 ; CHECK: call {{.*}}@realloc(
17 ; CHECK-LABEL: codeRepl:
18 ; CHECK: call {{.*}}@realloc2.cold.1(i64 %size, ptr %ptr, ptr %retval.0.ce.loc)
19 ; CHECK-LABEL: cleanup:
20 ; CHECK-NEXT: phi ptr [ null, %if.then ], [ %call, %if.end ], [ %retval.0.ce.reload, %codeRepl ]
21 define ptr @realloc2(ptr %ptr, i64 %size) {
23 %0 = add i64 %size, -1
24 %1 = icmp ugt i64 %0, 184549375
25 br i1 %1, label %if.then, label %if.end
27 if.then: ; preds = %entry
28 call void @sideeffect(i64 %size)
31 if.end: ; preds = %entry
32 %call = call ptr @realloc(ptr %ptr, i64 %size)
33 %tobool1 = icmp eq ptr %call, null
34 br i1 %tobool1, label %if.then2, label %cleanup
36 if.then2: ; preds = %if.end
37 call void @sideeffect(i64 %size)
39 %tobool3 = icmp eq ptr %ptr, null
40 br i1 %tobool3, label %cleanup, label %if.then4
42 if.then4: ; preds = %if.then2
43 call void @free(ptr %ptr)
46 cleanup: ; preds = %if.end, %if.then4, %if.then2, %if.then
47 %retval.0 = phi ptr [ null, %if.then ], [ null, %if.then2 ], [ null, %if.then4 ], [ %call, %if.end ]
51 ; CHECK-LABEL: define {{.*}}@realloc2.cold.1(
52 ; CHECK: call {{.*}}@sideeffect
53 ; CHECK: call {{.*}}@sink
54 ; CHECK: call {{.*}}@free