Skip to content

Commit cf47cfa

Browse files
committed
[Distributed] IRGen: Add generic argument substitutions to argument explosion of thunk call
1 parent 406af83 commit cf47cfa

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/IRGen/GenDistributed.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,25 @@ void DistributedAccessor::emit() {
472472
// so it could be forwarded to the distributed method.
473473
computeArguments(argBuffer, argTypes, arguments);
474474

475+
// Add all of the substitutions to the explosion
476+
if (auto *environment = Target->getGenericEnvironment()) {
477+
// swift.type **
478+
llvm::Value *substitutionBuffer =
479+
IGF.Builder.CreateBitCast(substitutions, IGM.TypeMetadataPtrPtrTy);
480+
481+
for (unsigned index : indices(environment->getGenericParams())) {
482+
auto offset =
483+
Size(index * IGM.DataLayout.getTypeAllocSize(IGM.TypeMetadataPtrTy));
484+
auto alignment =
485+
IGM.DataLayout.getABITypeAlignment(IGM.TypeMetadataPtrTy);
486+
487+
auto substitution =
488+
IGF.emitAddressAtOffset(substitutionBuffer, Offset(offset),
489+
IGM.TypeMetadataPtrTy, Alignment(alignment));
490+
arguments.add(IGF.Builder.CreateLoad(substitution, "substitution"));
491+
}
492+
}
493+
475494
// Step two, let's form and emit a call to the distributed method
476495
// using computed argument explosion.
477496
{

0 commit comments

Comments
 (0)