@@ -1340,3 +1340,65 @@ bb5:
1340
1340
bbEnd(%8 : @owned $Optional<Builtin.NativeObject>):
1341
1341
return %8 : $Optional<Builtin.NativeObject>
1342
1342
}
1343
+
1344
+ class Foo {}
1345
+ struct MyInt {
1346
+ var _value: Builtin.Int64
1347
+ }
1348
+ struct Baz {
1349
+ var x: MyInt
1350
+ var b: Builtin.NativeObject
1351
+ }
1352
+ sil @foo_method : $@convention(method) (@guaranteed Foo) -> MyInt
1353
+
1354
+ // We completely eliminate the alloc_stack here since the alloc_stack are not
1355
+ // viewed as user code by dead allocation elimination.
1356
+ //
1357
+ // CHECK: sil [ossa] @promote_loads_despite_debug_uses : $@convention(thin) (MyInt, @guaranteed Foo, @guaranteed Baz) -> MyInt {
1358
+ // CHECK-NOT: alloc_stack
1359
+ // CHECK: } // end sil function 'promote_loads_despite_debug_uses'
1360
+ sil [ossa] @promote_loads_despite_debug_uses : $@convention(thin) (MyInt, @guaranteed Foo, @guaranteed Baz) -> MyInt {
1361
+ bb0(%0 : $MyInt, %1 : @guaranteed $Foo, %2 : @guaranteed $Baz):
1362
+ %3 = alloc_stack $MyInt
1363
+ store %0 to [trivial] %3 : $*MyInt
1364
+ %5 = alloc_stack $Foo
1365
+ %6 = copy_value %1 : $Foo
1366
+ store %6 to [init] %5 : $*Foo
1367
+ %8 = alloc_stack $Baz
1368
+ %9 = copy_value %2 : $Baz
1369
+ store %9 to [init] %8 : $*Baz
1370
+ debug_value_addr %3 : $*MyInt, var, name "x", argno 1
1371
+ debug_value_addr %5 : $*Foo, var, name "y", argno 2
1372
+ debug_value_addr %8 : $*Baz, var, name "z", argno 3
1373
+ %14 = load [trivial] %3 : $*MyInt
1374
+ %15 = load [copy] %5 : $*Foo
1375
+
1376
+ %16 = function_ref @foo_method : $@convention(method) (@guaranteed Foo) -> MyInt
1377
+ %17 = begin_borrow %15 : $Foo
1378
+ %18 = apply %16(%17) : $@convention(method) (@guaranteed Foo) -> MyInt
1379
+ end_borrow %17 : $Foo
1380
+ destroy_value %15 : $Foo
1381
+ %21 = struct_extract %14 : $MyInt, #MyInt._value
1382
+ %22 = struct_extract %18 : $MyInt, #MyInt._value
1383
+ %23 = integer_literal $Builtin.Int1, -1
1384
+ %24 = builtin "sadd_with_overflow_Int64"(%21 : $Builtin.Int64, %22 : $Builtin.Int64, %23 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
1385
+ (%25, %26) = destructure_tuple %24 : $(Builtin.Int64, Builtin.Int1)
1386
+ cond_fail %26 : $Builtin.Int1, "arithmetic overflow"
1387
+ %28 = struct $MyInt (%25 : $Builtin.Int64)
1388
+ %29 = struct_element_addr %8 : $*Baz, #Baz.x
1389
+ %30 = load [trivial] %29 : $*MyInt
1390
+ %31 = struct_extract %28 : $MyInt, #MyInt._value
1391
+ %32 = struct_extract %30 : $MyInt, #MyInt._value
1392
+ %33 = integer_literal $Builtin.Int1, -1
1393
+ %34 = builtin "sadd_with_overflow_Int64"(%31 : $Builtin.Int64, %32 : $Builtin.Int64, %33 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
1394
+ (%35, %36) = destructure_tuple %34 : $(Builtin.Int64, Builtin.Int1)
1395
+ cond_fail %36 : $Builtin.Int1, "arithmetic overflow"
1396
+ %38 = struct $MyInt (%35 : $Builtin.Int64)
1397
+ destroy_addr %8 : $*Baz
1398
+ dealloc_stack %8 : $*Baz
1399
+ destroy_addr %5 : $*Foo
1400
+ dealloc_stack %5 : $*Foo
1401
+ destroy_addr %3 : $*MyInt
1402
+ dealloc_stack %3 : $*MyInt
1403
+ return %38 : $MyInt
1404
+ } // end sil function '$s27capture_promotion_ownership05test_a1_B0SiycyFSiycfU_Tf2iii_n'
0 commit comments