Layout one section until no relaxations are done and then move to the next

section.

This helps because in practice sections form a dag with debug sections pointing
to text sections. Finishing up the text sections first makes the debug section
relaxation trivial.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2010-12-21 04:22:09 +00:00
parent c19aadb8b0
commit 62b83b62f3
2 changed files with 43 additions and 34 deletions

View File

@@ -711,6 +711,8 @@ private:
/// were adjusted.
bool LayoutOnce(MCAsmLayout &Layout);
bool LayoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD);
bool RelaxInstruction(MCAsmLayout &Layout, MCInstFragment &IF);
bool RelaxOrg(MCAsmLayout &Layout, MCOrgFragment &OF);

View File

@@ -707,15 +707,10 @@ bool MCAssembler::RelaxAlignment(MCAsmLayout &Layout,
return OldSize != Size;
}
bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
++stats::RelaxationSteps;
// Scan for fragments that need relaxation.
bool WasRelaxed = false;
for (iterator it = begin(), ie = end(); it != ie; ++it) {
MCSectionData &SD = *it;
bool MCAssembler::LayoutSectionOnce(MCAsmLayout &Layout,
MCSectionData &SD) {
MCFragment *FirstInvalidFragment = NULL;
// Scan for fragments that need relaxation.
for (MCSectionData::iterator it2 = SD.begin(),
ie2 = SD.end(); it2 != ie2; ++it2) {
// Check if this is an fragment that needs relaxation.
@@ -743,10 +738,22 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
// Update the layout, and remember that we relaxed.
if (relaxedFrag && !FirstInvalidFragment)
FirstInvalidFragment = it2;
WasRelaxed |= relaxedFrag;
}
if (FirstInvalidFragment)
if (FirstInvalidFragment) {
Layout.Invalidate(FirstInvalidFragment);
return true;
}
return false;
}
bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
++stats::RelaxationSteps;
bool WasRelaxed = false;
for (iterator it = begin(), ie = end(); it != ie; ++it) {
MCSectionData &SD = *it;
while(LayoutSectionOnce(Layout, SD))
WasRelaxed = true;
}
return WasRelaxed;