Skip to content

Commit

Permalink
[FMV] Emit the resolver along with the default version definition.
Browse files Browse the repository at this point in the history
We would like the resolver to be generated eagerly, even if the
versioned function is not called from the current translation
unit. Fixes #81494.
  • Loading branch information
labrinea committed Mar 7, 2024
1 parent f78129e commit d257243
Show file tree
Hide file tree
Showing 3 changed files with 364 additions and 218 deletions.
7 changes: 5 additions & 2 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3969,8 +3969,11 @@ void CodeGenModule::EmitMultiVersionFunctionDefinition(GlobalDecl GD,
EmitGlobalFunctionDefinition(GD.getWithMultiVersionIndex(I), nullptr);
// Ensure that the resolver function is also emitted.
GetOrCreateMultiVersionResolver(GD);
} else if (FD->hasAttr<TargetVersionAttr>()) {
GetOrCreateMultiVersionResolver(GD);
} else if (auto *TVA = FD->getAttr<TargetVersionAttr>()) {
EmitGlobalFunctionDefinition(GD, GV);
// Emit the resolver alongside with the default version definition.
if (TVA->isDefaultVersion() && FD->doesThisDeclarationHaveABody())
GetOrCreateMultiVersionResolver(GD);
} else
EmitGlobalFunctionDefinition(GD, GV);
}
Expand Down
Loading

0 comments on commit d257243

Please sign in to comment.