@@ -1727,59 +1727,6 @@ static void AppendCPUSpecificCPUDispatchMangling(const CodeGenModule &CGM,
1727
1727
Out << " .resolver" ;
1728
1728
}
1729
1729
1730
- static void AppendTargetVersionMangling (const CodeGenModule &CGM,
1731
- const TargetVersionAttr *Attr,
1732
- raw_ostream &Out) {
1733
- if (Attr->isDefaultVersion ()) {
1734
- Out << " .default" ;
1735
- return ;
1736
- }
1737
- Out << " ._" ;
1738
- const TargetInfo &TI = CGM.getTarget ();
1739
- llvm::SmallVector<StringRef, 8 > Feats;
1740
- Attr->getFeatures (Feats);
1741
- llvm::stable_sort (Feats, [&TI](const StringRef FeatL, const StringRef FeatR) {
1742
- return TI.multiVersionSortPriority (FeatL) <
1743
- TI.multiVersionSortPriority (FeatR);
1744
- });
1745
- for (const auto &Feat : Feats) {
1746
- Out << ' M' ;
1747
- Out << Feat;
1748
- }
1749
- }
1750
-
1751
- static void AppendTargetMangling (const CodeGenModule &CGM,
1752
- const TargetAttr *Attr, raw_ostream &Out) {
1753
- if (Attr->isDefaultVersion ())
1754
- return ;
1755
-
1756
- Out << ' .' ;
1757
- const TargetInfo &Target = CGM.getTarget ();
1758
- ParsedTargetAttr Info = Target.parseTargetAttr (Attr->getFeaturesStr ());
1759
- llvm::sort (Info.Features , [&Target](StringRef LHS, StringRef RHS) {
1760
- // Multiversioning doesn't allow "no-${feature}", so we can
1761
- // only have "+" prefixes here.
1762
- assert (LHS.starts_with (" +" ) && RHS.starts_with (" +" ) &&
1763
- " Features should always have a prefix." );
1764
- return Target.multiVersionSortPriority (LHS.substr (1 )) >
1765
- Target.multiVersionSortPriority (RHS.substr (1 ));
1766
- });
1767
-
1768
- bool IsFirst = true ;
1769
-
1770
- if (!Info.CPU .empty ()) {
1771
- IsFirst = false ;
1772
- Out << " arch_" << Info.CPU ;
1773
- }
1774
-
1775
- for (StringRef Feat : Info.Features ) {
1776
- if (!IsFirst)
1777
- Out << ' _' ;
1778
- IsFirst = false ;
1779
- Out << Feat.substr (1 );
1780
- }
1781
- }
1782
-
1783
1730
// Returns true if GD is a function decl with internal linkage and
1784
1731
// needs a unique suffix after the mangled name.
1785
1732
static bool isUniqueInternalLinkageDecl (GlobalDecl GD,
@@ -1789,41 +1736,6 @@ static bool isUniqueInternalLinkageDecl(GlobalDecl GD,
1789
1736
(CGM.getFunctionLinkage (GD) == llvm::GlobalValue::InternalLinkage);
1790
1737
}
1791
1738
1792
- static void AppendTargetClonesMangling (const CodeGenModule &CGM,
1793
- const TargetClonesAttr *Attr,
1794
- unsigned VersionIndex,
1795
- raw_ostream &Out) {
1796
- const TargetInfo &TI = CGM.getTarget ();
1797
- if (TI.getTriple ().isAArch64 ()) {
1798
- StringRef FeatureStr = Attr->getFeatureStr (VersionIndex);
1799
- if (FeatureStr == " default" ) {
1800
- Out << " .default" ;
1801
- return ;
1802
- }
1803
- Out << " ._" ;
1804
- SmallVector<StringRef, 8 > Features;
1805
- FeatureStr.split (Features, " +" );
1806
- llvm::stable_sort (Features,
1807
- [&TI](const StringRef FeatL, const StringRef FeatR) {
1808
- return TI.multiVersionSortPriority (FeatL) <
1809
- TI.multiVersionSortPriority (FeatR);
1810
- });
1811
- for (auto &Feat : Features) {
1812
- Out << ' M' ;
1813
- Out << Feat;
1814
- }
1815
- } else {
1816
- Out << ' .' ;
1817
- StringRef FeatureStr = Attr->getFeatureStr (VersionIndex);
1818
- if (FeatureStr.starts_with (" arch=" ))
1819
- Out << " arch_" << FeatureStr.substr (sizeof (" arch=" ) - 1 );
1820
- else
1821
- Out << FeatureStr;
1822
-
1823
- Out << ' .' << Attr->getMangledIndex (VersionIndex);
1824
- }
1825
- }
1826
-
1827
1739
static std::string getMangledNameImpl (CodeGenModule &CGM, GlobalDecl GD,
1828
1740
const NamedDecl *ND,
1829
1741
bool OmitMultiVersionMangling = false ) {
@@ -1877,16 +1789,25 @@ static std::string getMangledNameImpl(CodeGenModule &CGM, GlobalDecl GD,
1877
1789
FD->getAttr <CPUSpecificAttr>(),
1878
1790
GD.getMultiVersionIndex (), Out);
1879
1791
break ;
1880
- case MultiVersionKind::Target:
1881
- AppendTargetMangling (CGM, FD->getAttr <TargetAttr>(), Out);
1792
+ case MultiVersionKind::Target: {
1793
+ auto *Attr = FD->getAttr <TargetAttr>();
1794
+ const ABIInfo &Info = CGM.getTargetCodeGenInfo ().getABIInfo ();
1795
+ Info.appendAttributeMangling (Attr, Out);
1882
1796
break ;
1883
- case MultiVersionKind::TargetVersion:
1884
- AppendTargetVersionMangling (CGM, FD->getAttr <TargetVersionAttr>(), Out);
1797
+ }
1798
+ case MultiVersionKind::TargetVersion: {
1799
+ auto *Attr = FD->getAttr <TargetVersionAttr>();
1800
+ const ABIInfo &Info = CGM.getTargetCodeGenInfo ().getABIInfo ();
1801
+ Info.appendAttributeMangling (Attr, Out);
1885
1802
break ;
1886
- case MultiVersionKind::TargetClones:
1887
- AppendTargetClonesMangling (CGM, FD->getAttr <TargetClonesAttr>(),
1888
- GD.getMultiVersionIndex (), Out);
1803
+ }
1804
+ case MultiVersionKind::TargetClones: {
1805
+ auto *Attr = FD->getAttr <TargetClonesAttr>();
1806
+ unsigned Index = GD.getMultiVersionIndex ();
1807
+ const ABIInfo &Info = CGM.getTargetCodeGenInfo ().getABIInfo ();
1808
+ Info.appendAttributeMangling (Attr, Index, Out);
1889
1809
break ;
1810
+ }
1890
1811
case MultiVersionKind::None:
1891
1812
llvm_unreachable (" None multiversion type isn't valid here" );
1892
1813
}
0 commit comments