From 18777bfa94a2eece5ab8e935d5bc539ad3483a24 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Thu, 15 Oct 2020 11:34:31 -0700 Subject: [PATCH] LoadableByAddress: Make sure that indirect return arguments are at the right type expansion rdar://70220886 --- lib/IRGen/LoadableByAddress.cpp | 3 ++- test/IRGen/big_types_generic.swift | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/IRGen/LoadableByAddress.cpp b/lib/IRGen/LoadableByAddress.cpp index 2a509cbfeeb89..1d74b82059c7a 100644 --- a/lib/IRGen/LoadableByAddress.cpp +++ b/lib/IRGen/LoadableByAddress.cpp @@ -1407,7 +1407,8 @@ void LoadableStorageAllocation::insertIndirectReturnArgs() { canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType(); } resultStorageType = SILType::getPrimitiveObjectType(canType); - auto newResultStorageType = pass.getNewSILType(loweredTy, resultStorageType); + auto newResultStorageType = + pass.F->getLoweredType(pass.getNewSILType(loweredTy, resultStorageType)); auto &ctx = pass.F->getModule().getASTContext(); auto var = new (ctx) ParamDecl( diff --git a/test/IRGen/big_types_generic.swift b/test/IRGen/big_types_generic.swift index d1c648fd3e465..3d3b9194d19f6 100644 --- a/test/IRGen/big_types_generic.swift +++ b/test/IRGen/big_types_generic.swift @@ -67,3 +67,29 @@ func useStuff() { print(generic2(1).0) print(generic2(1).1) } + + +public struct BigThing { + var x: (Int64, Int64, Int64, Int64) = (0, 0, 0, 0) + var y: (Int64, Int64, Int64, Int64) = (0, 0, 0, 0) + var z: (Int64, Int64, Int64, Int64) = (0, 0, 0, 0) +} + +public protocol P {} + +public protocol Assoc { + associatedtype A + func foo() -> A +} + +extension Int : P {} + +public struct DefineSome : Assoc { + public func foo() -> some P { + return 5 + } +} + +public func abiIndirect() -> BigThing { + return BigThing() +}