[llvm] r175316 - If bundle alignment is enabled, do not add data to a fragment with instructions
Derek Schuff
dschuff at google.com
Fri Feb 15 14:50:53 PST 2013
Author: dschuff
Date: Fri Feb 15 16:50:52 2013
New Revision: 175316
URL: http://llvm.org/viewvc/llvm-project?rev=175316&view=rev
Log:
If bundle alignment is enabled, do not add data to a fragment with instructions
With bundle alignment, instructions all get their own MCFragments
(unless they are in a bundle-locked group). For instructions with
fixups, this is an MCDataFragment. Emitting actual data (e.g. for
.long) attempts to re-use MCDataFragments, which we don't want int
this case since it leads to fragments which exceed the bundle size.
So, don't reuse them in this case.
Also adds a test and fixes some formatting.
Modified:
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/test/MC/ARM/AlignedBundling/group-bundle-arm.s
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=175316&r1=175315&r2=175316&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Fri Feb 15 16:50:52 2013
@@ -386,7 +386,9 @@ void MCELFStreamer::EmitInstToData(const
if (Assembler.isBundlingEnabled()) {
MCSectionData *SD = getCurrentSectionData();
if (SD->isBundleLocked() && !SD->isBundleGroupBeforeFirstInst())
- DF = getOrCreateDataFragment();
+ // If we are bundle-locked, we re-use the current fragment.
+ // The bundle-locking directive ensures this is a new data fragment.
+ DF = cast<MCDataFragment>(getCurrentFragment());
else if (!SD->isBundleLocked() && Fixups.size() == 0) {
// Optimize memory usage by emitting the instruction to a
// MCCompactEncodedInstFragment when not in a bundle-locked group and
@@ -394,8 +396,7 @@ void MCELFStreamer::EmitInstToData(const
MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment(SD);
CEIF->getContents().append(Code.begin(), Code.end());
return;
- }
- else {
+ } else {
DF = new MCDataFragment(SD);
if (SD->getBundleLockState() == MCSectionData::BundleLockedAlignToEnd) {
// If this is a new fragment created for a bundle-locked group, and the
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=175316&r1=175315&r2=175316&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Fri Feb 15 16:50:52 2013
@@ -59,7 +59,9 @@ MCFragment *MCObjectStreamer::getCurrent
MCDataFragment *MCObjectStreamer::getOrCreateDataFragment() const {
MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
- if (!F)
+ // When bundling is enabled, we don't want to add data to a fragment that
+ // already has instructions (see MCELFStreamer::EmitInstToData for details)
+ if (!F || (Assembler->isBundlingEnabled() && F->hasInstructions()))
F = new MCDataFragment(getCurrentSectionData());
return F;
}
Modified: llvm/trunk/test/MC/ARM/AlignedBundling/group-bundle-arm.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/AlignedBundling/group-bundle-arm.s?rev=175316&r1=175315&r2=175316&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/AlignedBundling/group-bundle-arm.s (original)
+++ llvm/trunk/test/MC/ARM/AlignedBundling/group-bundle-arm.s Fri Feb 15 16:50:52 2013
@@ -5,8 +5,8 @@
# instructions should not be inserted. However, for bundle-locked groups
# it can be.
- .syntax unified
- .text
+ .syntax unified
+ .text
.bundle_align_mode 4
bx lr
@@ -35,3 +35,14 @@
# CHECK-NEXT: 2c: nop
# CHECK-NEXT: 30: bx
+ .align 4
+foo:
+ b foo
+ .long 3892240112
+ .long 3892240112
+ .long 3892240112
+ .long 3892240112
+ .long 3892240112
+ .long 3892240112
+# CHECK: 40: b
+
More information about the llvm-commits
mailing list