Skip to content

[Test] Added test for CSE RAUW change. #41467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions test/SILOptimizer/cse_ossa.sil
Original file line number Diff line number Diff line change
Expand Up @@ -1317,3 +1317,49 @@ bb0(%0 : @owned $E):
%r = tuple ()
return %r : $()
}

sil [ossa] @get_owned_c : $@convention(thin) () -> (@owned C)
sil [ossa] @get_owned_s : $@convention(thin) () -> (@owned S)
sil [ossa] @take_guaranteed_c : $@convention(thin) (@guaranteed C) -> ()

struct S {
var c : C
}

// The RAUW utility doesn't properly handle reborrows yet. Until it does, don't
// replace in the face of non-dominated reborrows.
//
// CHECK-LABEL: sil [ossa] @dont_rauw_guaranteed_with_nondominated_reborrow : {{.*}} {
// CHECK: struct_extract
// CHECK: struct_extract
// CHECK: struct_extract
// CHECK-LABEL: } // end sil function 'dont_rauw_guaranteed_with_nondominated_reborrow'
sil [ossa] @dont_rauw_guaranteed_with_nondominated_reborrow : $@convention(thin) (@owned S) -> (@owned C) {
entry(%instance : @owned $S):
cond_br undef, left, right

left:
%guaranteed_s_left = begin_borrow %instance : $S
%new = struct_extract %guaranteed_s_left : $S, #S.c
%old = struct_extract %guaranteed_s_left : $S, #S.c
%take_guaranteed_c = function_ref @take_guaranteed_c : $@convention(thin) (@guaranteed C) -> ()
apply %take_guaranteed_c(%new) : $@convention(thin) (@guaranteed C) -> ()
%borrow = begin_borrow %old : $C
br exit(%borrow : $C, %guaranteed_s_left : $S, %instance : $S)

right:
destroy_value %instance : $S
%get_owned_s = function_ref @get_owned_s : $@convention(thin) () -> (@owned S)
%owned_s = apply %get_owned_s() : $@convention(thin) () -> (@owned S)
%guaranteed_s = begin_borrow %owned_s : $S
%projection = struct_extract %guaranteed_s : $S, #S.c
%borrow_right = begin_borrow %projection : $C
br exit(%borrow_right : $C, %guaranteed_s : $S, %owned_s : $S)

exit(%borrow_2 : @guaranteed $C, %guaranteed_s_2 : @guaranteed $S, %owned_s_2 : @owned $S):
%copy = copy_value %borrow_2 : $C
end_borrow %borrow_2 : $C
end_borrow %guaranteed_s_2 : $S
destroy_value %owned_s_2 : $S
return %copy : $C
}