Skip to content

Commit d257243

Browse files
committed
[FMV] Emit the resolver along with the default version definition.
We would like the resolver to be generated eagerly, even if the versioned function is not called from the current translation unit. Fixes #81494.
1 parent f78129e commit d257243

File tree

3 files changed

+364
-218
lines changed

3 files changed

+364
-218
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3969,8 +3969,11 @@ void CodeGenModule::EmitMultiVersionFunctionDefinition(GlobalDecl GD,
39693969
EmitGlobalFunctionDefinition(GD.getWithMultiVersionIndex(I), nullptr);
39703970
// Ensure that the resolver function is also emitted.
39713971
GetOrCreateMultiVersionResolver(GD);
3972-
} else if (FD->hasAttr<TargetVersionAttr>()) {
3973-
GetOrCreateMultiVersionResolver(GD);
3972+
} else if (auto *TVA = FD->getAttr<TargetVersionAttr>()) {
3973+
EmitGlobalFunctionDefinition(GD, GV);
3974+
// Emit the resolver alongside with the default version definition.
3975+
if (TVA->isDefaultVersion() && FD->doesThisDeclarationHaveABody())
3976+
GetOrCreateMultiVersionResolver(GD);
39743977
} else
39753978
EmitGlobalFunctionDefinition(GD, GV);
39763979
}

0 commit comments

Comments
 (0)