Skip to content
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

Win64 ABI: Pass/return delegates like slices - in (up to) 2 GP registers #3609

Merged
merged 1 commit into from
Nov 11, 2020
Merged
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
7 changes: 6 additions & 1 deletion gen/abi-win64.cpp
Original file line number Diff line number Diff line change
@@ -71,7 +71,11 @@ struct Win64TargetABI : TargetABI {

// Remaining aggregates which can NOT be rewritten as integers (size > 8
// bytes or not a power of 2) are passed by ref to hidden copy.
return isAggregate(t) && !canRewriteAsInt(t);
// LDC-specific exceptions: slices and delegates are left alone (as non-
// rewritten IR structs) and passed/returned as 2 separate args => passed in
// up to 2 GP registers and returned in RAX & RDX.
return isAggregate(t) && !canRewriteAsInt(t) && t->ty != Tarray &&
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[isAggregate(t) already excludes Tarray, so no change for slices. - That's a general limitation, as we cannot ABI-rewrite slices because we don't ABI-rewrite the druntime hooks.]

t->ty != Tdelegate;
}

public:
@@ -113,6 +117,7 @@ struct Win64TargetABI : TargetABI {
// are returned in a register (RAX, or XMM0 for single float/ifloat/
// double/idouble)
// * 80-bit real/ireal are returned on the x87 stack
// * LDC-specific: slices and delegates are returned in RAX & RDX
// * all other types are returned via sret
return passPointerToHiddenCopy(rt, /*isReturnValue=*/true, tf->linkage);
}
4 changes: 2 additions & 2 deletions gen/dibuilder.cpp
Original file line number Diff line number Diff line change
@@ -1255,9 +1255,9 @@ void DIBuilder::EmitLocalVariable(llvm::Value *ll, VarDeclaration *vd,
if (isaArgument(ll) && addr.empty()) {
forceAsLocal = true;
} else {
// 2) dynamic arrays and vectors
// 2) dynamic arrays, delegates and vectors
TY ty = type->toBasetype()->ty;
if (ty == Tarray || ty == Tvector)
if (ty == Tarray || ty == Tdelegate || ty == Tvector)
forceAsLocal = true;
}
}