1 ; RUN: llc -regalloc=greedy -verify-coalescing -mtriple=x86_64-unknown-linux-gnu < %s
2 ; Check the live range is updated properly after register coalescing.
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6 @.str = internal unnamed_addr constant { [17 x i8], [47 x i8] } { [17 x i8] c"0123456789ABCDEF\00", [47 x i8] zeroinitializer }, align 32
7 @b = common local_unnamed_addr global i32 0, align 4
8 @a = common local_unnamed_addr global ptr null, align 8
9 @__sancov_gen_cov = private global [9 x i32] zeroinitializer
11 ; Function Attrs: nounwind sanitize_address
12 define void @fn2(ptr %p1) local_unnamed_addr #0 {
14 %0 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 4) to ptr) monotonic, align 4
15 %1 = icmp sge i32 0, %0
16 br i1 %1, label %2, label %3
18 ; <label>:2: ; preds = %entry
19 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 4) to ptr))
20 call void asm sideeffect "", ""()
23 ; <label>:3: ; preds = %entry, %2
24 br label %while.cond.outer
26 while.cond.outer: ; preds = %75, %3
27 %e.0.ph = phi ptr [ %e.058, %75 ], [ undef, %3 ]
28 %c.0.ph = phi ptr [ %c.059, %75 ], [ undef, %3 ]
29 %p1.addr.0.ph = phi ptr [ %incdec.ptr60, %75 ], [ %p1, %3 ]
30 %4 = ptrtoint ptr %p1.addr.0.ph to i64
32 %6 = add i64 %5, 2147450880
33 %7 = inttoptr i64 %6 to ptr
36 br i1 %9, label %10, label %15
38 ; <label>:10: ; preds = %while.cond.outer
40 %12 = trunc i64 %11 to i8
41 %13 = icmp sge i8 %12, %8
42 br i1 %13, label %14, label %15
44 ; <label>:14: ; preds = %10
45 call void @__asan_report_load1(i64 %4)
46 call void asm sideeffect "", ""()
49 ; <label>:15: ; preds = %10, %while.cond.outer
50 %16 = load i8, ptr %p1.addr.0.ph, align 1
51 call void @__sanitizer_cov_trace_cmp1(i8 %16, i8 0)
52 %cmp57 = icmp eq i8 %16, 0
53 br i1 %cmp57, label %while.cond.outer.enoent.loopexit96_crit_edge, label %while.body.preheader
55 while.cond.outer.enoent.loopexit96_crit_edge: ; preds = %15
56 %17 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 8) to ptr) monotonic, align 4
57 %18 = icmp sge i32 0, %17
58 br i1 %18, label %19, label %20
60 ; <label>:19: ; preds = %while.cond.outer.enoent.loopexit96_crit_edge
61 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 8) to ptr))
62 call void asm sideeffect "", ""()
65 ; <label>:20: ; preds = %while.cond.outer.enoent.loopexit96_crit_edge, %19
66 br label %enoent.loopexit96
68 while.body.preheader: ; preds = %15
71 while.body: ; preds = %56, %while.body.preheader
72 %21 = phi i8 [ %52, %56 ], [ %16, %while.body.preheader ]
73 %p1.addr.0.ph.pn = phi ptr [ %incdec.ptr60, %56 ], [ %p1.addr.0.ph, %while.body.preheader ]
74 %c.059 = phi ptr [ %incdec.ptr18, %56 ], [ %c.0.ph, %while.body.preheader ]
75 %e.058 = phi ptr [ %incdec.ptr60, %56 ], [ %e.0.ph, %while.body.preheader ]
76 %incdec.ptr60 = getelementptr inbounds i8, ptr %p1.addr.0.ph.pn, i64 1
77 %conv = sext i8 %21 to i32
78 %call = tail call i32 (ptr, i32, ...) @fn3(ptr @.str, i32 %conv) #2
79 call void @__sanitizer_cov_trace_cmp4(i32 %call, i32 0)
80 %tobool = icmp eq i32 %call, 0
81 br i1 %tobool, label %if.end5, label %cleanup
83 if.end5: ; preds = %while.body
84 call void @__sanitizer_cov_trace_cmp1(i8 %21, i8 58)
85 %cmp6 = icmp eq i8 %21, 58
86 br i1 %cmp6, label %if.end14, label %cleanup.thread40
88 if.end14: ; preds = %if.end5
89 %lshr1 = lshr i64 ptrtoint (ptr @a to i64), 3
90 %add1 = add i64 %lshr1, 2147450880
91 %inttoptr1 = inttoptr i64 %add1 to ptr
92 %22 = load i8, ptr %inttoptr1
93 %23 = icmp ne i8 %22, 0
94 br i1 %23, label %24, label %25
96 ; <label>:24: ; preds = %if.end14
97 call void @__asan_report_load8(i64 ptrtoint (ptr @a to i64))
98 call void asm sideeffect "", ""()
101 ; <label>:25: ; preds = %if.end14
102 %26 = load ptr, ptr @a, align 8
103 %tobool15 = icmp eq ptr %26, null
104 br i1 %tobool15, label %cleanup.thread39, label %cleanup23.loopexit
106 cleanup.thread39: ; preds = %25
107 %incdec.ptr18 = getelementptr inbounds i32, ptr %c.059, i64 1
108 %27 = ptrtoint ptr %c.059 to i64
109 %28 = lshr i64 %27, 3
110 %29 = add i64 %28, 2147450880
111 %30 = inttoptr i64 %29 to ptr
112 %31 = load i8, ptr %30
113 %32 = icmp ne i8 %31, 0
114 br i1 %32, label %33, label %39
116 ; <label>:33: ; preds = %cleanup.thread39
119 %36 = trunc i64 %35 to i8
120 %37 = icmp sge i8 %36, %31
121 br i1 %37, label %38, label %39
123 ; <label>:38: ; preds = %33
124 call void @__asan_report_store4(i64 %27)
125 call void asm sideeffect "", ""()
128 ; <label>:39: ; preds = %33, %cleanup.thread39
129 store i32 0, ptr %c.059, align 4
130 %40 = ptrtoint ptr %incdec.ptr60 to i64
131 %41 = lshr i64 %40, 3
132 %42 = add i64 %41, 2147450880
133 %43 = inttoptr i64 %42 to ptr
134 %44 = load i8, ptr %43
135 %45 = icmp ne i8 %44, 0
136 br i1 %45, label %46, label %51
138 ; <label>:46: ; preds = %39
140 %48 = trunc i64 %47 to i8
141 %49 = icmp sge i8 %48, %44
142 br i1 %49, label %50, label %51
144 ; <label>:50: ; preds = %46
145 call void @__asan_report_load1(i64 %40)
146 call void asm sideeffect "", ""()
149 ; <label>:51: ; preds = %46, %39
150 %52 = load i8, ptr %incdec.ptr60, align 1
151 call void @__sanitizer_cov_trace_cmp1(i8 %52, i8 0)
152 %cmp = icmp eq i8 %52, 0
153 br i1 %cmp, label %enoent.loopexit, label %cleanup.thread39.while.body_crit_edge
155 cleanup.thread39.while.body_crit_edge: ; preds = %51
156 %53 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 12) to ptr) monotonic, align 4
157 %54 = icmp sge i32 0, %53
158 br i1 %54, label %55, label %56
160 ; <label>:55: ; preds = %cleanup.thread39.while.body_crit_edge
161 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 12) to ptr))
162 call void asm sideeffect "", ""()
165 ; <label>:56: ; preds = %cleanup.thread39.while.body_crit_edge, %55
168 cleanup.thread40: ; preds = %if.end5
169 %57 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 16) to ptr) monotonic, align 4
170 %58 = icmp sge i32 0, %57
171 br i1 %58, label %59, label %60
173 ; <label>:59: ; preds = %cleanup.thread40
174 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 16) to ptr))
175 call void asm sideeffect "", ""()
178 ; <label>:60: ; preds = %cleanup.thread40, %59
179 %call20 = tail call i32 (ptr, ...) @fn4(ptr %e.058) #2
182 cleanup: ; preds = %while.body
183 %lshr2 = lshr i64 ptrtoint (ptr @b to i64), 3
184 %add2 = add i64 %lshr2, 2147450880
185 %inttoptr2 = inttoptr i64 %add2 to ptr
186 %61 = load i8, ptr %inttoptr2
187 %62 = icmp ne i8 %61, 0
188 br i1 %62, label %63, label %66
190 ; <label>:63: ; preds = %cleanup
191 %and = and i64 ptrtoint (ptr @b to i64), 7
192 %add = add i64 %and, 3
193 %trunc = trunc i64 %add to i8
194 %64 = icmp sge i8 %trunc, %61
195 br i1 %64, label %65, label %66
197 ; <label>:65: ; preds = %63
198 call void @__asan_report_load4(i64 ptrtoint (ptr @b to i64))
199 call void asm sideeffect "", ""()
202 ; <label>:66: ; preds = %63, %cleanup
203 %67 = load i32, ptr @b, align 4
204 call void @__sanitizer_cov_trace_cmp4(i32 %67, i32 0)
205 %tobool3 = icmp eq i32 %67, 0
206 br i1 %tobool3, label %cleanup.while.cond.outer_crit_edge, label %cleanup.enoent.loopexit96_crit_edge
208 cleanup.enoent.loopexit96_crit_edge: ; preds = %66
209 %68 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 20) to ptr) monotonic, align 4
210 %69 = icmp sge i32 0, %68
211 br i1 %69, label %70, label %71
213 ; <label>:70: ; preds = %cleanup.enoent.loopexit96_crit_edge
214 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 20) to ptr))
215 call void asm sideeffect "", ""()
218 ; <label>:71: ; preds = %cleanup.enoent.loopexit96_crit_edge, %70
219 br label %enoent.loopexit96
221 cleanup.while.cond.outer_crit_edge: ; preds = %66
222 %72 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 24) to ptr) monotonic, align 4
223 %73 = icmp sge i32 0, %72
224 br i1 %73, label %74, label %75
226 ; <label>:74: ; preds = %cleanup.while.cond.outer_crit_edge
227 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 24) to ptr))
228 call void asm sideeffect "", ""()
231 ; <label>:75: ; preds = %cleanup.while.cond.outer_crit_edge, %74
232 br label %while.cond.outer
234 enoent.loopexit: ; preds = %51
235 %76 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 28) to ptr) monotonic, align 4
236 %77 = icmp sge i32 0, %76
237 br i1 %77, label %78, label %79
239 ; <label>:78: ; preds = %enoent.loopexit
240 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 28) to ptr))
241 call void asm sideeffect "", ""()
244 ; <label>:79: ; preds = %enoent.loopexit, %78
247 enoent.loopexit96: ; preds = %71, %20
250 enoent: ; preds = %enoent.loopexit96, %79, %60
251 %call22 = tail call ptr (...) @fn1() #2
254 cleanup23.loopexit: ; preds = %25
255 %80 = load atomic i32, ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 32) to ptr) monotonic, align 4
256 %81 = icmp sge i32 0, %80
257 br i1 %81, label %82, label %83
259 ; <label>:82: ; preds = %cleanup23.loopexit
260 call void @__sanitizer_cov(ptr inttoptr (i64 add (i64 ptrtoint (ptr @__sancov_gen_cov to i64), i64 32) to ptr))
261 call void asm sideeffect "", ""()
264 ; <label>:83: ; preds = %cleanup23.loopexit, %82
267 cleanup23: ; preds = %83, %enoent
271 declare i32 @fn3(...) local_unnamed_addr #1
273 declare i32 @fn4(...) local_unnamed_addr #1
275 declare ptr @fn1(...) local_unnamed_addr #1
277 declare void @__sanitizer_cov(ptr)
279 declare void @__sanitizer_cov_trace_cmp1(i8, i8)
281 declare void @__sanitizer_cov_trace_cmp4(i32, i32)
283 declare void @__asan_report_load1(i64)
285 declare void @__asan_report_load4(i64)
287 declare void @__asan_report_load8(i64)
289 declare void @__asan_report_store4(i64)