File tree Expand file tree Collapse file tree 6 files changed +26
-25
lines changed Expand file tree Collapse file tree 6 files changed +26
-25
lines changed Original file line number Diff line number Diff line change @@ -73,20 +73,9 @@ class MCObjectStreamer : public MCStreamer {
7373 MCSymbol *emitCFILabel () override ;
7474 void emitCFISections (bool EH, bool Debug) override ;
7575
76- void insert (MCFragment *F) {
77- auto *Sec = CurFrag->getParent ();
78- F->setParent (Sec);
79- F->setLayoutOrder (CurFrag->getLayoutOrder () + 1 );
80- CurFrag->Next = F;
81- CurFrag = F;
82- Sec->curFragList ()->Tail = F;
83- }
84-
8576 // / Get a data fragment to write into, creating a new one if the current
8677 // / fragment is not FT_Data.
87- // / Optionally a \p STI can be passed in so that a new fragment is created
88- // / if the Subtarget differs from the current fragment.
89- MCFragment *getOrCreateDataFragment (const MCSubtargetInfo *STI = nullptr );
78+ MCFragment *getOrCreateDataFragment ();
9079
9180protected:
9281 bool changeSectionImpl (MCSection *Section, uint32_t Subsection);
Original file line number Diff line number Diff line change @@ -188,6 +188,7 @@ class LLVM_ABI MCSection {
188188// destructors.
189189class MCFragment {
190190 friend class MCAssembler ;
191+ friend class MCStreamer ;
191192 friend class MCObjectStreamer ;
192193 friend class MCSection ;
193194
Original file line number Diff line number Diff line change @@ -429,7 +429,6 @@ class LLVM_ABI MCStreamer {
429429 CurFrag->getParent () == getCurrentSection ().first );
430430 return CurFrag;
431431 }
432-
433432 // / Save the current and previous section on the section stack.
434433 void pushSection () {
435434 SectionStack.push_back (
@@ -457,6 +456,9 @@ class LLVM_ABI MCStreamer {
457456
458457 MCSymbol *endSection (MCSection *Section);
459458
459+ void insert (MCFragment *F);
460+ void newFragment ();
461+
460462 // / Returns the mnemonic for \p MI, if the streamer has access to a
461463 // / instruction printer and returns an empty string otherwise.
462464 virtual StringRef getMnemonic (const MCInst &MI) const { return " " ; }
Original file line number Diff line number Diff line change @@ -106,26 +106,18 @@ void MCObjectStreamer::emitFrames(MCAsmBackend *MAB) {
106106 MCDwarfFrameEmitter::Emit (*this , MAB, false );
107107}
108108
109- static bool canReuseDataFragment (const MCFragment &F,
110- const MCAssembler &Assembler,
111- const MCSubtargetInfo *STI) {
109+ static bool canReuseDataFragment (const MCFragment &F) {
112110 if (!F.hasInstructions ())
113111 return true ;
114112 // Do not add data after a linker-relaxable instruction. The difference
115113 // between a new label and a label at or before the linker-relaxable
116114 // instruction cannot be resolved at assemble-time.
117- if (F.isLinkerRelaxable ())
118- return false ;
119- // If the subtarget is changed mid fragment we start a new fragment to record
120- // the new STI.
121- return !STI || F.getSubtargetInfo () == STI;
115+ return !F.isLinkerRelaxable ();
122116}
123117
124- MCFragment *
125- MCObjectStreamer::getOrCreateDataFragment (const MCSubtargetInfo *STI) {
118+ MCFragment *MCObjectStreamer::getOrCreateDataFragment () {
126119 auto *F = getCurrentFragment ();
127- if (F->getKind () != MCFragment::FT_Data ||
128- !canReuseDataFragment (*F, *Assembler, STI)) {
120+ if (F->getKind () != MCFragment::FT_Data || !canReuseDataFragment (*F)) {
129121 F = getContext ().allocFragment <MCFragment>();
130122 insert (F);
131123 }
Original file line number Diff line number Diff line change 99#include " llvm/MC/MCParser/MCTargetAsmParser.h"
1010#include " llvm/MC/MCContext.h"
1111#include " llvm/MC/MCRegister.h"
12+ #include " llvm/MC/MCStreamer.h"
1213
1314using namespace llvm ;
1415
@@ -22,6 +23,9 @@ MCTargetAsmParser::~MCTargetAsmParser() = default;
2223MCSubtargetInfo &MCTargetAsmParser::copySTI () {
2324 MCSubtargetInfo &STICopy = getContext ().getSubtargetCopy (getSTI ());
2425 STI = &STICopy;
26+ // The returned STI will likely be modified. Create a new fragment to avoid
27+ // mixed STI values within a fragment.
28+ getStreamer ().newFragment ();
2529 return STICopy;
2630}
2731
Original file line number Diff line number Diff line change @@ -1404,6 +1404,19 @@ MCSymbol *MCStreamer::endSection(MCSection *Section) {
14041404 return Sym;
14051405}
14061406
1407+ void MCStreamer::insert (MCFragment *F) {
1408+ auto *Sec = CurFrag->getParent ();
1409+ F->setParent (Sec);
1410+ F->setLayoutOrder (CurFrag->getLayoutOrder () + 1 );
1411+ CurFrag->Next = F;
1412+ CurFrag = F;
1413+ Sec->curFragList ()->Tail = F;
1414+ }
1415+
1416+ void MCStreamer::newFragment () {
1417+ insert (getContext ().allocFragment <MCFragment>());
1418+ }
1419+
14071420static VersionTuple
14081421targetVersionOrMinimumSupportedOSVersion (const Triple &Target,
14091422 VersionTuple TargetVersion) {
You can’t perform that action at this time.
0 commit comments