1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -passes=hotcoldsplit -hotcoldsplit-threshold=0 < %s 2>&1 | FileCheck %s
declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
declare void @cold_use(ptr) cold
declare void @use(ptr)
; In this CFG, splitting will extract the blocks extract{1,2}. I.e., it will
; extract a lifetime.start marker, but not the corresponding lifetime.end
; marker. Make sure that a lifetime.start marker is emitted before the call to
; the split function, and *only* that marker.
;
; entry
; / \
; extract1 no-extract1
; (lt.start) |
; / |
; extract2 |
; \_____ |
; \ /
; exit
; (lt.end)
;
; After splitting, we should see:
;
; entry
; / \
; codeRepl no-extract1
; (lt.start) |
; \ /
; exit
; (lt.end)
define void @only_lifetime_start_is_cold() {
; CHECK-LABEL: @only_lifetime_start_is_cold(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[LOCAL1:%.*]] = alloca i256
; CHECK-NEXT: br i1 undef, label [[CODEREPL:%.*]], label [[NO_EXTRACT1:%.*]]
; CHECK: codeRepl:
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 -1, ptr [[LOCAL1]])
; CHECK-NEXT: [[TARGETBLOCK:%.*]] = call i1 @only_lifetime_start_is_cold.cold.1(ptr [[LOCAL1]]) #3
; CHECK-NEXT: br i1 [[TARGETBLOCK]], label [[NO_EXTRACT1]], label [[EXIT:%.*]]
; CHECK: no-extract1:
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr [[LOCAL1]])
; CHECK-NEXT: ret void
;
entry:
%local1 = alloca i256
br i1 undef, label %extract1, label %no-extract1
extract1:
; lt.start
call void @llvm.lifetime.start.p0(i64 1, ptr %local1)
call void @cold_use(ptr %local1)
br i1 undef, label %extract2, label %no-extract1
extract2:
br label %exit
no-extract1:
br label %exit
exit:
; lt.end
call void @llvm.lifetime.end.p0(i64 1, ptr %local1)
ret void
}
; In this CFG, splitting will extract the block extract1. I.e., it will extract
; a lifetime.end marker, but not the corresponding lifetime.start marker. Do
; not emit a lifetime.end marker after the call to the split function.
;
; entry
; (lt.start)
; / \
; no-extract1 extract1
; (lt.end) (lt.end)
; \ /
; exit
;
; After splitting, we should see:
;
; entry
; (lt.start)
; / \
; no-extract1 codeRepl
; (lt.end)
; \ /
; exit
define void @only_lifetime_end_is_cold() {
; CHECK-LABEL: @only_lifetime_end_is_cold(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[LOCAL1:%.*]] = alloca i256
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[LOCAL1]])
; CHECK-NEXT: br i1 undef, label [[NO_EXTRACT1:%.*]], label [[CODEREPL:%.*]]
; CHECK: no-extract1:
; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr [[LOCAL1]])
; CHECK-NEXT: br label [[EXIT:%.*]]
; CHECK: codeRepl:
; CHECK-NEXT: call void @only_lifetime_end_is_cold.cold.1(ptr [[LOCAL1]]) #3
; CHECK-NEXT: br label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
; lt.start
%local1 = alloca i256
call void @llvm.lifetime.start.p0(i64 1, ptr %local1)
br i1 undef, label %no-extract1, label %extract1
no-extract1:
; lt.end
call void @llvm.lifetime.end.p0(i64 1, ptr %local1)
br label %exit
extract1:
; lt.end
call void @cold_use(ptr %local1)
call void @llvm.lifetime.end.p0(i64 1, ptr %local1)
br label %exit
exit:
ret void
}
; In this CFG, splitting will extract the blocks extract{1,2,3}. Lifting the
; lifetime.end marker would be a miscompile.
define void @do_not_lift_lifetime_end() {
; CHECK-LABEL: @do_not_lift_lifetime_end(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[LOCAL1:%.*]] = alloca i256
; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr [[LOCAL1]])
; CHECK-NEXT: br label [[HEADER:%.*]]
; CHECK: header:
; CHECK-NEXT: call void @use(ptr [[LOCAL1]])
; CHECK-NEXT: br i1 undef, label [[EXIT:%.*]], label [[CODEREPL:%.*]]
; CHECK: codeRepl:
; CHECK-NEXT: [[TARGETBLOCK:%.*]] = call i1 @do_not_lift_lifetime_end.cold.1(ptr [[LOCAL1]]) #3
; CHECK-NEXT: br i1 [[TARGETBLOCK]], label [[HEADER]], label [[EXIT]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
entry:
; lt.start
%local1 = alloca i256
call void @llvm.lifetime.start.p0(i64 1, ptr %local1)
br label %header
header:
; If the lifetime.end marker is lifted, this use becomes dead the second time
; the header block is executed.
call void @use(ptr %local1)
br i1 undef, label %exit, label %extract1
extract1:
call void @cold_use(ptr %local1)
br i1 undef, label %extract2, label %extract3
extract2:
; Backedge.
br label %header
extract3:
; lt.end
call void @llvm.lifetime.end.p0(i64 1, ptr %local1)
br label %exit
exit:
ret void
}
|