Skip to content

Commit bfb5ccd

Browse files
authored
Merge pull request #37371 from gottesmm/release/5.4-77644532
SIL: support dealloc_ref and dealloc_partial_ref in LoadBorrowImmutabilityChecker
2 parents 1617e53 + 70091a2 commit bfb5ccd

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

lib/SIL/Verifier/LoadBorrowImmutabilityChecker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ bool GatherWritesVisitor::visitUse(Operand *op, AccessUseType useTy) {
107107
case SILInstructionKind::AssignInst:
108108
case SILInstructionKind::UncheckedTakeEnumDataAddrInst:
109109
case SILInstructionKind::MarkFunctionEscapeInst:
110+
case SILInstructionKind::DeallocRefInst:
111+
case SILInstructionKind::DeallocPartialRefInst:
110112
writeAccumulator.push_back(op);
111113
return true;
112114

test/SILOptimizer/load_borrow_verify.sil

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,39 @@ bb0(%0 : @guaranteed $ObjectWrapper):
9797
end_borrow %2 : $AnyObject
9898
return %3 : $ObjectWrapper
9999
}
100+
101+
final class B { }
102+
103+
final class K {
104+
@_hasStorage public var x: B { get }
105+
init()
106+
}
107+
108+
sil [ossa] @test_dealloc_ref : $@convention(thin) (@owned K) -> () {
109+
bb0(%0 : @owned $K):
110+
%1 = begin_borrow %0 : $K
111+
%2 = ref_element_addr %1 : $K, #K.x
112+
%3 = begin_access [read] [dynamic] %2 : $*B
113+
%4 = load_borrow %3 : $*B
114+
end_borrow %4 : $B
115+
end_access %3 : $*B
116+
end_borrow %1 : $K
117+
dealloc_ref %0 : $K
118+
%r = tuple ()
119+
return %r : $()
120+
}
121+
122+
sil [ossa] @test_dealloc_partial_ref : $@convention(thin) (@owned K) -> () {
123+
bb0(%0 : @owned $K):
124+
%1 = begin_borrow %0 : $K
125+
%2 = ref_element_addr %1 : $K, #K.x
126+
%3 = begin_access [read] [dynamic] %2 : $*B
127+
%4 = load_borrow %3 : $*B
128+
end_borrow %4 : $B
129+
end_access %3 : $*B
130+
end_borrow %1 : $K
131+
%8 = metatype $@thick K.Type
132+
dealloc_partial_ref %0 : $K, %8 : $@thick K.Type
133+
%r = tuple ()
134+
return %r : $()
135+
}

0 commit comments

Comments
 (0)