mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SIL Verifier: verify that inside a read-only access scope there are no stores to the memory location
This will e.g. catch violations like ``` %1 = begin_access [read] %0 store %2 to %0 end_access %1 ``` Also, fix all the sil tests which violate that.
This commit is contained in:
@@ -55,7 +55,7 @@ bb0(%0 : @owned $WrapperStruct):
|
||||
// we run sil-opt with -dont-abort-on-memory-lifetime-error.
|
||||
|
||||
// CHECK-LABEL: Begin Error in function caller2
|
||||
// CHECK: SIL verification failed: Load borrow invalidated by a local write
|
||||
// CHECK: SIL verification failed: read-only scope invalidated by a local write
|
||||
// CHECK-LABEL: End Error in function caller2
|
||||
sil [ossa] @caller2 : $@convention(thin) (@owned WrapperStruct) -> () {
|
||||
bb0(%0 : @owned $WrapperStruct):
|
||||
|
||||
@@ -8,7 +8,7 @@ sil @use_guaranteed : $@convention(thin) (@guaranteed Klass) -> ()
|
||||
|
||||
// Write: store {{.*}} [assign] {{.*}}
|
||||
// CHECK: Begin Error in function test_write_reborrow
|
||||
// CHECK: SIL verification failed: Load borrow invalidated by a local write
|
||||
// CHECK: SIL verification failed: read-only scope invalidated by a local write
|
||||
// CHECK: End Error in function test_write_reborrow
|
||||
sil [ossa] @test_write_reborrow : $@convention(thin) (@owned Klass, @owned Klass) -> () {
|
||||
bb0(%0 : @owned $Klass, %1 : @owned $Klass):
|
||||
@@ -30,7 +30,7 @@ bb2(%ldarg : @guaranteed $Klass):
|
||||
}
|
||||
|
||||
// CHECK: Begin Error in function test_multiple_loadborrows
|
||||
// CHECK: SIL verification failed: Load borrow invalidated by a local write
|
||||
// CHECK: SIL verification failed: read-only scope invalidated by a local write
|
||||
// CHECK: Verifying instruction:
|
||||
// CHECK: -> destroy_addr
|
||||
// CHECK: End Error in function test_multiple_loadborrows
|
||||
@@ -84,7 +84,7 @@ struct MyStruct {
|
||||
}
|
||||
|
||||
// CHECK: Begin Error in function test_is_unique
|
||||
// CHECK: SIL verification failed: Load borrow invalidated by a local write
|
||||
// CHECK: SIL verification failed: read-only scope invalidated by a local write
|
||||
// CHECK: -> %4 = is_unique %1 : $*ArrayIntBuffer
|
||||
// CHECK: End Error in function test_is_unique
|
||||
sil [ossa] @test_is_unique : $@convention(thin) (@in MyArray<MyStruct>) -> () {
|
||||
|
||||
@@ -825,7 +825,7 @@ bb0(%0 : @owned $T, %1 : @owned $Inner):
|
||||
%4 = alloc_stack $Inner
|
||||
store %1 to [init] %4
|
||||
%6 = mark_dependence %4 on %2
|
||||
%7 = begin_access [read] [dynamic] %6
|
||||
%7 = begin_access [modify] [dynamic] %6
|
||||
%8 = load [take] %7
|
||||
end_access %7
|
||||
dealloc_stack %4
|
||||
@@ -841,7 +841,7 @@ bb0(%0 : @owned $T, %1 : @owned $Inner):
|
||||
%4 = alloc_stack $Inner
|
||||
store %1 to [init] %4
|
||||
mark_dependence_addr %4 on %2
|
||||
%7 = begin_access [read] [dynamic] %4
|
||||
%7 = begin_access [modify] [dynamic] %4
|
||||
%8 = load [take] %7
|
||||
end_access %7
|
||||
dealloc_stack %4
|
||||
|
||||
Reference in New Issue
Block a user