aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MC
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-07 15:03:27 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-07 15:03:27 +0000
commite25e1ef48b029795fd03be13791e5d19834bd503 (patch)
tree1400cfe8807ba5ee311b14852b540f84bb82c15b /lib/MC
parent6bc6cd223c79ed30e13363772ecc0a3e220f853b (diff)
downloadexternal_llvm-e25e1ef48b029795fd03be13791e5d19834bd503.zip
external_llvm-e25e1ef48b029795fd03be13791e5d19834bd503.tar.gz
external_llvm-e25e1ef48b029795fd03be13791e5d19834bd503.tar.bz2
Speed up AddSectionToTheEnd. It was walking all fragments in all sections.
This is really slow with we have 1000s of sections each with a corresponding relocation section. Also, it is only used by the ELF writer to add basic data, so there is no need to force a new layout pass. Should fix PR8563. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118377 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r--lib/MC/MCAssembler.cpp23
1 files changed, 4 insertions, 19 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 9dc67644..8e87d5b 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -590,24 +590,14 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD,
void MCAssembler::AddSectionToTheEnd(const MCObjectWriter &Writer,
MCSectionData &SD, MCAsmLayout &Layout) {
// Create dummy fragments and assign section ordinals.
- unsigned SectionIndex = 0;
- for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it)
- SectionIndex++;
-
+ unsigned SectionIndex = size();
SD.setOrdinal(SectionIndex);
// Assign layout order indices to sections and fragments.
- unsigned FragmentIndex = 0;
- unsigned i = 0;
- for (unsigned e = Layout.getSectionOrder().size(); i != e; ++i) {
- MCSectionData *SD = Layout.getSectionOrder()[i];
-
- for (MCSectionData::iterator it2 = SD->begin(),
- ie2 = SD->end(); it2 != ie2; ++it2)
- FragmentIndex++;
- }
+ const MCFragment &Last = *Layout.getSectionOrder().back()->rbegin();
+ unsigned FragmentIndex = Last.getLayoutOrder() + 1;
- SD.setLayoutOrder(i);
+ SD.setLayoutOrder(Layout.getSectionOrder().size());
for (MCSectionData::iterator it2 = SD.begin(),
ie2 = SD.end(); it2 != ie2; ++it2) {
it2->setLayoutOrder(FragmentIndex++);
@@ -615,11 +605,6 @@ void MCAssembler::AddSectionToTheEnd(const MCObjectWriter &Writer,
Layout.getSectionOrder().push_back(&SD);
Layout.LayoutSection(&SD);
-
- // Layout until everything fits.
- while (LayoutOnce(Writer, Layout))
- continue;
-
}
void MCAssembler::Finish(MCObjectWriter *Writer) {