@@ -50,44 +50,6 @@ bool MCELFStreamer::isBundleLocked() const {
5050 return getCurrentSectionOnly ()->isBundleLocked ();
5151}
5252
53- void MCELFStreamer::mergeFragment (MCDataFragment *DF,
54- MCDataFragment *EF) {
55- MCAssembler &Assembler = getAssembler ();
56-
57- if (Assembler.isBundlingEnabled () && Assembler.getRelaxAll ()) {
58- uint64_t FSize = EF->getContents ().size ();
59-
60- if (FSize > Assembler.getBundleAlignSize ())
61- report_fatal_error (" Fragment can't be larger than a bundle size" );
62-
63- uint64_t RequiredBundlePadding = computeBundlePadding (
64- Assembler, EF, DF->getContents ().size (), FSize);
65-
66- if (RequiredBundlePadding > UINT8_MAX)
67- report_fatal_error (" Padding cannot exceed 255 bytes" );
68-
69- if (RequiredBundlePadding > 0 ) {
70- SmallString<256 > Code;
71- raw_svector_ostream VecOS (Code);
72- EF->setBundlePadding (static_cast <uint8_t >(RequiredBundlePadding));
73- Assembler.writeFragmentPadding (VecOS, *EF, FSize);
74-
75- DF->getContents ().append (Code.begin (), Code.end ());
76- }
77- }
78-
79- flushPendingLabels (DF, DF->getContents ().size ());
80-
81- for (unsigned i = 0 , e = EF->getFixups ().size (); i != e; ++i) {
82- EF->getFixups ()[i].setOffset (EF->getFixups ()[i].getOffset () +
83- DF->getContents ().size ());
84- DF->getFixups ().push_back (EF->getFixups ()[i]);
85- }
86- if (DF->getSubtargetInfo () == nullptr && EF->getSubtargetInfo ())
87- DF->setHasInstructions (*EF->getSubtargetInfo ());
88- DF->getContents ().append (EF->getContents ().begin (), EF->getContents ().end ());
89- }
90-
9153void MCELFStreamer::initSections (bool NoExecStack, const MCSubtargetInfo &STI) {
9254 MCContext &Ctx = getContext ();
9355 switchSection (Ctx.getObjectFileInfo ()->getTextSection ());
@@ -575,24 +537,12 @@ void MCELFStreamer::emitInstToData(const MCInst &Inst,
575537
576538 if (Assembler.isBundlingEnabled ()) {
577539 MCSection &Sec = *getCurrentSectionOnly ();
578- if (Assembler.getRelaxAll () && isBundleLocked ()) {
579- // If the -mc-relax-all flag is used and we are bundle-locked, we re-use
580- // the current bundle group.
581- DF = BundleGroups.back ();
582- CheckBundleSubtargets (DF->getSubtargetInfo (), &STI);
583- }
584- else if (Assembler.getRelaxAll () && !isBundleLocked ())
585- // When not in a bundle-locked group and the -mc-relax-all flag is used,
586- // we create a new temporary fragment which will be later merged into
587- // the current fragment.
588- DF = getContext ().allocFragment <MCDataFragment>();
589- else if (isBundleLocked () && !Sec.isBundleGroupBeforeFirstInst ()) {
540+ if (isBundleLocked () && !Sec.isBundleGroupBeforeFirstInst ()) {
590541 // If we are bundle-locked, we re-use the current fragment.
591542 // The bundle-locking directive ensures this is a new data fragment.
592543 DF = cast<MCDataFragment>(getCurrentFragment ());
593544 CheckBundleSubtargets (DF->getSubtargetInfo (), &STI);
594- }
595- else if (!isBundleLocked () && Fixups.size () == 0 ) {
545+ } else if (!isBundleLocked () && Fixups.size () == 0 ) {
596546 // Optimize memory usage by emitting the instruction to a
597547 // MCCompactEncodedInstFragment when not in a bundle-locked group and
598548 // there are no fixups registered.
@@ -632,13 +582,6 @@ void MCELFStreamer::emitInstToData(const MCInst &Inst,
632582 getAssembler ().getBackend ().RelaxFixupKind )
633583 DF->setLinkerRelaxable ();
634584 DF->getContents ().append (Code.begin (), Code.end ());
635-
636- if (Assembler.isBundlingEnabled () && Assembler.getRelaxAll ()) {
637- if (!isBundleLocked ()) {
638- mergeFragment (getOrCreateDataFragment (&STI), DF);
639- delete DF;
640- }
641- }
642585}
643586
644587void MCELFStreamer::emitBundleAlignMode (Align Alignment) {
@@ -660,12 +603,6 @@ void MCELFStreamer::emitBundleLock(bool AlignToEnd) {
660603 if (!isBundleLocked ())
661604 Sec.setBundleGroupBeforeFirstInst (true );
662605
663- if (getAssembler ().getRelaxAll () && !isBundleLocked ()) {
664- // TODO: drop the lock state and set directly in the fragment
665- MCDataFragment *DF = getContext ().allocFragment <MCDataFragment>();
666- BundleGroups.push_back (DF);
667- }
668-
669606 Sec.setBundleLockState (AlignToEnd ? MCSection::BundleLockedAlignToEnd
670607 : MCSection::BundleLocked);
671608}
@@ -680,27 +617,7 @@ void MCELFStreamer::emitBundleUnlock() {
680617 else if (Sec.isBundleGroupBeforeFirstInst ())
681618 report_fatal_error (" Empty bundle-locked group is forbidden" );
682619
683- // When the -mc-relax-all flag is used, we emit instructions to fragments
684- // stored on a stack. When the bundle unlock is emitted, we pop a fragment
685- // from the stack a merge it to the one below.
686- if (getAssembler ().getRelaxAll ()) {
687- assert (!BundleGroups.empty () && " There are no bundle groups" );
688- MCDataFragment *DF = BundleGroups.back ();
689-
690- // FIXME: Use BundleGroups to track the lock state instead.
691- Sec.setBundleLockState (MCSection::NotBundleLocked);
692-
693- // FIXME: Use more separate fragments for nested groups.
694- if (!isBundleLocked ()) {
695- mergeFragment (getOrCreateDataFragment (DF->getSubtargetInfo ()), DF);
696- BundleGroups.pop_back ();
697- delete DF;
698- }
699-
700- if (Sec.getBundleLockState () != MCSection::BundleLockedAlignToEnd)
701- getOrCreateDataFragment ()->setAlignToBundleEnd (false );
702- } else
703- Sec.setBundleLockState (MCSection::NotBundleLocked);
620+ Sec.setBundleLockState (MCSection::NotBundleLocked);
704621}
705622
706623void MCELFStreamer::finishImpl () {
0 commit comments