Skip to content

Commit dd798e3

Browse files
Merge pull request swiftlang#39882 from aschwaighofer/loadable_by_address_84460204
Fix LoadableByAddress lowering of alloc_stack
2 parents 38e9f39 + bca8a59 commit dd798e3

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ void LargeValueVisitor::visitTupleInst(SingleValueInstruction *instr) {
984984

985985
void LargeValueVisitor::visitAllocStackInst(AllocStackInst *instr) {
986986
SILType currSILType = instr->getType().getObjectType();
987-
if (getInnerFunctionType(currSILType)) {
987+
if (pass.containsDifferentFunctionSignature(pass.F->getLoweredFunctionType(),
988+
currSILType)) {
988989
pass.allocStackInstsToMod.push_back(instr);
989990
}
990991
}

test/IRGen/loadable_by_address.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
3+
// RUN: %target-swift-frontend -I %t -c %s
4+
5+
import resilient_struct
6+
7+
public struct LargeValue {
8+
var field : (Int64, Int64, Int64, Int64, Int64,
9+
Int64, Int64, Int64, Int64, Int64)? = nil
10+
public init() {}
11+
}
12+
13+
// This test use to crash with a compiler assert.
14+
public class Test {
15+
public typealias Closure = ((LargeValue, _ last: Bool) -> Void)
16+
17+
public init() {}
18+
19+
public var t : Test?
20+
21+
public func forceClosure(_ cl: () -> ()) {
22+
cl()
23+
}
24+
25+
public func execute(input: (arg1: Size, closure: Closure)) {
26+
if let _t = t {
27+
_t.forceClosure {
28+
var i = input
29+
}
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)