Skip to content

LoadableByAddress: Make sure that indirect return arguments are at the right type expansion #34324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/IRGen/LoadableByAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
26 changes: 26 additions & 0 deletions test/IRGen/big_types_generic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,29 @@ func useStuff() {
print(generic2(1).0)
print(generic2(1).1)
}


public struct BigThing<T> {
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<DefineSome.A> {
return BigThing<DefineSome.A>()
}