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