Skip to content

Commit aa9aab8

Browse files
committed
Creates new autodiff loop context allocation builtins and preserves old ones
This commit builds on top of a previous commit that fixed memory leak issues in the autodiff loop context allocation builtins. The previous commit changed the existing builtins. However, inorder to maintain ABI compatibility and not break other consumers of autodiff, this commit creates newly named builtins that don't leak memory and preserves the older builtins. As a result, now, code compiled with an older frontend and using a newer stdlib will continue to work. But code compiled with a newer frontend and using older stdlib will have undefined behavior.
1 parent 91bafd4 commit aa9aab8

File tree

17 files changed

+147
-103
lines changed

17 files changed

+147
-103
lines changed

include/swift/AST/Builtins.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,14 +985,14 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(CreateAsyncTaskInGroup,
985985
/// is a pure value and therefore we can consider it as readnone).
986986
BUILTIN_MISC_OPERATION_WITH_SILGEN(GlobalStringTablePointer, "globalStringTablePointer", "n", Special)
987987

988-
// autoDiffCreateLinearMapContext: (T.Type) -> Builtin.NativeObject
989-
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffCreateLinearMapContext, "autoDiffCreateLinearMapContext", "", Special)
988+
// autoDiffCreateLinearMapContextWithType: (T.Type) -> Builtin.NativeObject
989+
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffCreateLinearMapContextWithType, "autoDiffCreateLinearMapContextWithType", "", Special)
990990

991991
// autoDiffProjectTopLevelSubcontext: (Builtin.NativeObject) -> Builtin.RawPointer
992992
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffProjectTopLevelSubcontext, "autoDiffProjectTopLevelSubcontext", "n", Special)
993993

994-
// autoDiffAllocateSubcontext: (Builtin.NativeObject, T.Type) -> Builtin.RawPointer
995-
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffAllocateSubcontext, "autoDiffAllocateSubcontext", "", Special)
994+
// autoDiffAllocateSubcontextWithType: (Builtin.NativeObject, T.Type) -> Builtin.RawPointer
995+
BUILTIN_MISC_OPERATION_WITH_SILGEN(AutoDiffAllocateSubcontextWithType, "autoDiffAllocateSubcontextWithType", "", Special)
996996

997997
/// Build a Builtin.Executor value from an "ordinary" serial executor
998998
/// reference.

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,9 +2273,9 @@ FUNCTION(TaskGroupDestroy,
22732273
ATTRS(NoUnwind),
22742274
EFFECT(Concurrency))
22752275

