@@ -287,7 +287,8 @@ static Flags getMethodDescriptorFlags(ValueDecl *fn) {
287287static void buildMethodDescriptorFields (IRGenModule &IGM,
288288 const SILVTable *VTable,
289289 SILDeclRef fn,
290- ConstantStructBuilder &descriptor) {
290+ ConstantStructBuilder &descriptor,
291+ ClassDecl *classDecl) {
291292 auto *func = cast<AbstractFunctionDecl>(fn.getDecl ());
292293 // Classify the method.
293294 using Flags = MethodDescriptorFlags;
@@ -318,6 +319,13 @@ static void buildMethodDescriptorFields(IRGenModule &IGM,
318319 descriptor.addRelativeAddress (implFn);
319320 } else {
320321 llvm::Function *implFn = IGM.getAddrOfSILFunction (impl, NotForDefinition);
322+
323+ if (IGM.getOptions ().UseProfilingMarkerThunks &&
324+ classDecl->getSelfNominalTypeDecl ()->isGenericContext () &&
325+ !impl->getLoweredFunctionType ()->isCoroutine ()) {
326+ implFn = IGM.getAddrOfVTableProfilingThunk (implFn, classDecl);
327+ }
328+
321329 descriptor.addCompactFunctionReference (implFn);
322330 }
323331 } else {
@@ -328,7 +336,8 @@ static void buildMethodDescriptorFields(IRGenModule &IGM,
328336}
329337
330338void IRGenModule::emitNonoverriddenMethodDescriptor (const SILVTable *VTable,
331- SILDeclRef declRef) {
339+ SILDeclRef declRef,
340+ ClassDecl *classDecl) {
332341 auto entity = LinkEntity::forMethodDescriptor (declRef);
333342 auto *var = cast<llvm::GlobalVariable>(
334343 getAddrOfLLVMVariable (entity, ConstantInit (), DebugTypeInfo ()));
@@ -343,7 +352,7 @@ void IRGenModule::emitNonoverriddenMethodDescriptor(const SILVTable *VTable,
343352 ConstantInitBuilder ib (*this );
344353 ConstantStructBuilder sb (ib.beginStruct (MethodDescriptorStructTy));
345354
346- buildMethodDescriptorFields (*this , VTable, declRef, sb);
355+ buildMethodDescriptorFields (*this , VTable, declRef, sb, classDecl );
347356
348357 auto init = sb.finishAndCreateFuture ();
349358
@@ -2081,7 +2090,7 @@ namespace {
20812090
20822091 // Actually build the descriptor.
20832092 auto descriptor = B.beginStruct (IGM.MethodDescriptorStructTy );
2084- buildMethodDescriptorFields (IGM, VTable, fn, descriptor);
2093+ buildMethodDescriptorFields (IGM, VTable, fn, descriptor, getType () );
20852094 descriptor.finishAndAddTo (B);
20862095
20872096 // Emit method dispatch thunk if the class is resilient.
@@ -2129,7 +2138,7 @@ namespace {
21292138 // exist in the table in the class's context descriptor since it isn't
21302139 // in the vtable, but external clients need to be able to link against the
21312140 // symbol.
2132- IGM.emitNonoverriddenMethodDescriptor (VTable, fn);
2141+ IGM.emitNonoverriddenMethodDescriptor (VTable, fn, getType () );
21332142 }
21342143
21352144 void addOverrideTable () {
0 commit comments