@@ -1716,8 +1716,10 @@ static void AppendCPUSpecificCPUDispatchMangling(const CodeGenModule &CGM,
1716
1716
static void AppendTargetVersionMangling (const CodeGenModule &CGM,
1717
1717
const TargetVersionAttr *Attr,
1718
1718
raw_ostream &Out) {
1719
- if (Attr->isDefaultVersion ())
1719
+ if (Attr->isDefaultVersion ()) {
1720
+ Out << " .default" ;
1720
1721
return ;
1722
+ }
1721
1723
Out << " ._" ;
1722
1724
const TargetInfo &TI = CGM.getTarget ();
1723
1725
llvm::SmallVector<StringRef, 8 > Feats;
@@ -1780,8 +1782,10 @@ static void AppendTargetClonesMangling(const CodeGenModule &CGM,
1780
1782
const TargetInfo &TI = CGM.getTarget ();
1781
1783
if (TI.getTriple ().isAArch64 ()) {
1782
1784
StringRef FeatureStr = Attr->getFeatureStr (VersionIndex);
1783
- if (FeatureStr == " default" )
1785
+ if (FeatureStr == " default" ) {
1786
+ Out << " .default" ;
1784
1787
return ;
1788
+ }
1785
1789
Out << " ._" ;
1786
1790
SmallVector<StringRef, 8 > Features;
1787
1791
FeatureStr.split (Features, " +" );
@@ -4029,6 +4033,8 @@ void CodeGenModule::EmitMultiVersionFunctionDefinition(GlobalDecl GD,
4029
4033
EmitGlobalFunctionDefinition (GD.getWithMultiVersionIndex (I), nullptr );
4030
4034
// Ensure that the resolver function is also emitted.
4031
4035
GetOrCreateMultiVersionResolver (GD);
4036
+ } else if (FD->hasAttr <TargetVersionAttr>()) {
4037
+ GetOrCreateMultiVersionResolver (GD);
4032
4038
} else
4033
4039
EmitGlobalFunctionDefinition (GD, GV);
4034
4040
}
@@ -4210,14 +4216,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
4210
4216
llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver (GD);
4211
4217
if (auto *IFunc = dyn_cast<llvm::GlobalIFunc>(ResolverConstant)) {
4212
4218
ResolverConstant = IFunc->getResolver ();
4213
- // In Aarch64, default versions of multiversioned functions are mangled to
4214
- // their 'normal' assembly name. This deviates from other targets which
4215
- // append a '.default' string. As a result we need to continue appending
4216
- // .ifunc in Aarch64.
4217
- // FIXME: Should Aarch64 mangling for 'default' multiversion function and
4218
- // in turn ifunc function match that of other targets?
4219
- if (FD->isTargetClonesMultiVersion () &&
4220
- !getTarget ().getTriple ().isAArch64 ()) {
4219
+ if (FD->isTargetClonesMultiVersion ()) {
4221
4220
const CGFunctionInfo &FI = getTypes ().arrangeGlobalDeclaration (GD);
4222
4221
llvm::FunctionType *DeclTy = getTypes ().GetFunctionType (FI);
4223
4222
std::string MangledName = getMangledNameImpl (
@@ -4398,14 +4397,7 @@ llvm::Constant *CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
4398
4397
// a separate resolver).
4399
4398
std::string ResolverName = MangledName;
4400
4399
if (getTarget ().supportsIFunc ()) {
4401
- // In Aarch64, default versions of multiversioned functions are mangled to
4402
- // their 'normal' assembly name. This deviates from other targets which
4403
- // append a '.default' string. As a result we need to continue appending
4404
- // .ifunc in Aarch64.
4405
- // FIXME: Should Aarch64 mangling for 'default' multiversion function and
4406
- // in turn ifunc function match that of other targets?
4407
- if (!FD->isTargetClonesMultiVersion () ||
4408
- getTarget ().getTriple ().isAArch64 ())
4400
+ if (!FD->isTargetClonesMultiVersion ())
4409
4401
ResolverName += " .ifunc" ;
4410
4402
} else if (FD->isTargetMultiVersion ()) {
4411
4403
ResolverName += " .resolver" ;
0 commit comments