diff options
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index c4c8e6e4e7d..8ddbfbbe8a4 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -386,7 +386,9 @@ void MCELFStreamer::EmitInstToData(const MCInst &Inst) { 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 MCInst &Inst) { 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 diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index fe435061eb4..b6c7341469d 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -59,7 +59,9 @@ MCFragment *MCObjectStreamer::getCurrentFragment() const { 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; } |