@@ -1777,23 +1777,7 @@ void FrameEmitterImpl::EmitFDE(const MCSymbol &cieStart,
17771777namespace {
17781778
17791779struct CIEKey {
1780- static const CIEKey getEmptyKey () {
1781- return CIEKey (nullptr , 0 , -1 , false , false , static_cast <unsigned >(INT_MAX),
1782- false , false );
1783- }
1784-
1785- static const CIEKey getTombstoneKey () {
1786- return CIEKey (nullptr , -1 , 0 , false , false , static_cast <unsigned >(INT_MAX),
1787- false , false );
1788- }
1789-
1790- CIEKey (const MCSymbol *Personality, unsigned PersonalityEncoding,
1791- unsigned LSDAEncoding, bool IsSignalFrame, bool IsSimple,
1792- unsigned RAReg, bool IsBKeyFrame, bool IsMTETaggedFrame)
1793- : Personality(Personality), PersonalityEncoding(PersonalityEncoding),
1794- LsdaEncoding (LSDAEncoding), IsSignalFrame(IsSignalFrame),
1795- IsSimple(IsSimple), RAReg(RAReg), IsBKeyFrame(IsBKeyFrame),
1796- IsMTETaggedFrame(IsMTETaggedFrame) {}
1780+ CIEKey () = default ;
17971781
17981782 explicit CIEKey (const MCDwarfFrameInfo &Frame)
17991783 : Personality(Frame.Personality),
@@ -1819,44 +1803,28 @@ struct CIEKey {
18191803 Other.IsMTETaggedFrame );
18201804 }
18211805
1822- const MCSymbol *Personality;
1823- unsigned PersonalityEncoding;
1824- unsigned LsdaEncoding;
1825- bool IsSignalFrame;
1826- bool IsSimple;
1827- unsigned RAReg;
1828- bool IsBKeyFrame;
1829- bool IsMTETaggedFrame;
1806+ bool operator ==(const CIEKey &Other) const {
1807+ return Personality == Other.Personality &&
1808+ PersonalityEncoding == Other.PersonalityEncoding &&
1809+ LsdaEncoding == Other.LsdaEncoding &&
1810+ IsSignalFrame == Other.IsSignalFrame && IsSimple == Other.IsSimple &&
1811+ RAReg == Other.RAReg && IsBKeyFrame == Other.IsBKeyFrame &&
1812+ IsMTETaggedFrame == Other.IsMTETaggedFrame ;
1813+ }
1814+ bool operator !=(const CIEKey &Other) const { return !(*this == Other); }
1815+
1816+ const MCSymbol *Personality = nullptr ;
1817+ unsigned PersonalityEncoding = 0 ;
1818+ unsigned LsdaEncoding = -1 ;
1819+ bool IsSignalFrame = false ;
1820+ bool IsSimple = false ;
1821+ unsigned RAReg = static_cast <unsigned >(UINT_MAX);
1822+ bool IsBKeyFrame = false ;
1823+ bool IsMTETaggedFrame = false ;
18301824};
18311825
18321826} // end anonymous namespace
18331827
1834- namespace llvm {
1835-
1836- template <> struct DenseMapInfo <CIEKey> {
1837- static CIEKey getEmptyKey () { return CIEKey::getEmptyKey (); }
1838- static CIEKey getTombstoneKey () { return CIEKey::getTombstoneKey (); }
1839-
1840- static unsigned getHashValue (const CIEKey &Key) {
1841- return static_cast <unsigned >(
1842- hash_combine (Key.Personality , Key.PersonalityEncoding , Key.LsdaEncoding ,
1843- Key.IsSignalFrame , Key.IsSimple , Key.RAReg ,
1844- Key.IsBKeyFrame , Key.IsMTETaggedFrame ));
1845- }
1846-
1847- static bool isEqual (const CIEKey &LHS, const CIEKey &RHS) {
1848- return LHS.Personality == RHS.Personality &&
1849- LHS.PersonalityEncoding == RHS.PersonalityEncoding &&
1850- LHS.LsdaEncoding == RHS.LsdaEncoding &&
1851- LHS.IsSignalFrame == RHS.IsSignalFrame &&
1852- LHS.IsSimple == RHS.IsSimple && LHS.RAReg == RHS.RAReg &&
1853- LHS.IsBKeyFrame == RHS.IsBKeyFrame &&
1854- LHS.IsMTETaggedFrame == RHS.IsMTETaggedFrame ;
1855- }
1856- };
1857-
1858- } // end namespace llvm
1859-
18601828void MCDwarfFrameEmitter::Emit (MCObjectStreamer &Streamer, MCAsmBackend *MAB,
18611829 bool IsEH) {
18621830 MCContext &Context = Streamer.getContext ();
@@ -1898,9 +1866,6 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
18981866 MCSymbol *SectionStart = Context.createTempSymbol ();
18991867 Streamer.emitLabel (SectionStart);
19001868
1901- DenseMap<CIEKey, const MCSymbol *> CIEStarts;
1902-
1903- const MCSymbol *DummyDebugKey = nullptr ;
19041869 bool CanOmitDwarf = MOFI->getOmitDwarfIfHaveCompactUnwind ();
19051870 // Sort the FDEs by their corresponding CIE before we emit them.
19061871 // This isn't technically necessary according to the DWARF standard,
@@ -1911,6 +1876,8 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
19111876 [](const MCDwarfFrameInfo &X, const MCDwarfFrameInfo &Y) {
19121877 return CIEKey (X) < CIEKey (Y);
19131878 });
1879+ CIEKey LastKey;
1880+ const MCSymbol *LastCIEStart = nullptr ;
19141881 for (auto I = FrameArrayX.begin (), E = FrameArrayX.end (); I != E;) {
19151882 const MCDwarfFrameInfo &Frame = *I;
19161883 ++I;
@@ -1925,11 +1892,12 @@ void MCDwarfFrameEmitter::Emit(MCObjectStreamer &Streamer, MCAsmBackend *MAB,
19251892 continue ;
19261893
19271894 CIEKey Key (Frame);
1928- const MCSymbol *&CIEStart = IsEH ? CIEStarts[Key] : DummyDebugKey;
1929- if (!CIEStart)
1930- CIEStart = &Emitter.EmitCIE (Frame);
1895+ if (!LastCIEStart || (IsEH && Key != LastKey)) {
1896+ LastKey = Key;
1897+ LastCIEStart = &Emitter.EmitCIE (Frame);
1898+ }
19311899
1932- Emitter.EmitFDE (*CIEStart , Frame, I == E, *SectionStart);
1900+ Emitter.EmitFDE (*LastCIEStart , Frame, I == E, *SectionStart);
19331901 }
19341902}
19351903
0 commit comments