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 {
73
73
MCSymbol *emitCFILabel () override ;
74
74
void emitCFISections (bool EH, bool Debug) override ;
75
75
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
-
85
76
// / Get a data fragment to write into, creating a new one if the current
86
77
// / 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 ();
90
79
91
80
protected:
92
81
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 {
188
188
// destructors.
189
189
class MCFragment {
190
190
friend class MCAssembler ;
191
+ friend class MCStreamer ;
191
192
friend class MCObjectStreamer ;
192
193
friend class MCSection ;
193
194
Original file line number Diff line number Diff line change @@ -429,7 +429,6 @@ class LLVM_ABI MCStreamer {
429
429
CurFrag->getParent () == getCurrentSection ().first );
430
430
return CurFrag;
431
431
}
432
-
433
432
// / Save the current and previous section on the section stack.
434
433
void pushSection () {
435
434
SectionStack.push_back (
@@ -457,6 +456,9 @@ class LLVM_ABI MCStreamer {
457
456
458
457
MCSymbol *endSection (MCSection *Section);
459
458
459
+ void insert (MCFragment *F);
460
+ void newFragment ();
461
+
460
462
// / Returns the mnemonic for \p MI, if the streamer has access to a
461
463
// / instruction printer and returns an empty string otherwise.
462
464
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) {
106
106
MCDwarfFrameEmitter::Emit (*this , MAB, false );
107
107
}
108
108
109
- static bool canReuseDataFragment (const MCFragment &F,
110
- const MCAssembler &Assembler,
111
- const MCSubtargetInfo *STI) {
109
+ static bool canReuseDataFragment (const MCFragment &F) {
112
110
if (!F.hasInstructions ())
113
111
return true ;
114
112
// Do not add data after a linker-relaxable instruction. The difference
115
113
// between a new label and a label at or before the linker-relaxable
116
114
// 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 ();
122
116
}
123
117
124
- MCFragment *
125
- MCObjectStreamer::getOrCreateDataFragment (const MCSubtargetInfo *STI) {
118
+ MCFragment *MCObjectStreamer::getOrCreateDataFragment () {
126
119
auto *F = getCurrentFragment ();
127
- if (F->getKind () != MCFragment::FT_Data ||
128
- !canReuseDataFragment (*F, *Assembler, STI)) {
120
+ if (F->getKind () != MCFragment::FT_Data || !canReuseDataFragment (*F)) {
129
121
F = getContext ().allocFragment <MCFragment>();
130
122
insert (F);
131
123
}
Original file line number Diff line number Diff line change 9
9
#include " llvm/MC/MCParser/MCTargetAsmParser.h"
10
10
#include " llvm/MC/MCContext.h"
11
11
#include " llvm/MC/MCRegister.h"
12
+ #include " llvm/MC/MCStreamer.h"
12
13
13
14
using namespace llvm ;
14
15
@@ -22,6 +23,9 @@ MCTargetAsmParser::~MCTargetAsmParser() = default;
22
23
MCSubtargetInfo &MCTargetAsmParser::copySTI () {
23
24
MCSubtargetInfo &STICopy = getContext ().getSubtargetCopy (getSTI ());
24
25
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 ();
25
29
return STICopy;
26
30
}
27
31
Original file line number Diff line number Diff line change @@ -1404,6 +1404,19 @@ MCSymbol *MCStreamer::endSection(MCSection *Section) {
1404
1404
return Sym;
1405
1405
}
1406
1406
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
+
1407
1420
static VersionTuple
1408
1421
targetVersionOrMinimumSupportedOSVersion (const Triple &Target,
1409
1422
VersionTuple TargetVersion) {
You can’t perform that action at this time.
0 commit comments