blob: 5b697727e7d36c5f21d88b0798c92cd5459e45f7 [file] [log] [blame]
Vedant Kumarc2990062018-10-24 22:15:41 +00001; RUN: opt -S -hotcoldsplit < %s | FileCheck %s
2
3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-apple-macosx10.14.0"
5
6declare void @sideeffect(i64)
7
8declare i8* @realloc(i8* %ptr, i64 %size)
9
10declare void @free(i8* %ptr)
11
12declare void @sink() cold
13
14; CHECK-LABEL: define {{.*}}@realloc2(
15; CHECK: call {{.*}}@sideeffect(
16; CHECK: call {{.*}}@realloc(
17; CHECK-LABEL: codeRepl:
Vedant Kumard1295692018-12-03 22:40:21 +000018; CHECK-NEXT: call {{.*}}@realloc2.cold.1(i64 %size, i8* %ptr, i8** %retval.0.ce.loc)
Vedant Kumarc2990062018-10-24 22:15:41 +000019; CHECK-LABEL: cleanup:
Vedant Kumard1295692018-12-03 22:40:21 +000020; CHECK-NEXT: phi i8* [ null, %if.then ], [ %call, %if.end ], [ %retval.0.ce.reload, %codeRepl ]
Vedant Kumarc2990062018-10-24 22:15:41 +000021define i8* @realloc2(i8* %ptr, i64 %size) {
22entry:
23 %0 = add i64 %size, -1
24 %1 = icmp ugt i64 %0, 184549375
25 br i1 %1, label %if.then, label %if.end
26
27if.then: ; preds = %entry
28 call void @sideeffect(i64 %size)
29 br label %cleanup
30
31if.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
35
36if.then2: ; preds = %if.end
37 call void @sideeffect(i64 %size)
38 call void @sink()
39 %tobool3 = icmp eq i8* %ptr, null
40 br i1 %tobool3, label %cleanup, label %if.then4
41
42if.then4: ; preds = %if.then2
43 call void @free(i8* %ptr)
44 br label %cleanup
45
46cleanup: ; 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 ]
48 ret i8* %retval.0
49}
50
51; CHECK-LABEL: define {{.*}}@realloc2.cold.1(
52; CHECK: call {{.*}}@sideeffect
53; CHECK: call {{.*}}@sink
54; CHECK: call {{.*}}@free