@@ -287,7 +287,8 @@ static Flags getMethodDescriptorFlags(ValueDecl *fn) {
287
287
static void buildMethodDescriptorFields (IRGenModule &IGM,
288
288
const SILVTable *VTable,
289
289
SILDeclRef fn,
290
- ConstantStructBuilder &descriptor) {
290
+ ConstantStructBuilder &descriptor,
291
+ ClassDecl *classDecl) {
291
292
auto *func = cast<AbstractFunctionDecl>(fn.getDecl ());
292
293
// Classify the method.
293
294
using Flags = MethodDescriptorFlags;
@@ -318,6 +319,13 @@ static void buildMethodDescriptorFields(IRGenModule &IGM,
318
319
descriptor.addRelativeAddress (implFn);
319
320
} else {
320
321
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
+
321
329
descriptor.addCompactFunctionReference (implFn);
322
330
}
323
331
} else {
@@ -328,7 +336,8 @@ static void buildMethodDescriptorFields(IRGenModule &IGM,
328
336
}
329
337
330
338
void IRGenModule::emitNonoverriddenMethodDescriptor (const SILVTable *VTable,
331
- SILDeclRef declRef) {
339
+ SILDeclRef declRef,
340
+ ClassDecl *classDecl) {
332
341
auto entity = LinkEntity::forMethodDescriptor (declRef);
333
342
auto *var = cast<llvm::GlobalVariable>(
334
343
getAddrOfLLVMVariable (entity, ConstantInit (), DebugTypeInfo ()));
@@ -343,7 +352,7 @@ void IRGenModule::emitNonoverriddenMethodDescriptor(const SILVTable *VTable,
343
352
ConstantInitBuilder ib (*this );
344
353
ConstantStructBuilder sb (ib.beginStruct (MethodDescriptorStructTy));
345
354
346
- buildMethodDescriptorFields (*this , VTable, declRef, sb);
355
+ buildMethodDescriptorFields (*this , VTable, declRef, sb, classDecl );
347
356
348
357
auto init = sb.finishAndCreateFuture ();
349
358
@@ -2081,7 +2090,7 @@ namespace {
2081
2090
2082
2091
// Actually build the descriptor.
2083
2092
auto descriptor = B.beginStruct (IGM.MethodDescriptorStructTy );
2084
- buildMethodDescriptorFields (IGM, VTable, fn, descriptor);
2093
+ buildMethodDescriptorFields (IGM, VTable, fn, descriptor, getType () );
2085
2094
descriptor.finishAndAddTo (B);
2086
2095
2087
2096
// Emit method dispatch thunk if the class is resilient.
@@ -2129,7 +2138,7 @@ namespace {
2129
2138
// exist in the table in the class's context descriptor since it isn't
2130
2139
// in the vtable, but external clients need to be able to link against the
2131
2140
// symbol.
2132
- IGM.emitNonoverriddenMethodDescriptor (VTable, fn);
2141
+ IGM.emitNonoverriddenMethodDescriptor (VTable, fn, getType () );
2133
2142
}
2134
2143
2135
2144
void addOverrideTable () {
0 commit comments