@@ -268,3 +268,51 @@ bb2:
268
268
%52 = tuple ()
269
269
return %52 : $()
270
270
}
271
+
272
+
273
+ sil @get_unknown_value : $@convention(thin) () -> Builtin.Int32
274
+ sil @get_unknown_value2 : $@convention(thin) () -> Builtin.Int32
275
+
276
+ sil @callee : $@convention(thin) (@inout Builtin.Int32) -> () {
277
+ bb0(%0 : $*Builtin.Int32):
278
+ %1 = function_ref @get_unknown_value : $@convention(thin) () -> Builtin.Int32
279
+ %2 = apply %1() : $@convention(thin) () -> Builtin.Int32
280
+ store %2 to %0 : $*Builtin.Int32
281
+ %9999 = tuple()
282
+ return %9999 : $()
283
+ }
284
+
285
+ sil @use_value : $@convention(thin) (Builtin.Int32) -> ()
286
+
287
+ // Check if escape analysis figures out that the alloc_stack escapes to callee.
288
+ //
289
+ // CHECK-LABEL: sil @dont_hoist_aliased_load
290
+ // CHECK: bb2:
291
+ // CHECK-NEXT: apply
292
+ // CHECK-NEXT: load
293
+ // CHECK-NEXT: apply
294
+ sil @dont_hoist_aliased_load : $@convention(thin) () -> () {
295
+ bb0:
296
+ %0 = alloc_stack $Builtin.Int32
297
+ %1 = integer_literal $Builtin.Int32, 0
298
+ %3 = function_ref @callee : $@convention(thin) (@inout Builtin.Int32) -> ()
299
+ %5 = function_ref @use_value : $@convention(thin) (Builtin.Int32) -> ()
300
+ %unknown_value_fn = function_ref @get_unknown_value2 : $@convention(thin) () -> Builtin.Int32
301
+ store %1 to %0 : $*Builtin.Int32
302
+ br bb1(%0 : $*Builtin.Int32)
303
+
304
+ bb1(%phi1 : $*Builtin.Int32):
305
+ br bb2
306
+
307
+ bb2:
308
+ apply %3(%0) : $@convention(thin) (@inout Builtin.Int32) -> ()
309
+ %4 = load %phi1 : $*Builtin.Int32
310
+ %6 = apply %unknown_value_fn() : $@convention(thin) () -> Builtin.Int32
311
+ %33 = builtin "cmp_eq_Int32"(%4 : $Builtin.Int32, %6 : $Builtin.Int32) : $Builtin.Int1
312
+ cond_br %33, bb2, bb3
313
+
314
+ bb3:
315
+ %9999 = tuple()
316
+ dealloc_stack %0 : $*Builtin.Int32
317
+ return %9999 : $()
318
+ }
0 commit comments