forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix LoadBorrowImmutabilityChecker for partial applies (swiftlang#34658)
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
test/SIL/ownership-verifier/load_borrow_invalidation_partial_apply.sil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// RUN: %target-sil-opt -enable-sil-verify-all -inline %s -o /dev/null | ||
|
||
// Tests here are patterns we should not consider as broken | ||
|
||
import Builtin | ||
|
||
class SuperKlass {} | ||
class Klass : SuperKlass {} | ||
|
||
struct WrapperStruct { | ||
var cls : Klass | ||
} | ||
|
||
sil [ossa] @foo1 : $@convention(thin) (@guaranteed WrapperStruct, @in_guaranteed WrapperStruct) -> () | ||
sil [ossa] @foo2 : $@convention(thin) (@owned WrapperStruct, @in_guaranteed WrapperStruct) -> () | ||
|
||
sil [ossa] @test1 : $@convention(thin) (@in_guaranteed WrapperStruct) -> () { | ||
bb0(%0 : $*WrapperStruct): | ||
%1 = load_borrow %0 : $*WrapperStruct | ||
%func = function_ref @foo1 : $@convention(thin) (@guaranteed WrapperStruct, @in_guaranteed WrapperStruct) -> () | ||
%pa = partial_apply [callee_guaranteed] [on_stack] %func(%1, %0) : $@convention(thin) (@guaranteed WrapperStruct, @in_guaranteed WrapperStruct) -> () | ||
end_borrow %1 : $WrapperStruct | ||
dealloc_stack %pa : $@noescape @callee_guaranteed () -> () | ||
%res = tuple () | ||
return %res : $() | ||
} | ||
|
||
sil [ossa] @test2 : $@convention(thin) (@in_guaranteed WrapperStruct) -> () { | ||
bb0(%0 : $*WrapperStruct): | ||
%1 = load_borrow %0 : $*WrapperStruct | ||
%copy = copy_value %1 : $WrapperStruct | ||
%func = function_ref @foo2 : $@convention(thin) (@owned WrapperStruct, @in_guaranteed WrapperStruct) -> () | ||
%pa = partial_apply %func(%copy, %0) : $@convention(thin) (@owned WrapperStruct, @in_guaranteed WrapperStruct) -> () | ||
end_borrow %1 : $WrapperStruct | ||
destroy_value %pa : $@callee_owned () -> () | ||
%res = tuple () | ||
return %res : $() | ||
} | ||
|
||
sil [ossa] @caller1 : $@convention(thin) (@owned WrapperStruct) -> () { | ||
bb0(%0 : @owned $WrapperStruct): | ||
%stk = alloc_stack $WrapperStruct | ||
store %0 to [init] %stk : $*WrapperStruct | ||
%func = function_ref @test1 : $@convention(thin) (@in_guaranteed WrapperStruct) -> () | ||
%a = apply %func(%stk) : $@convention(thin) (@in_guaranteed WrapperStruct) -> () | ||
destroy_addr %stk : $*WrapperStruct | ||
dealloc_stack %stk : $*WrapperStruct | ||
%res = tuple () | ||
return %res : $() | ||
} | ||
|
||
sil [ossa] @caller2 : $@convention(thin) (@owned WrapperStruct) -> () { | ||
bb0(%0 : @owned $WrapperStruct): | ||
%stk = alloc_stack $WrapperStruct | ||
store %0 to [init] %stk : $*WrapperStruct | ||
%func = function_ref @test2 : $@convention(thin) (@in_guaranteed WrapperStruct) -> () | ||
%a = apply %func(%stk) : $@convention(thin) (@in_guaranteed WrapperStruct) -> () | ||
destroy_addr %stk : $*WrapperStruct | ||
dealloc_stack %stk : $*WrapperStruct | ||
%res = tuple () | ||
return %res : $() | ||
} | ||
|