1 ; RUN: opt -S -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 i8* @realloc(i8* %ptr, i64 %size)
10 declare void @free(i8* %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, i8* %ptr, i8** %retval.0.ce.loc)
19 ; CHECK-LABEL: cleanup:
20 ; CHECK-NEXT: phi i8* [ null, %if.then ], [ %call, %if.end ], [ %retval.0.ce.reload, %codeRepl ]
21 define i8* @realloc2(i8* %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 i8* @realloc(i8* %ptr, i64 %size)
33 %tobool1 = icmp eq i8* %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 i8* %ptr, null
40 br i1 %tobool3, label %cleanup, label %if.then4
42 if.then4: ; preds = %if.then2
43 call void @free(i8* %ptr)
46 cleanup: ; preds = %if.end, %if.then4, %if.then2, %if.then
47 %retval.0 = phi i8* [ 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