aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Sehr <sehr@google.com>2012-08-13 14:29:26 -0700
committerDerek Schuff <dschuff@chromium.org>2012-08-13 14:29:26 -0700
commit35142769ccfaddc7e16bbc4314bb3d5530b005d0 (patch)
treee9a639c907ad68022a5f83d6cefb50dda0ff0719 /lib
parent07b0dd66a2bef968a26351303ab8643f31fd6b77 (diff)
Instructions that appear between BundleLock and BundleUnlock are part of one
contiguous region of bytes, and should not be individually aligned. This CL adds instructions within such a region to the same MCTinyFragment to improve memory usage for NaCl pseudo-instructions. I also added dumping of the NaCl specific attributes on MCFragments to make further analysis easier. BUG= http://code.google.com/p/nativeclient/issues/detail?id=2545 TEST=none Review URL: http://codereview.chromium.org/10832175/
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/MCAssembler.cpp13
-rw-r--r--lib/MC/MCELFStreamer.cpp9
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index a914e12cdc..321b2832b9 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -1052,7 +1052,18 @@ void MCFragment::dump() {
}
OS << "<MCFragment " << (void*) this << " LayoutOrder:" << LayoutOrder
- << " Offset:" << Offset << ">";
+ << " Offset:" << Offset;
+ // @LOCALMOD-BEGIN
+ if (BundleGroupStart)
+ OS << " BundleGroupStart";
+ if (BundleGroupEnd)
+ OS << " BundleGroupEnd";
+ if (BundleAlign == BundleAlignStart)
+ OS << " BundleAlign: Start";
+ else if (BundleAlign == BundleAlignEnd)
+ OS << " BundleAlign: End";
+ OS << ">";
+ // @LOCALMOD-END
switch (getKind()) {
case MCFragment::FT_Align: {
diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp
index 39cc4eb415..c569a4b3f4 100644
--- a/lib/MC/MCELFStreamer.cpp
+++ b/lib/MC/MCELFStreamer.cpp
@@ -487,7 +487,14 @@ void MCELFStreamer::EmitInstToData(const MCInst &Inst) {
}
DF->getContents().append(Code.begin(), Code.end());
} else {
- MCTinyFragment *TF = new MCTinyFragment(getCurrentSectionData());
+ MCTinyFragment *TF = dyn_cast_or_null<MCTinyFragment>(getCurrentFragment());
+ // A bundle group is a contiguous group of bytes aligned as a unit. We
+ // always try to append to the current bundle group, if there is one, to
+ // reduce the number of fragments created.
+ if (!TF || !TF->isBundleGroupStart() || TF->isBundleGroupEnd()) {
+ // We need to start a new bundle group.
+ TF = new MCTinyFragment(getCurrentSectionData());
+ }
TF->getContents().append(Code.begin(), Code.end());
}
// @LOCALMOD-END