Skip to content

Commit 7c12be8

Browse files
authored
Merge pull request #82881 from jckarter/dont-try-to-address-project-static-properties-6.2
[6.2] SILGen: Don't try to project static stored properties as addressable from their base.
2 parents 3c98a1e + e2ac7a0 commit 7c12be8

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3623,8 +3623,8 @@ SILGenFunction::tryEmitAddressableParameterAsAddress(ArgumentSource &&arg,
36233623
auto vd = cast<VarDecl>(memberStorage);
36243624
// TODO: Is it possible and/or useful for class storage to be
36253625
// addressable?
3626-
if (!vd->getDeclContext()->getInnermostTypeContext()
3627-
->getDeclaredTypeInContext()->getStructOrBoundGenericStruct()) {
3626+
if (!vd->isInstanceMember()
3627+
|| !isa<StructDecl>(vd->getDeclContext())) {
36283628
return notAddressable();
36293629
}
36303630

lib/SILGen/SILGenDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,8 @@ static void deallocateAddressable(SILGenFunction &SGF,
684684
const SILGenFunction::VarLoc::AddressableBuffer::State &state) {
685685
SGF.B.createEndBorrow(l, state.storeBorrow);
686686
SGF.B.createDeallocStack(l, state.allocStack);
687-
if (state.reabstraction) {
687+
if (state.reabstraction
688+
&& !state.reabstraction->getType().isTrivial(SGF.F)) {
688689
SGF.B.createDestroyValue(l, state.reabstraction);
689690
}
690691
}

test/SILGen/82368.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-emit-silgen -disable-availability-checking -verify %s
2+
3+
struct A {
4+
static let a: InlineArray = [1]
5+
6+
static func foo() {
7+
a.span.withUnsafeBufferPointer({ buffer in
8+
print("\(buffer.baseAddress!)")
9+
})
10+
}
11+
}

0 commit comments

Comments
 (0)