@@ -46,59 +46,6 @@ MCAssembler *MCObjectStreamer::getAssemblerPtr() {
4646 return nullptr ;
4747}
4848
49- void MCObjectStreamer::addPendingLabel (MCSymbol* S) {
50- MCSection *CurSection = getCurrentSectionOnly ();
51- if (CurSection) {
52- // Register labels that have not yet been assigned to a Section.
53- if (!PendingLabels.empty ()) {
54- for (MCSymbol* Sym : PendingLabels)
55- CurSection->addPendingLabel (Sym);
56- PendingLabels.clear ();
57- }
58-
59- // Add this label to the current Section / Subsection.
60- CurSection->addPendingLabel (S, CurSubsectionIdx);
61-
62- // Add this Section to the list of PendingLabelSections.
63- PendingLabelSections.insert (CurSection);
64- } else
65- // There is no Section / Subsection for this label yet.
66- PendingLabels.push_back (S);
67- }
68-
69- void MCObjectStreamer::flushPendingLabels (MCFragment *F, uint64_t FOffset) {
70- assert (F);
71- MCSection *CurSection = getCurrentSectionOnly ();
72- if (!CurSection) {
73- assert (PendingLabels.empty ());
74- return ;
75- }
76- // Register labels that have not yet been assigned to a Section.
77- if (!PendingLabels.empty ()) {
78- for (MCSymbol* Sym : PendingLabels)
79- CurSection->addPendingLabel (Sym, CurSubsectionIdx);
80- PendingLabels.clear ();
81- }
82-
83- // Associate the labels with F.
84- CurSection->flushPendingLabels (F, CurSubsectionIdx);
85- }
86-
87- void MCObjectStreamer::flushPendingLabels () {
88- // Register labels that have not yet been assigned to a Section.
89- if (!PendingLabels.empty ()) {
90- MCSection *CurSection = getCurrentSectionOnly ();
91- assert (CurSection);
92- for (MCSymbol* Sym : PendingLabels)
93- CurSection->addPendingLabel (Sym, CurSubsectionIdx);
94- PendingLabels.clear ();
95- }
96-
97- // Assign an empty data fragment to all remaining pending labels.
98- for (MCSection* Section : PendingLabelSections)
99- Section->flushPendingLabels ();
100- }
101-
10249// When fixup's offset is a forward declared label, e.g.:
10350//
10451// .reloc 1f, R_MIPS_JALR, foo
@@ -113,7 +60,6 @@ void MCObjectStreamer::resolvePendingFixups() {
11360 " unresolved relocation offset" );
11461 continue ;
11562 }
116- flushPendingLabels (PendingFixup.DF , PendingFixup.DF ->getContents ().size ());
11763 PendingFixup.Fixup .setOffset (PendingFixup.Sym ->getOffset () +
11864 PendingFixup.Fixup .getOffset ());
11965
@@ -245,7 +191,6 @@ void MCObjectStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
245191 SMLoc Loc) {
246192 MCStreamer::emitValueImpl (Value, Size, Loc);
247193 MCDataFragment *DF = getOrCreateDataFragment ();
248- flushPendingLabels (DF, DF->getContents ().size ());
249194
250195 MCDwarfLineEntry::make (this , getCurrentSectionOnly ());
251196
@@ -291,17 +236,9 @@ void MCObjectStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
291236 // If there is a current fragment, mark the symbol as pointing into it.
292237 // Otherwise queue the label and set its fragment pointer when we emit the
293238 // next fragment.
294- auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment ());
295- if (F) {
296- Symbol->setFragment (F);
297- Symbol->setOffset (F->getContents ().size ());
298- } else {
299- // Assign all pending labels to offset 0 within the dummy "pending"
300- // fragment. (They will all be reassigned to a real fragment in
301- // flushPendingLabels())
302- Symbol->setOffset (0 );
303- addPendingLabel (Symbol);
304- }
239+ MCDataFragment *F = getOrCreateDataFragment ();
240+ Symbol->setFragment (F);
241+ Symbol->setOffset (F->getContents ().size ());
305242
306243 emitPendingAssignments (Symbol);
307244}
@@ -598,11 +535,9 @@ void MCObjectStreamer::emitCVInlineLinetableDirective(
598535void MCObjectStreamer::emitCVDefRangeDirective (
599536 ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
600537 StringRef FixedSizePortion) {
601- MCFragment *Frag =
602- getContext ().getCVContext ().emitDefRange (*this , Ranges, FixedSizePortion);
538+ getContext ().getCVContext ().emitDefRange (*this , Ranges, FixedSizePortion);
603539 // Attach labels that were pending before we created the defrange fragment to
604540 // the beginning of the new fragment.
605- flushPendingLabels (Frag, 0 );
606541 this ->MCStreamer ::emitCVDefRangeDirective (Ranges, FixedSizePortion);
607542}
608543
@@ -620,7 +555,6 @@ void MCObjectStreamer::emitCVFileChecksumOffsetDirective(unsigned FileNo) {
620555void MCObjectStreamer::emitBytes (StringRef Data) {
621556 MCDwarfLineEntry::make (this , getCurrentSectionOnly ());
622557 MCDataFragment *DF = getOrCreateDataFragment ();
623- flushPendingLabels (DF, DF->getContents ().size ());
624558 DF->getContents ().append (Data.begin (), Data.end ());
625559}
626560
@@ -653,8 +587,6 @@ void MCObjectStreamer::emitValueToOffset(const MCExpr *Offset,
653587// Associate DTPRel32 fixup with data and resize data area
654588void MCObjectStreamer::emitDTPRel32Value (const MCExpr *Value) {
655589 MCDataFragment *DF = getOrCreateDataFragment ();
656- flushPendingLabels (DF, DF->getContents ().size ());
657-
658590 DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
659591 Value, FK_DTPRel_4));
660592 DF->getContents ().resize (DF->getContents ().size () + 4 , 0 );
@@ -663,8 +595,6 @@ void MCObjectStreamer::emitDTPRel32Value(const MCExpr *Value) {
663595// Associate DTPRel64 fixup with data and resize data area
664596void MCObjectStreamer::emitDTPRel64Value (const MCExpr *Value) {
665597 MCDataFragment *DF = getOrCreateDataFragment ();
666- flushPendingLabels (DF, DF->getContents ().size ());
667-
668598 DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
669599 Value, FK_DTPRel_8));
670600 DF->getContents ().resize (DF->getContents ().size () + 8 , 0 );
@@ -673,8 +603,6 @@ void MCObjectStreamer::emitDTPRel64Value(const MCExpr *Value) {
673603// Associate TPRel32 fixup with data and resize data area
674604void MCObjectStreamer::emitTPRel32Value (const MCExpr *Value) {
675605 MCDataFragment *DF = getOrCreateDataFragment ();
676- flushPendingLabels (DF, DF->getContents ().size ());
677-
678606 DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
679607 Value, FK_TPRel_4));
680608 DF->getContents ().resize (DF->getContents ().size () + 4 , 0 );
@@ -683,8 +611,6 @@ void MCObjectStreamer::emitTPRel32Value(const MCExpr *Value) {
683611// Associate TPRel64 fixup with data and resize data area
684612void MCObjectStreamer::emitTPRel64Value (const MCExpr *Value) {
685613 MCDataFragment *DF = getOrCreateDataFragment ();
686- flushPendingLabels (DF, DF->getContents ().size ());
687-
688614 DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
689615 Value, FK_TPRel_8));
690616 DF->getContents ().resize (DF->getContents ().size () + 8 , 0 );
@@ -693,8 +619,6 @@ void MCObjectStreamer::emitTPRel64Value(const MCExpr *Value) {
693619// Associate GPRel32 fixup with data and resize data area
694620void MCObjectStreamer::emitGPRel32Value (const MCExpr *Value) {
695621 MCDataFragment *DF = getOrCreateDataFragment ();
696- flushPendingLabels (DF, DF->getContents ().size ());
697-
698622 DF->getFixups ().push_back (
699623 MCFixup::create (DF->getContents ().size (), Value, FK_GPRel_4));
700624 DF->getContents ().resize (DF->getContents ().size () + 4 , 0 );
@@ -703,8 +627,6 @@ void MCObjectStreamer::emitGPRel32Value(const MCExpr *Value) {
703627// Associate GPRel64 fixup with data and resize data area
704628void MCObjectStreamer::emitGPRel64Value (const MCExpr *Value) {
705629 MCDataFragment *DF = getOrCreateDataFragment ();
706- flushPendingLabels (DF, DF->getContents ().size ());
707-
708630 DF->getFixups ().push_back (
709631 MCFixup::create (DF->getContents ().size (), Value, FK_GPRel_4));
710632 DF->getContents ().resize (DF->getContents ().size () + 8 , 0 );
@@ -789,8 +711,6 @@ MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
789711 MCSymbolRefExpr::create (getContext ().createTempSymbol (), getContext ());
790712
791713 MCDataFragment *DF = getOrCreateDataFragment (&STI);
792- flushPendingLabels (DF, DF->getContents ().size ());
793-
794714 MCValue OffsetVal;
795715 if (!Offset.evaluateAsRelocatable (OffsetVal, nullptr , nullptr ))
796716 return std::make_pair (false ,
@@ -830,9 +750,6 @@ MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
830750
831751void MCObjectStreamer::emitFill (const MCExpr &NumBytes, uint64_t FillValue,
832752 SMLoc Loc) {
833- MCDataFragment *DF = getOrCreateDataFragment ();
834- flushPendingLabels (DF, DF->getContents ().size ());
835-
836753 assert (getCurrentSectionOnly () && " need a section" );
837754 insert (
838755 getContext ().allocFragment <MCFillFragment>(FillValue, 1 , NumBytes, Loc));
@@ -861,22 +778,14 @@ void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
861778 }
862779
863780 // Otherwise emit as fragment.
864- MCDataFragment *DF = getOrCreateDataFragment ();
865- flushPendingLabels (DF, DF->getContents ().size ());
866-
867781 assert (getCurrentSectionOnly () && " need a section" );
868782 insert (
869783 getContext ().allocFragment <MCFillFragment>(Expr, Size, NumValues, Loc));
870784}
871785
872786void MCObjectStreamer::emitNops (int64_t NumBytes, int64_t ControlledNopLength,
873787 SMLoc Loc, const MCSubtargetInfo &STI) {
874- // Emit an NOP fragment.
875- MCDataFragment *DF = getOrCreateDataFragment ();
876- flushPendingLabels (DF, DF->getContents ().size ());
877-
878788 assert (getCurrentSectionOnly () && " need a section" );
879-
880789 insert (getContext ().allocFragment <MCNopsFragment>(
881790 NumBytes, ControlledNopLength, Loc, STI));
882791}
@@ -916,9 +825,6 @@ void MCObjectStreamer::finishImpl() {
916825 // Emit pseudo probes for the current module.
917826 MCPseudoProbeTable::emit (this );
918827
919- // Update any remaining pending labels with empty data fragments.
920- flushPendingLabels ();
921-
922828 resolvePendingFixups ();
923829 getAssembler ().Finish ();
924830}
0 commit comments