@@ -1606,8 +1606,10 @@ static void AppendCPUSpecificCPUDispatchMangling(const CodeGenModule &CGM,
1606
1606
static void AppendTargetVersionMangling (const CodeGenModule &CGM,
1607
1607
const TargetVersionAttr *Attr,
1608
1608
raw_ostream &Out) {
1609
- if (Attr->isDefaultVersion ())
1609
+ if (Attr->isDefaultVersion ()) {
1610
+ Out << " .default" ;
1610
1611
return ;
1612
+ }
1611
1613
Out << " ._" ;
1612
1614
const TargetInfo &TI = CGM.getTarget ();
1613
1615
llvm::SmallVector<StringRef, 8 > Feats;
@@ -1670,8 +1672,10 @@ static void AppendTargetClonesMangling(const CodeGenModule &CGM,
1670
1672
const TargetInfo &TI = CGM.getTarget ();
1671
1673
if (TI.getTriple ().isAArch64 ()) {
1672
1674
StringRef FeatureStr = Attr->getFeatureStr (VersionIndex);
1673
- if (FeatureStr == " default" )
1675
+ if (FeatureStr == " default" ) {
1676
+ Out << " .default" ;
1674
1677
return ;
1678
+ }
1675
1679
Out << " ._" ;
1676
1680
SmallVector<StringRef, 8 > Features;
1677
1681
FeatureStr.split (Features, " +" );
@@ -3868,6 +3872,8 @@ void CodeGenModule::EmitMultiVersionFunctionDefinition(GlobalDecl GD,
3868
3872
EmitGlobalFunctionDefinition (GD.getWithMultiVersionIndex (I), nullptr );
3869
3873
// Ensure that the resolver function is also emitted.
3870
3874
GetOrCreateMultiVersionResolver (GD);
3875
+ } else if (FD->hasAttr <TargetVersionAttr>()) {
3876
+ GetOrCreateMultiVersionResolver (GD);
3871
3877
} else
3872
3878
EmitGlobalFunctionDefinition (GD, GV);
3873
3879
}
@@ -4049,14 +4055,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
4049
4055
llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver (GD);
4050
4056
if (auto *IFunc = dyn_cast<llvm::GlobalIFunc>(ResolverConstant)) {
4051
4057
ResolverConstant = IFunc->getResolver ();
4052
- // In Aarch64, default versions of multiversioned functions are mangled to
4053
- // their 'normal' assembly name. This deviates from other targets which
4054
- // append a '.default' string. As a result we need to continue appending
4055
- // .ifunc in Aarch64.
4056
- // FIXME: Should Aarch64 mangling for 'default' multiversion function and
4057
- // in turn ifunc function match that of other targets?
4058
- if (FD->isTargetClonesMultiVersion () &&
4059
- !getTarget ().getTriple ().isAArch64 ()) {
4058
+ if (FD->isTargetClonesMultiVersion ()) {
4060
4059
const CGFunctionInfo &FI = getTypes ().arrangeGlobalDeclaration (GD);
4061
4060
llvm::FunctionType *DeclTy = getTypes ().GetFunctionType (FI);
4062
4061
std::string MangledName = getMangledNameImpl (
@@ -4236,14 +4235,7 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
4236
4235
// a separate resolver).
4237
4236
std::string ResolverName = MangledName;
4238
4237
if (getTarget ().supportsIFunc ()) {
4239
- // In Aarch64, default versions of multiversioned functions are mangled to
4240
- // their 'normal' assembly name. This deviates from other targets which
4241
- // append a '.default' string. As a result we need to continue appending
4242
- // .ifunc in Aarch64.
4243
- // FIXME: Should Aarch64 mangling for 'default' multiversion function and
4244
- // in turn ifunc function match that of other targets?
4245
- if (!FD->isTargetClonesMultiVersion () ||
4246
- getTarget ().getTriple ().isAArch64 ())
4238
+ if (!FD->isTargetClonesMultiVersion ())
4247
4239
ResolverName += " .ifunc" ;
4248
4240
} else if (FD->isTargetMultiVersion ()) {
4249
4241
ResolverName += " .resolver" ;
0 commit comments