@@ -46,59 +46,6 @@ MCAssembler *MCObjectStreamer::getAssemblerPtr() {
46
46
return nullptr ;
47
47
}
48
48
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
-
102
49
// When fixup's offset is a forward declared label, e.g.:
103
50
//
104
51
// .reloc 1f, R_MIPS_JALR, foo
@@ -113,7 +60,6 @@ void MCObjectStreamer::resolvePendingFixups() {
113
60
" unresolved relocation offset" );
114
61
continue ;
115
62
}
116
- flushPendingLabels (PendingFixup.DF , PendingFixup.DF ->getContents ().size ());
117
63
PendingFixup.Fixup .setOffset (PendingFixup.Sym ->getOffset () +
118
64
PendingFixup.Fixup .getOffset ());
119
65
@@ -245,7 +191,6 @@ void MCObjectStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
245
191
SMLoc Loc) {
246
192
MCStreamer::emitValueImpl (Value, Size, Loc);
247
193
MCDataFragment *DF = getOrCreateDataFragment ();
248
- flushPendingLabels (DF, DF->getContents ().size ());
249
194
250
195
MCDwarfLineEntry::make (this , getCurrentSectionOnly ());
251
196
@@ -291,17 +236,9 @@ void MCObjectStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
291
236
// If there is a current fragment, mark the symbol as pointing into it.
292
237
// Otherwise queue the label and set its fragment pointer when we emit the
293
238
// 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 ());
305
242
306
243
emitPendingAssignments (Symbol);
307
244
}
@@ -598,11 +535,9 @@ void MCObjectStreamer::emitCVInlineLinetableDirective(
598
535
void MCObjectStreamer::emitCVDefRangeDirective (
599
536
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
600
537
StringRef FixedSizePortion) {
601
- MCFragment *Frag =
602
- getContext ().getCVContext ().emitDefRange (*this , Ranges, FixedSizePortion);
538
+ getContext ().getCVContext ().emitDefRange (*this , Ranges, FixedSizePortion);
603
539
// Attach labels that were pending before we created the defrange fragment to
604
540
// the beginning of the new fragment.
605
- flushPendingLabels (Frag, 0 );
606
541
this ->MCStreamer ::emitCVDefRangeDirective (Ranges, FixedSizePortion);
607
542
}
608
543
@@ -620,7 +555,6 @@ void MCObjectStreamer::emitCVFileChecksumOffsetDirective(unsigned FileNo) {
620
555
void MCObjectStreamer::emitBytes (StringRef Data) {
621
556
MCDwarfLineEntry::make (this , getCurrentSectionOnly ());
622
557
MCDataFragment *DF = getOrCreateDataFragment ();
623
- flushPendingLabels (DF, DF->getContents ().size ());
624
558
DF->getContents ().append (Data.begin (), Data.end ());
625
559
}
626
560
@@ -653,8 +587,6 @@ void MCObjectStreamer::emitValueToOffset(const MCExpr *Offset,
653
587
// Associate DTPRel32 fixup with data and resize data area
654
588
void MCObjectStreamer::emitDTPRel32Value (const MCExpr *Value) {
655
589
MCDataFragment *DF = getOrCreateDataFragment ();
656
- flushPendingLabels (DF, DF->getContents ().size ());
657
-
658
590
DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
659
591
Value, FK_DTPRel_4));
660
592
DF->getContents ().resize (DF->getContents ().size () + 4 , 0 );
@@ -663,8 +595,6 @@ void MCObjectStreamer::emitDTPRel32Value(const MCExpr *Value) {
663
595
// Associate DTPRel64 fixup with data and resize data area
664
596
void MCObjectStreamer::emitDTPRel64Value (const MCExpr *Value) {
665
597
MCDataFragment *DF = getOrCreateDataFragment ();
666
- flushPendingLabels (DF, DF->getContents ().size ());
667
-
668
598
DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
669
599
Value, FK_DTPRel_8));
670
600
DF->getContents ().resize (DF->getContents ().size () + 8 , 0 );
@@ -673,8 +603,6 @@ void MCObjectStreamer::emitDTPRel64Value(const MCExpr *Value) {
673
603
// Associate TPRel32 fixup with data and resize data area
674
604
void MCObjectStreamer::emitTPRel32Value (const MCExpr *Value) {
675
605
MCDataFragment *DF = getOrCreateDataFragment ();
676
- flushPendingLabels (DF, DF->getContents ().size ());
677
-
678
606
DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
679
607
Value, FK_TPRel_4));
680
608
DF->getContents ().resize (DF->getContents ().size () + 4 , 0 );
@@ -683,8 +611,6 @@ void MCObjectStreamer::emitTPRel32Value(const MCExpr *Value) {
683
611
// Associate TPRel64 fixup with data and resize data area
684
612
void MCObjectStreamer::emitTPRel64Value (const MCExpr *Value) {
685
613
MCDataFragment *DF = getOrCreateDataFragment ();
686
- flushPendingLabels (DF, DF->getContents ().size ());
687
-
688
614
DF->getFixups ().push_back (MCFixup::create (DF->getContents ().size (),
689
615
Value, FK_TPRel_8));
690
616
DF->getContents ().resize (DF->getContents ().size () + 8 , 0 );
@@ -693,8 +619,6 @@ void MCObjectStreamer::emitTPRel64Value(const MCExpr *Value) {
693
619
// Associate GPRel32 fixup with data and resize data area
694
620
void MCObjectStreamer::emitGPRel32Value (const MCExpr *Value) {
695
621
MCDataFragment *DF = getOrCreateDataFragment ();
696
- flushPendingLabels (DF, DF->getContents ().size ());
697
-
698
622
DF->getFixups ().push_back (
699
623
MCFixup::create (DF->getContents ().size (), Value, FK_GPRel_4));
700
624
DF->getContents ().resize (DF->getContents ().size () + 4 , 0 );
@@ -703,8 +627,6 @@ void MCObjectStreamer::emitGPRel32Value(const MCExpr *Value) {
703
627
// Associate GPRel64 fixup with data and resize data area
704
628
void MCObjectStreamer::emitGPRel64Value (const MCExpr *Value) {
705
629
MCDataFragment *DF = getOrCreateDataFragment ();
706
- flushPendingLabels (DF, DF->getContents ().size ());
707
-
708
630
DF->getFixups ().push_back (
709
631
MCFixup::create (DF->getContents ().size (), Value, FK_GPRel_4));
710
632
DF->getContents ().resize (DF->getContents ().size () + 8 , 0 );
@@ -789,8 +711,6 @@ MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
789
711
MCSymbolRefExpr::create (getContext ().createTempSymbol (), getContext ());
790
712
791
713
MCDataFragment *DF = getOrCreateDataFragment (&STI);
792
- flushPendingLabels (DF, DF->getContents ().size ());
793
-
794
714
MCValue OffsetVal;
795
715
if (!Offset.evaluateAsRelocatable (OffsetVal, nullptr , nullptr ))
796
716
return std::make_pair (false ,
@@ -830,9 +750,6 @@ MCObjectStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
830
750
831
751
void MCObjectStreamer::emitFill (const MCExpr &NumBytes, uint64_t FillValue,
832
752
SMLoc Loc) {
833
- MCDataFragment *DF = getOrCreateDataFragment ();
834
- flushPendingLabels (DF, DF->getContents ().size ());
835
-
836
753
assert (getCurrentSectionOnly () && " need a section" );
837
754
insert (
838
755
getContext ().allocFragment <MCFillFragment>(FillValue, 1 , NumBytes, Loc));
@@ -861,22 +778,14 @@ void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
861
778
}
862
779
863
780
// Otherwise emit as fragment.
864
- MCDataFragment *DF = getOrCreateDataFragment ();
865
- flushPendingLabels (DF, DF->getContents ().size ());
866
-
867
781
assert (getCurrentSectionOnly () && " need a section" );
868
782
insert (
869
783
getContext ().allocFragment <MCFillFragment>(Expr, Size, NumValues, Loc));
870
784
}
871
785
872
786
void MCObjectStreamer::emitNops (int64_t NumBytes, int64_t ControlledNopLength,
873
787
SMLoc Loc, const MCSubtargetInfo &STI) {
874
- // Emit an NOP fragment.
875
- MCDataFragment *DF = getOrCreateDataFragment ();
876
- flushPendingLabels (DF, DF->getContents ().size ());
877
-
878
788
assert (getCurrentSectionOnly () && " need a section" );
879
-
880
789
insert (getContext ().allocFragment <MCNopsFragment>(
881
790
NumBytes, ControlledNopLength, Loc, STI));
882
791
}
@@ -916,9 +825,6 @@ void MCObjectStreamer::finishImpl() {
916
825
// Emit pseudo probes for the current module.
917
826
MCPseudoProbeTable::emit (this );
918
827
919
- // Update any remaining pending labels with empty data fragments.
920
- flushPendingLabels ();
921
-
922
828
resolvePendingFixups ();
923
829
getAssembler ().Finish ();
924
830
}
0 commit comments