2276-
// AutoDiffLinearMapContext *swift_autoDiffCreateLinearMapContext(const Metadata *);
2277-
FUNCTION(AutoDiffCreateLinearMapContext,
2278-
swift_autoDiffCreateLinearMapContext, SwiftCC,
2276+
// AutoDiffLinearMapContext *swift_autoDiffCreateLinearMapContextWithType(const Metadata *);
2277+
FUNCTION(AutoDiffCreateLinearMapContextWithType,
2278+
swift_autoDiffCreateLinearMapContextWithType, SwiftCC,
22792279
DifferentiationAvailability,
22802280
RETURNS(RefCountedPtrTy),
22812281
ARGS(TypeMetadataPtrTy),
@@ -2291,9 +2291,9 @@ FUNCTION(AutoDiffProjectTopLevelSubcontext,
22912291
ATTRS(NoUnwind, ArgMemOnly),
22922292
EFFECT(AutoDiff))
22932293

2294-
// void *swift_autoDiffAllocateSubcontext(AutoDiffLinearMapContext *, const Metadata *);
2295-
FUNCTION(AutoDiffAllocateSubcontext,
2296-
swift_autoDiffAllocateSubcontext, SwiftCC,
2294+
// void *swift_autoDiffAllocateSubcontextWithType(AutoDiffLinearMapContext *, const Metadata *);
2295+
FUNCTION(AutoDiffAllocateSubcontextWithType,
2296+
swift_autoDiffAllocateSubcontextWithType, SwiftCC,
22972297
DifferentiationAvailability,
22982298
RETURNS(Int8PtrTy),
22992299
ARGS(RefCountedPtrTy, TypeMetadataPtrTy),

lib/AST/Builtins.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2967,13 +2967,13 @@ ValueDecl *swift::getBuiltinValueDecl(ASTContext &Context, Identifier Id) {
29672967
case BuiltinValueKind::HopToActor:
29682968
return getHopToActor(Context, Id);
29692969

2970-
case BuiltinValueKind::AutoDiffCreateLinearMapContext:
2970+
case BuiltinValueKind::AutoDiffCreateLinearMapContextWithType:
29712971
return getAutoDiffCreateLinearMapContext(Context, Id);
29722972

29732973
case BuiltinValueKind::AutoDiffProjectTopLevelSubcontext:
29742974
return getAutoDiffProjectTopLevelSubcontext(Context, Id);
29752975

2976-
case BuiltinValueKind::AutoDiffAllocateSubcontext:
2976+
case BuiltinValueKind::AutoDiffAllocateSubcontextWithType:
29772977
return getAutoDiffAllocateSubcontext(Context, Id);
29782978
}
29792979

lib/IRGen/GenBuiltin.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,9 +1307,10 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
13071307
return;
13081308
}
13091309

1310-
if (Builtin.ID == BuiltinValueKind::AutoDiffCreateLinearMapContext) {
1310+
if (Builtin.ID == BuiltinValueKind::AutoDiffCreateLinearMapContextWithType) {
13111311
auto topLevelSubcontextMetaType = args.claimNext();
1312-
out.add(emitAutoDiffCreateLinearMapContext(IGF, topLevelSubcontextMetaType)
1312+
out.add(emitAutoDiffCreateLinearMapContextWithType(
1313+
IGF, topLevelSubcontextMetaType)
13131314
.getAddress());
13141315
return;
13151316
}
@@ -1322,13 +1323,13 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
13221323
return;
13231324
}
13241325

1325-
if (Builtin.ID == BuiltinValueKind::AutoDiffAllocateSubcontext) {
1326+
if (Builtin.ID == BuiltinValueKind::AutoDiffAllocateSubcontextWithType) {
13261327
Address allocatorAddr(args.claimNext(), IGF.IGM.RefCountedStructTy,
13271328
IGF.IGM.getPointerAlignment());
13281329
auto subcontextMetatype = args.claimNext();
1329-
out.add(
1330-
emitAutoDiffAllocateSubcontext(IGF, allocatorAddr, subcontextMetatype)
1331-
.getAddress());
1330+
out.add(emitAutoDiffAllocateSubcontextWithType(IGF, allocatorAddr,
1331+
subcontextMetatype)
1332+
.getAddress());
13321333
return;
13331334
}
13341335

lib/IRGen/GenCall.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5479,12 +5479,12 @@ IRGenFunction::getFunctionPointerForResumeIntrinsic(llvm::Value *resume) {
54795479
return fnPtr;
54805480
}
54815481

5482-
Address irgen::emitAutoDiffCreateLinearMapContext(
5482+
Address irgen::emitAutoDiffCreateLinearMapContextWithType(
54835483
IRGenFunction &IGF, llvm::Value *topLevelSubcontextMetatype) {
54845484
topLevelSubcontextMetatype = IGF.Builder.CreateBitCast(
54855485
topLevelSubcontextMetatype, IGF.IGM.TypeMetadataPtrTy);
54865486
auto *call = IGF.Builder.CreateCall(
5487-
IGF.IGM.getAutoDiffCreateLinearMapContextFunctionPointer(),
5487+
IGF.IGM.getAutoDiffCreateLinearMapContextWithTypeFunctionPointer(),
54885488
{topLevelSubcontextMetatype});
54895489
call->setDoesNotThrow();
54905490
call->setCallingConv(IGF.IGM.SwiftCC);
@@ -5502,13 +5502,12 @@ Address irgen::emitAutoDiffProjectTopLevelSubcontext(
55025502
return Address(call, IGF.IGM.Int8Ty, IGF.IGM.getPointerAlignment());
55035503
}
55045504

5505-
Address irgen::emitAutoDiffAllocateSubcontext(IRGenFunction &IGF,
5506-
Address context,
5507-
llvm::Value *subcontextMetatype) {
5505+
Address irgen::emitAutoDiffAllocateSubcontextWithType(
5506+
IRGenFunction &IGF, Address context, llvm::Value *subcontextMetatype) {
55085507
subcontextMetatype =
55095508
IGF.Builder.CreateBitCast(subcontextMetatype, IGF.IGM.TypeMetadataPtrTy);
55105509
auto *call = IGF.Builder.CreateCall(
5511-
IGF.IGM.getAutoDiffAllocateSubcontextFunctionPointer(),
5510+
IGF.IGM.getAutoDiffAllocateSubcontextWithTypeFunctionPointer(),
55125511
{context.getAddress(), subcontextMetatype});
55135512
call->setDoesNotThrow();
55145513
call->setCallingConv(IGF.IGM.SwiftCC);

lib/IRGen/GenCall.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,14 @@ namespace irgen {
261261
CanSILFunctionType fnType, Explosion &result,
262262
Explosion &error);
263263

264-
Address
265-
emitAutoDiffCreateLinearMapContext(IRGenFunction &IGF,
266-
llvm::Value *topLevelSubcontextMetatype);
264+
Address emitAutoDiffCreateLinearMapContextWithType(
265+
IRGenFunction &IGF, llvm::Value *topLevelSubcontextMetatype);
266+
267267
Address emitAutoDiffProjectTopLevelSubcontext(
268268
IRGenFunction &IGF, Address context);
269-
Address emitAutoDiffAllocateSubcontext(IRGenFunction &IGF, Address context,
269+
270+
Address
271+
emitAutoDiffAllocateSubcontextWithType(IRGenFunction &IGF, Address context,
270272
llvm::Value *subcontextMetatype);
271273

272274
FunctionPointer getFunctionPointerForDispatchCall(IRGenModule &IGM,

lib/SIL/IR/OperandOwnership.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse, InitializeDistributedRemoteActor)
943943
BUILTIN_OPERAND_OWNERSHIP(InstantaneousUse,
944944
InitializeNonDefaultDistributedActor)
945945

946-
BUILTIN_OPERAND_OWNERSHIP(PointerEscape, AutoDiffAllocateSubcontext)
946+
BUILTIN_OPERAND_OWNERSHIP(PointerEscape, AutoDiffAllocateSubcontextWithType)
947947
BUILTIN_OPERAND_OWNERSHIP(PointerEscape, AutoDiffProjectTopLevelSubcontext)
948948

949949
// FIXME: ConvertTaskToJob is documented as taking NativePointer. It's operand's
@@ -955,8 +955,7 @@ BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildComplexEqualitySerialExecutorRef)
955955
BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildDefaultActorExecutorRef)
956956
BUILTIN_OPERAND_OWNERSHIP(BitwiseEscape, BuildMainActorExecutorRef)
957957

958-
BUILTIN_OPERAND_OWNERSHIP(TrivialUse, AutoDiffCreateLinearMapContext)
959-
958+
BUILTIN_OPERAND_OWNERSHIP(TrivialUse, AutoDiffCreateLinearMapContextWithType)
960959
#undef BUILTIN_OPERAND_OWNERSHIP
961960

962961
#define SHOULD_NEVER_VISIT_BUILTIN(ID) \

lib/SIL/IR/ValueOwnership.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDefaultActor)
571571
CONSTANT_OWNERSHIP_BUILTIN(None, DestroyDefaultActor)
572572
CONSTANT_OWNERSHIP_BUILTIN(None, InitializeDistributedRemoteActor)
573573
CONSTANT_OWNERSHIP_BUILTIN(None, InitializeNonDefaultDistributedActor)
574-
CONSTANT_OWNERSHIP_BUILTIN(Owned, AutoDiffCreateLinearMapContext)
574+
CONSTANT_OWNERSHIP_BUILTIN(Owned, AutoDiffCreateLinearMapContextWithType)
575575
CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffProjectTopLevelSubcontext)
576-
CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffAllocateSubcontext)
576+
CONSTANT_OWNERSHIP_BUILTIN(None, AutoDiffAllocateSubcontextWithType)
577577
CONSTANT_OWNERSHIP_BUILTIN(None, GetCurrentExecutor)
578578
CONSTANT_OWNERSHIP_BUILTIN(None, ResumeNonThrowingContinuationReturning)
579579
CONSTANT_OWNERSHIP_BUILTIN(None, ResumeThrowingContinuationReturning)

lib/SIL/Utils/MemAccessUtils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,8 +2567,8 @@ static void visitBuiltinAddress(BuiltinInst *builtin,
25672567
case BuiltinValueKind::CancelAsyncTask:
25682568
case BuiltinValueKind::CreateAsyncTask:
25692569
case BuiltinValueKind::CreateAsyncTaskInGroup:
2570-
case BuiltinValueKind::AutoDiffCreateLinearMapContext:
2571-
case BuiltinValueKind::AutoDiffAllocateSubcontext:
2570+
case BuiltinValueKind::AutoDiffCreateLinearMapContextWithType:
2571+
case BuiltinValueKind::AutoDiffAllocateSubcontextWithType:
25722572
case BuiltinValueKind::InitializeDefaultActor:
25732573
case BuiltinValueKind::InitializeDistributedRemoteActor:
25742574
case BuiltinValueKind::InitializeNonDefaultDistributedActor:

lib/SILGen/SILGenBuiltin.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,16 +1708,15 @@ static ManagedValue emitBuiltinHopToActor(SILGenFunction &SGF, SILLocation loc,
17081708
return ManagedValue::forObjectRValueWithoutOwnership(SGF.emitEmptyTuple(loc));
17091709
}
17101710

1711-
static ManagedValue emitBuiltinAutoDiffCreateLinearMapContext(
1711+
static ManagedValue emitBuiltinAutoDiffCreateLinearMapContextWithType(
17121712
SILGenFunction &SGF, SILLocation loc, SubstitutionMap subs,
17131713
ArrayRef<ManagedValue> args, SGFContext C) {
17141714
ASTContext &ctx = SGF.getASTContext();
17151715
auto *builtinApply = SGF.B.createBuiltin(
17161716
loc,
1717-
ctx.getIdentifier(
1718-
getBuiltinName(BuiltinValueKind::AutoDiffCreateLinearMapContext)),
1719-
SILType::getNativeObjectType(ctx),
1720-
subs,
1717+
ctx.getIdentifier(getBuiltinName(
1718+
BuiltinValueKind::AutoDiffCreateLinearMapContextWithType)),
1719+
SILType::getNativeObjectType(ctx), subs,
17211720
/*args*/ {args[0].getValue()});
17221721
return SGF.emitManagedRValueWithCleanup(builtinApply);
17231722
}
@@ -1736,16 +1735,15 @@ static ManagedValue emitBuiltinAutoDiffProjectTopLevelSubcontext(
17361735
return ManagedValue::forObjectRValueWithoutOwnership(builtinApply);
17371736
}
17381737

1739-
static ManagedValue emitBuiltinAutoDiffAllocateSubcontext(
1738+
static ManagedValue emitBuiltinAutoDiffAllocateSubcontextWithType(
17401739
SILGenFunction &SGF, SILLocation loc, SubstitutionMap subs,
17411740
ArrayRef<ManagedValue> args, SGFContext C) {
17421741
ASTContext &ctx = SGF.getASTContext();
17431742
auto *builtinApply = SGF.B.createBuiltin(
17441743
loc,
17451744
ctx.getIdentifier(
1746-
getBuiltinName(BuiltinValueKind::AutoDiffAllocateSubcontext)),
1747-
SILType::getRawPointerType(ctx),
1748-
subs,
1745+
getBuiltinName(BuiltinValueKind::AutoDiffAllocateSubcontextWithType)),
1746+
SILType::getRawPointerType(ctx), subs,
17491747
/*args*/ {args[0].borrow(SGF, loc).getValue(), args[1].getValue()});
17501748
return ManagedValue::forObjectRValueWithoutOwnership(builtinApply);
17511749
}

lib/SILOptimizer/Differentiation/VJPCloner.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ class VJPCloner::Implementation final
131131
// Create an context.
132132
pullbackContextValue = Builder.createBuiltin(
133133
original->getLocation(),
134-
getASTContext().getIdentifier(
135-
getBuiltinName(BuiltinValueKind::AutoDiffCreateLinearMapContext)),
134+
getASTContext().getIdentifier(getBuiltinName(
135+
BuiltinValueKind::AutoDiffCreateLinearMapContextWithType)),
136136
SILType::getNativeObjectType(getASTContext()), SubstitutionMap(),
137137
{pbTupleMetatype});
138138
borrowedPullbackContextValue = Builder.createBeginBorrow(
@@ -156,8 +156,8 @@ class VJPCloner::Implementation final
156156
return builtinAutoDiffAllocateSubcontextGenericSignature;
157157
auto &ctx = getASTContext();
158158
auto *decl = cast<FuncDecl>(getBuiltinValueDecl(
159-
ctx, ctx.getIdentifier(
160-
getBuiltinName(BuiltinValueKind::AutoDiffAllocateSubcontext))));
159+
ctx, ctx.getIdentifier(getBuiltinName(
160+
BuiltinValueKind::AutoDiffAllocateSubcontextWithType))));
161161
builtinAutoDiffAllocateSubcontextGenericSignature =
162162
decl->getGenericSignature();
163163
assert(builtinAutoDiffAllocateSubcontextGenericSignature);
@@ -1085,8 +1085,8 @@ EnumInst *VJPCloner::Implementation::buildPredecessorEnumValue(
10851085

10861086
auto rawBufferValue = builder.createBuiltin(
10871087
loc,
1088-
getASTContext().getIdentifier(
1089-
getBuiltinName(BuiltinValueKind::AutoDiffAllocateSubcontext)),
1088+
getASTContext().getIdentifier(getBuiltinName(
1089+
BuiltinValueKind::AutoDiffAllocateSubcontextWithType)),
10901090
rawPtrType, SubstitutionMap(),
10911091
{borrowedPullbackContextValue, pbTupleMetatype});
10921092

lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static bool isBarrier(SILInstruction *inst) {
146146
case BuiltinValueKind::COWBufferForReading:
147147
case BuiltinValueKind::GetCurrentAsyncTask:
148148
case BuiltinValueKind::GetCurrentExecutor:
149-
case BuiltinValueKind::AutoDiffCreateLinearMapContext:
149+
case BuiltinValueKind::AutoDiffCreateLinearMapContextWithType:
150150
case BuiltinValueKind::EndAsyncLet:
151151
case BuiltinValueKind::EndAsyncLetLifetime:
152152
case BuiltinValueKind::CreateTaskGroup:
@@ -199,7 +199,7 @@ static bool isBarrier(SILInstruction *inst) {
199199
case BuiltinValueKind::ResumeThrowingContinuationReturning:
200200
case BuiltinValueKind::ResumeThrowingContinuationThrowing:
201201
case BuiltinValueKind::AutoDiffProjectTopLevelSubcontext:
202-
case BuiltinValueKind::AutoDiffAllocateSubcontext:
202+
case BuiltinValueKind::AutoDiffAllocateSubcontextWithType:
203203
case BuiltinValueKind::AddressOfBorrowOpaque:
204204
case BuiltinValueKind::UnprotectedAddressOfBorrowOpaque:
205205
return true;

stdlib/public/runtime/AutoDiffSupport.cpp

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ static FullMetadata<HeapMetadata> linearMapContextHeapMetadata = {
4343
}
4444
};
4545

46+
AutoDiffLinearMapContext::AutoDiffLinearMapContext()
47+
: HeapObject(&linearMapContextHeapMetadata) {
48+
}
49+
4650
AutoDiffLinearMapContext::AutoDiffLinearMapContext(
4751
const Metadata *topLevelLinearMapContextMetadata)
4852
: HeapObject(&linearMapContextHeapMetadata) {
@@ -51,10 +55,14 @@ AutoDiffLinearMapContext::AutoDiffLinearMapContext(
5155
}
5256

5357
void *AutoDiffLinearMapContext::projectTopLevelSubcontext() const {
54-
auto offset = alignTo(sizeof(AutoDiffLinearMapContext),
55-
alignof(AutoDiffLinearMapContext));
56-
return const_cast<uint8_t *>(reinterpret_cast<const uint8_t *>(this) +
57-
offset);
58+
auto offset = alignTo(
59+
sizeof(AutoDiffLinearMapContext), alignof(AutoDiffLinearMapContext));
60+
return const_cast<uint8_t *>(
61+
reinterpret_cast<const uint8_t *>(this) + offset);
62+
}
63+
64+
void *AutoDiffLinearMapContext::allocate(size_t size) {
65+
return allocator.Allocate(size, alignof(AutoDiffLinearMapContext));
5866
}
5967

6068
void *AutoDiffLinearMapContext::allocateSubcontext(
@@ -68,7 +76,27 @@ void *AutoDiffLinearMapContext::allocateSubcontext(
6876
}
6977

7078
AutoDiffLinearMapContext *swift::swift_autoDiffCreateLinearMapContext(
79+
size_t topLevelLinearMapStructSize) {
80+
auto allocationSize = alignTo(
81+
sizeof(AutoDiffLinearMapContext), alignof(AutoDiffLinearMapContext))
82+
+ topLevelLinearMapStructSize;
83+
auto *buffer = (AutoDiffLinearMapContext *)malloc(allocationSize);
84+
return ::new (buffer) AutoDiffLinearMapContext;
85+
}
86+
87+
void *swift::swift_autoDiffProjectTopLevelSubcontext(
88+
AutoDiffLinearMapContext *linearMapContext) {
89+
return static_cast<void *>(linearMapContext->projectTopLevelSubcontext());
90+
}
91+
92+
void *swift::swift_autoDiffAllocateSubcontext(
93+
AutoDiffLinearMapContext *allocator, size_t size) {
94+
return allocator->allocate(size);
95+
}
96+
97+
AutoDiffLinearMapContext *swift::swift_autoDiffCreateLinearMapContextWithType(
7198
const Metadata *topLevelLinearMapContextMetadata) {
99+
assert(topLevelLinearMapContextMetadata->getValueWitnesses() != nullptr);
72100
auto topLevelLinearMapContextSize =
73101
topLevelLinearMapContextMetadata->vw_size();
74102
auto allocationSize = alignTo(sizeof(AutoDiffLinearMapContext),
@@ -79,13 +107,9 @@ AutoDiffLinearMapContext *swift::swift_autoDiffCreateLinearMapContext(
79107
AutoDiffLinearMapContext(topLevelLinearMapContextMetadata);
80108
}
81109

82-
void *swift::swift_autoDiffProjectTopLevelSubcontext(
83-
AutoDiffLinearMapContext *linearMapContext) {
84-
return static_cast<void *>(linearMapContext->projectTopLevelSubcontext());
85-
}
86-
87-
void *swift::swift_autoDiffAllocateSubcontext(
110+
void *swift::swift_autoDiffAllocateSubcontextWithType(
88111
AutoDiffLinearMapContext *linearMapContext,
89112
const Metadata *linearMapSubcontextMetadata) {
113+
assert(linearMapSubcontextMetadata->getValueWitnesses() != nullptr);
90114
return linearMapContext->allocateSubcontext(linearMapSubcontextMetadata);
91115
}

0 commit comments

Comments
 (0)