@@ -1604,59 +1604,6 @@ static void AppendCPUSpecificCPUDispatchMangling(const CodeGenModule &CGM,
1604
1604
Out << " .resolver" ;
1605
1605
}
1606
1606
1607
- static void AppendTargetVersionMangling (const CodeGenModule &CGM,
1608
- const TargetVersionAttr *Attr,
1609
- raw_ostream &Out) {
1610
- if (Attr->isDefaultVersion ()) {
1611
- Out << " .default" ;
1612
- return ;
1613
- }
1614
- Out << " ._" ;
1615
- const TargetInfo &TI = CGM.getTarget ();
1616
- llvm::SmallVector<StringRef, 8 > Feats;
1617
- Attr->getFeatures (Feats);
1618
- llvm::stable_sort (Feats, [&TI](const StringRef FeatL, const StringRef FeatR) {
1619
- return TI.multiVersionSortPriority (FeatL) <
1620
- TI.multiVersionSortPriority (FeatR);
1621
- });
1622
- for (const auto &Feat : Feats) {
1623
- Out << ' M' ;
1624
- Out << Feat;
1625
- }
1626
- }
1627
-
1628
- static void AppendTargetMangling (const CodeGenModule &CGM,
1629
- const TargetAttr *Attr, raw_ostream &Out) {
1630
- if (Attr->isDefaultVersion ())
1631
- return ;
1632
-
1633
- Out << ' .' ;
1634
- const TargetInfo &Target = CGM.getTarget ();
1635
- ParsedTargetAttr Info = Target.parseTargetAttr (Attr->getFeaturesStr ());
1636
- llvm::sort (Info.Features , [&Target](StringRef LHS, StringRef RHS) {
1637
- // Multiversioning doesn't allow "no-${feature}", so we can
1638
- // only have "+" prefixes here.
1639
- assert (LHS.startswith (" +" ) && RHS.startswith (" +" ) &&
1640
- " Features should always have a prefix." );
1641
- return Target.multiVersionSortPriority (LHS.substr (1 )) >
1642
- Target.multiVersionSortPriority (RHS.substr (1 ));
1643
- });
1644
-
1645
- bool IsFirst = true ;
1646
-
1647
- if (!Info.CPU .empty ()) {
1648
- IsFirst = false ;
1649
- Out << " arch_" << Info.CPU ;
1650
- }
1651
-
1652
- for (StringRef Feat : Info.Features ) {
1653
- if (!IsFirst)
1654
- Out << ' _' ;
1655
- IsFirst = false ;
1656
- Out << Feat.substr (1 );
1657
- }
1658
- }
1659
-
1660
1607
// Returns true if GD is a function decl with internal linkage and
1661
1608
// needs a unique suffix after the mangled name.
1662
1609
static bool isUniqueInternalLinkageDecl (GlobalDecl GD,
@@ -1666,41 +1613,6 @@ static bool isUniqueInternalLinkageDecl(GlobalDecl GD,
1666
1613
(CGM.getFunctionLinkage (GD) == llvm::GlobalValue::InternalLinkage);
1667
1614
}
1668
1615
1669
- static void AppendTargetClonesMangling (const CodeGenModule &CGM,
1670
- const TargetClonesAttr *Attr,
1671
- unsigned VersionIndex,
1672
- raw_ostream &Out) {
1673
- const TargetInfo &TI = CGM.getTarget ();
1674
- if (TI.getTriple ().isAArch64 ()) {
1675
- StringRef FeatureStr = Attr->getFeatureStr (VersionIndex);
1676
- if (FeatureStr == " default" ) {
1677
- Out << " .default" ;
1678
- return ;
1679
- }
1680
- Out << " ._" ;
1681
- SmallVector<StringRef, 8 > Features;
1682
- FeatureStr.split (Features, " +" );
1683
- llvm::stable_sort (Features,
1684
- [&TI](const StringRef FeatL, const StringRef FeatR) {
1685
- return TI.multiVersionSortPriority (FeatL) <
1686
- TI.multiVersionSortPriority (FeatR);
1687
- });
1688
- for (auto &Feat : Features) {
1689
- Out << ' M' ;
1690
- Out << Feat;
1691
- }
1692
- } else {
1693
- Out << ' .' ;
1694
- StringRef FeatureStr = Attr->getFeatureStr (VersionIndex);
1695
- if (FeatureStr.startswith (" arch=" ))
1696
- Out << " arch_" << FeatureStr.substr (sizeof (" arch=" ) - 1 );
1697
- else
1698
- Out << FeatureStr;
1699
-
1700
- Out << ' .' << Attr->getMangledIndex (VersionIndex);
1701
- }
1702
- }
1703
-
1704
1616
static std::string getMangledNameImpl (CodeGenModule &CGM, GlobalDecl GD,
1705
1617
const NamedDecl *ND,
1706
1618
bool OmitMultiVersionMangling = false ) {
@@ -1751,16 +1663,25 @@ static std::string getMangledNameImpl(CodeGenModule &CGM, GlobalDecl GD,
1751
1663
FD->getAttr <CPUSpecificAttr>(),
1752
1664
GD.getMultiVersionIndex (), Out);
1753
1665
break ;
1754
- case MultiVersionKind::Target:
1755
- AppendTargetMangling (CGM, FD->getAttr <TargetAttr>(), Out);
1666
+ case MultiVersionKind::Target: {
1667
+ auto *Attr = FD->getAttr <TargetAttr>();
1668
+ const ABIInfo &Info = CGM.getTargetCodeGenInfo ().getABIInfo ();
1669
+ Info.appendAttributeMangling (Attr, Out);
1756
1670
break ;
1757
- case MultiVersionKind::TargetVersion:
1758
- AppendTargetVersionMangling (CGM, FD->getAttr <TargetVersionAttr>(), Out);
1671
+ }
1672
+ case MultiVersionKind::TargetVersion: {
1673
+ auto *Attr = FD->getAttr <TargetVersionAttr>();
1674
+ const ABIInfo &Info = CGM.getTargetCodeGenInfo ().getABIInfo ();
1675
+ Info.appendAttributeMangling (Attr, Out);
1759
1676
break ;
1760
- case MultiVersionKind::TargetClones:
1761
- AppendTargetClonesMangling (CGM, FD->getAttr <TargetClonesAttr>(),
1762
- GD.getMultiVersionIndex (), Out);
1677
+ }
1678
+ case MultiVersionKind::TargetClones: {
1679
+ auto *Attr = FD->getAttr <TargetClonesAttr>();
1680
+ unsigned Index = GD.getMultiVersionIndex ();
1681
+ const ABIInfo &Info = CGM.getTargetCodeGenInfo ().getABIInfo ();
1682
+ Info.appendAttributeMangling (Attr, Index, Out);
1763
1683
break ;
1684
+ }
1764
1685
case MultiVersionKind::None:
1765
1686
llvm_unreachable (" None multiversion type isn't valid here" );
1766
1687
}
0 commit comments