Skip to content

Commit b571eb3

Browse files
Merge pull request #41467 from nate-chandler/test/20220218/1
[Test] Added test for CSE RAUW change.
2 parents e45bb6f + 3900a84 commit b571eb3

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/SILOptimizer/cse_ossa.sil

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,3 +1317,49 @@ bb0(%0 : @owned $E):
13171317
%r = tuple ()
13181318
return %r : $()
13191319
}
1320+
1321+
sil [ossa] @get_owned_c : $@convention(thin) () -> (@owned C)
1322+
sil [ossa] @get_owned_s : $@convention(thin) () -> (@owned S)
1323+
sil [ossa] @take_guaranteed_c : $@convention(thin) (@guaranteed C) -> ()
1324+
1325+
struct S {
1326+
var c : C
1327+
}
1328+
1329+
// The RAUW utility doesn't properly handle reborrows yet. Until it does, don't
1330+
// replace in the face of non-dominated reborrows.
1331+
//
1332+
// CHECK-LABEL: sil [ossa] @dont_rauw_guaranteed_with_nondominated_reborrow : {{.*}} {
1333+
// CHECK: struct_extract
1334+
// CHECK: struct_extract
1335+
// CHECK: struct_extract
1336+
// CHECK-LABEL: } // end sil function 'dont_rauw_guaranteed_with_nondominated_reborrow'
1337+
sil [ossa] @dont_rauw_guaranteed_with_nondominated_reborrow : $@convention(thin) (@owned S) -> (@owned C) {
1338+
entry(%instance : @owned $S):
1339+
cond_br undef, left, right
1340+
1341+
left:
1342+
%guaranteed_s_left = begin_borrow %instance : $S
1343+
%new = struct_extract %guaranteed_s_left : $S, #S.c
1344+
%old = struct_extract %guaranteed_s_left : $S, #S.c
1345+
%take_guaranteed_c = function_ref @take_guaranteed_c : $@convention(thin) (@guaranteed C) -> ()
1346+
apply %take_guaranteed_c(%new) : $@convention(thin) (@guaranteed C) -> ()
1347+
%borrow = begin_borrow %old : $C
1348+
br exit(%borrow : $C, %guaranteed_s_left : $S, %instance : $S)
1349+
1350+
right:
1351+
destroy_value %instance : $S
1352+
%get_owned_s = function_ref @get_owned_s : $@convention(thin) () -> (@owned S)
1353+
%owned_s = apply %get_owned_s() : $@convention(thin) () -> (@owned S)
1354+
%guaranteed_s = begin_borrow %owned_s : $S
1355+
%projection = struct_extract %guaranteed_s : $S, #S.c
1356+
%borrow_right = begin_borrow %projection : $C
1357+
br exit(%borrow_right : $C, %guaranteed_s : $S, %owned_s : $S)
1358+
1359+
exit(%borrow_2 : @guaranteed $C, %guaranteed_s_2 : @guaranteed $S, %owned_s_2 : @owned $S):
1360+
%copy = copy_value %borrow_2 : $C
1361+
end_borrow %borrow_2 : $C
1362+
end_borrow %guaranteed_s_2 : $S
1363+
destroy_value %owned_s_2 : $S
1364+
return %copy : $C
1365+
}

0 commit comments

Comments
 (0)