[llvm-commits] [llvm] r122314 - in /llvm/trunk: include/llvm/MC/MCAssembler.h lib/MC/MCAssembler.cpp
Rafael Espindola
rafael.espindola at gmail.com
Mon Dec 20 20:22:09 PST 2010
Author: rafael
Date: Mon Dec 20 22:22:09 2010
New Revision: 122314
URL: http://llvm.org/viewvc/llvm-project?rev=122314&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCAssembler.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=122314&r1=122313&r2=122314&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Mon Dec 20 22:22:09 2010
@@ -711,6 +711,8 @@
/// were adjusted.
bool LayoutOnce(MCAsmLayout &Layout);
+ bool LayoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD);
+
bool RelaxInstruction(MCAsmLayout &Layout, MCInstFragment &IF);
bool RelaxOrg(MCAsmLayout &Layout, MCOrgFragment &OF);
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=122314&r1=122313&r2=122314&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Mon Dec 20 22:22:09 2010
@@ -707,46 +707,53 @@
return OldSize != Size;
}
+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.
+ bool relaxedFrag = false;
+ switch(it2->getKind()) {
+ default:
+ break;
+ case MCFragment::FT_Align:
+ relaxedFrag = RelaxAlignment(Layout, *cast<MCAlignFragment>(it2));
+ break;
+ case MCFragment::FT_Inst:
+ relaxedFrag = RelaxInstruction(Layout, *cast<MCInstFragment>(it2));
+ break;
+ case MCFragment::FT_Org:
+ relaxedFrag = RelaxOrg(Layout, *cast<MCOrgFragment>(it2));
+ break;
+ case MCFragment::FT_Dwarf:
+ relaxedFrag = RelaxDwarfLineAddr(Layout,
+ *cast<MCDwarfLineAddrFragment>(it2));
+ break;
+ case MCFragment::FT_LEB:
+ relaxedFrag = RelaxLEB(Layout, *cast<MCLEBFragment>(it2));
+ break;
+ }
+ // Update the layout, and remember that we relaxed.
+ if (relaxedFrag && !FirstInvalidFragment)
+ FirstInvalidFragment = it2;
+ }
+ if (FirstInvalidFragment) {
+ Layout.Invalidate(FirstInvalidFragment);
+ return true;
+ }
+ return false;
+}
+
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;
- MCFragment *FirstInvalidFragment = NULL;
-
- for (MCSectionData::iterator it2 = SD.begin(),
- ie2 = SD.end(); it2 != ie2; ++it2) {
- // Check if this is an fragment that needs relaxation.
- bool relaxedFrag = false;
- switch(it2->getKind()) {
- default:
- break;
- case MCFragment::FT_Align:
- relaxedFrag = RelaxAlignment(Layout, *cast<MCAlignFragment>(it2));
- break;
- case MCFragment::FT_Inst:
- relaxedFrag = RelaxInstruction(Layout, *cast<MCInstFragment>(it2));
- break;
- case MCFragment::FT_Org:
- relaxedFrag = RelaxOrg(Layout, *cast<MCOrgFragment>(it2));
- break;
- case MCFragment::FT_Dwarf:
- relaxedFrag = RelaxDwarfLineAddr(Layout,
- *cast<MCDwarfLineAddrFragment>(it2));
- break;
- case MCFragment::FT_LEB:
- relaxedFrag = RelaxLEB(Layout, *cast<MCLEBFragment>(it2));
- break;
- }
- // Update the layout, and remember that we relaxed.
- if (relaxedFrag && !FirstInvalidFragment)
- FirstInvalidFragment = it2;
- WasRelaxed |= relaxedFrag;
- }
- if (FirstInvalidFragment)
- Layout.Invalidate(FirstInvalidFragment);
+ while(LayoutSectionOnce(Layout, SD))
+ WasRelaxed = true;
}
return WasRelaxed;
More information about the llvm-commits
mailing list