[llvm] f808abf - [MC] Add MCFragment allocation helpers
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 09:39:36 PDT 2024
Author: Fangrui Song
Date: 2024-06-14T09:39:32-07:00
New Revision: f808abf508a6b890b40fc2594ea36ce896bb1f37
URL: https://github.com/llvm/llvm-project/commit/f808abf508a6b890b40fc2594ea36ce896bb1f37
DIFF: https://github.com/llvm/llvm-project/commit/f808abf508a6b890b40fc2594ea36ce896bb1f37.diff
LOG: [MC] Add MCFragment allocation helpers
`allocFragment` might be changed to a placement new when the allocation
strategy changes.
`allocInitialFragment` is to deduplicate the following pattern
```
auto *F = new MCDataFragment();
Result->addFragment(*F);
F->setParent(Result);
```
Pull Request: https://github.com/llvm/llvm-project/pull/95197
Added:
Modified:
llvm/include/llvm/MC/MCCodeView.h
llvm/include/llvm/MC/MCContext.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCCodeView.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCPseudoProbe.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/lib/MC/WinCOFFObjectWriter.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCCodeView.h b/llvm/include/llvm/MC/MCCodeView.h
index d15f2e42c6cc9..b1d8fe37a3188 100644
--- a/llvm/include/llvm/MC/MCCodeView.h
+++ b/llvm/include/llvm/MC/MCCodeView.h
@@ -143,7 +143,7 @@ struct MCCVFunctionInfo {
/// Holds state from .cv_file and .cv_loc directives for later emission.
class CodeViewContext {
public:
- CodeViewContext();
+ CodeViewContext(MCContext *MCCtx) : MCCtx(MCCtx) {}
~CodeViewContext();
CodeViewContext &operator=(const CodeViewContext &other) = delete;
@@ -223,6 +223,8 @@ class CodeViewContext {
std::pair<StringRef, unsigned> addToStringTable(StringRef S);
private:
+ MCContext *MCCtx;
+
/// Map from string to string table offset.
StringMap<unsigned> StringTable;
diff --git a/llvm/include/llvm/MC/MCContext.h b/llvm/include/llvm/MC/MCContext.h
index ad412409b3e13..7c70a29b243de 100644
--- a/llvm/include/llvm/MC/MCContext.h
+++ b/llvm/include/llvm/MC/MCContext.h
@@ -44,6 +44,7 @@ namespace llvm {
class CodeViewContext;
class MCAsmInfo;
+class MCDataFragment;
class MCInst;
class MCLabel;
class MCObjectFileInfo;
@@ -345,6 +346,8 @@ class MCContext {
void reportCommon(SMLoc Loc,
std::function<void(SMDiagnostic &, const SourceMgr *)>);
+ MCDataFragment *allocInitialFragment(MCSection &Sec);
+
MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
bool IsTemporary);
MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
@@ -437,6 +440,10 @@ class MCContext {
/// Create and return a new MC instruction.
MCInst *createMCInst();
+ template <typename F, typename... Args> F *allocFragment(Args &&...args) {
+ return new F(std::forward<Args>(args)...);
+ }
+
/// \name Symbol Management
/// @{
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index 4ff606d373238..08420ed2b3a39 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -820,8 +820,11 @@ void MCAssembler::layout(MCAsmLayout &Layout) {
for (MCSection &Sec : *this) {
// Create dummy fragments to eliminate any empty sections, this simplifies
// layout.
- if (Sec.empty())
- new MCDataFragment(&Sec);
+ if (Sec.empty()) {
+ auto *F = getContext().allocFragment<MCDataFragment>();
+ F->setParent(&Sec);
+ Sec.addFragment(*F);
+ }
Sec.setOrdinal(SectionIndex++);
}
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index d234ce110918e..713ae07c3a730 100644
--- a/llvm/lib/MC/MCCodeView.cpp
+++ b/llvm/lib/MC/MCCodeView.cpp
@@ -26,8 +26,6 @@
using namespace llvm;
using namespace llvm::codeview;
-CodeViewContext::CodeViewContext() = default;
-
CodeViewContext::~CodeViewContext() {
// If someone inserted strings into the string table but never actually
// emitted them somewhere, clean up the fragment.
@@ -138,7 +136,7 @@ void CodeViewContext::recordCVLoc(MCContext &Ctx, const MCSymbol *Label,
MCDataFragment *CodeViewContext::getStringTableFragment() {
if (!StrTabFragment) {
- StrTabFragment = new MCDataFragment();
+ StrTabFragment = MCCtx->allocFragment<MCDataFragment>();
// Start a new string table out with a null byte.
StrTabFragment->getContents().push_back('\0');
}
@@ -450,9 +448,9 @@ void CodeViewContext::emitInlineLineTableForFunction(MCObjectStreamer &OS,
const MCSymbol *FnEndSym) {
// Create and insert a fragment into the current section that will be encoded
// later.
- new MCCVInlineLineTableFragment(PrimaryFunctionId, SourceFileId,
- SourceLineNum, FnStartSym, FnEndSym,
- OS.getCurrentSectionOnly());
+ auto *F = MCCtx->allocFragment<MCCVInlineLineTableFragment>(
+ PrimaryFunctionId, SourceFileId, SourceLineNum, FnStartSym, FnEndSym);
+ OS.insert(F);
}
MCFragment *CodeViewContext::emitDefRange(
@@ -461,8 +459,10 @@ MCFragment *CodeViewContext::emitDefRange(
StringRef FixedSizePortion) {
// Create and insert a fragment into the current section that will be encoded
// later.
- return new MCCVDefRangeFragment(Ranges, FixedSizePortion,
- OS.getCurrentSectionOnly());
+ auto *F =
+ MCCtx->allocFragment<MCCVDefRangeFragment>(Ranges, FixedSizePortion);
+ OS.insert(F);
+ return F;
}
static unsigned computeLabelDiff(MCAsmLayout &Layout, const MCSymbol *Begin,
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 0522f1bd7c7e4..f12a3bc0e56f5 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -195,6 +195,15 @@ MCInst *MCContext::createMCInst() {
return new (MCInstAllocator.Allocate()) MCInst;
}
+// Allocate the initial MCDataFragment for the begin symbol.
+MCDataFragment *MCContext::allocInitialFragment(MCSection &Sec) {
+ assert(!Sec.curFragList()->Head);
+ auto *F = allocFragment<MCDataFragment>();
+ F->setParent(&Sec);
+ Sec.addFragment(*F);
+ return F;
+}
+
//===----------------------------------------------------------------------===//
// Symbol Manipulation
//===----------------------------------------------------------------------===//
@@ -497,11 +506,8 @@ MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type,
MCSectionELF(Section, Type, Flags, K, EntrySize, Group, Comdat, UniqueID,
R, LinkedToSym);
- auto *F = new MCDataFragment();
- Ret->addFragment(*F);
- F->setParent(Ret);
+ auto *F = allocInitialFragment(*Ret);
R->setFragment(F);
-
return Ret;
}
@@ -797,11 +803,8 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind,
MCSectionWasm(CachedName, Kind, Flags, GroupSym, UniqueID, Begin);
Entry.second = Result;
- auto *F = new MCDataFragment();
- Result->addFragment(*F);
- F->setParent(Result);
+ auto *F = allocInitialFragment(*Result);
Begin->setFragment(F);
-
return Result;
}
@@ -863,10 +866,7 @@ MCSectionXCOFF *MCContext::getXCOFFSection(
Entry.second = Result;
- auto *F = new MCDataFragment();
- Result->addFragment(*F);
- F->setParent(Result);
-
+ auto *F = allocInitialFragment(*Result);
if (Begin)
Begin->setFragment(F);
@@ -886,10 +886,7 @@ MCSectionSPIRV *MCContext::getSPIRVSection() {
MCSectionSPIRV *Result = new (SPIRVAllocator.Allocate())
MCSectionSPIRV(SectionKind::getText(), Begin);
- auto *F = new MCDataFragment();
- Result->addFragment(*F);
- F->setParent(Result);
-
+ allocInitialFragment(*Result);
return Result;
}
@@ -909,10 +906,7 @@ MCSectionDXContainer *MCContext::getDXContainerSection(StringRef Section,
new (DXCAllocator.Allocate()) MCSectionDXContainer(Name, K, nullptr);
// The first fragment will store the header
- auto *F = new MCDataFragment();
- MapIt->second->addFragment(*F);
- F->setParent(MapIt->second);
-
+ allocInitialFragment(*MapIt->second);
return MapIt->second;
}
@@ -1043,7 +1037,7 @@ void MCContext::finalizeDwarfSections(MCStreamer &MCOS) {
CodeViewContext &MCContext::getCVContext() {
if (!CVContext)
- CVContext.reset(new CodeViewContext);
+ CVContext.reset(new CodeViewContext(this));
return *CVContext;
}
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 23e926c3a9d14..6bd6fe7edc87a 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -585,7 +585,7 @@ void MCELFStreamer::emitInstToData(const MCInst &Inst,
// When not in a bundle-locked group and the -mc-relax-all flag is used,
// we create a new temporary fragment which will be later merged into
// the current fragment.
- DF = new MCDataFragment();
+ DF = getContext().allocFragment<MCDataFragment>();
else if (isBundleLocked() && !Sec.isBundleGroupBeforeFirstInst()) {
// If we are bundle-locked, we re-use the current fragment.
// The bundle-locking directive ensures this is a new data fragment.
@@ -596,13 +596,14 @@ void MCELFStreamer::emitInstToData(const MCInst &Inst,
// Optimize memory usage by emitting the instruction to a
// MCCompactEncodedInstFragment when not in a bundle-locked group and
// there are no fixups registered.
- MCCompactEncodedInstFragment *CEIF = new MCCompactEncodedInstFragment();
+ MCCompactEncodedInstFragment *CEIF =
+ getContext().allocFragment<MCCompactEncodedInstFragment>();
insert(CEIF);
CEIF->getContents().append(Code.begin(), Code.end());
CEIF->setHasInstructions(STI);
return;
} else {
- DF = new MCDataFragment();
+ DF = getContext().allocFragment<MCDataFragment>();
insert(DF);
}
if (Sec.getBundleLockState() == MCSection::BundleLockedAlignToEnd) {
@@ -661,7 +662,7 @@ void MCELFStreamer::emitBundleLock(bool AlignToEnd) {
if (getAssembler().getRelaxAll() && !isBundleLocked()) {
// TODO: drop the lock state and set directly in the fragment
- MCDataFragment *DF = new MCDataFragment();
+ MCDataFragment *DF = getContext().allocFragment<MCDataFragment>();
BundleGroups.push_back(DF);
}
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 466aa633f0087..6b2e411b61505 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -199,7 +199,7 @@ void MCMachOStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
// We have to create a new fragment if this is an atom defining symbol,
// fragments cannot span atoms.
if (getAssembler().isSymbolLinkerVisible(*Symbol))
- insert(new MCDataFragment());
+ insert(getContext().allocFragment<MCDataFragment>());
MCObjectStreamer::emitLabel(Symbol, Loc);
@@ -555,7 +555,9 @@ void MCMachOStreamer::finalizeCGProfile() {
MCSection *CGProfileSection = Asm.getContext().getMachOSection(
"__LLVM", "__cg_profile", 0, SectionKind::getMetadata());
Asm.registerSection(*CGProfileSection);
- auto *Frag = new MCDataFragment(CGProfileSection);
+ auto *Frag = getContext().allocFragment<MCDataFragment>();
+ Frag->setParent(CGProfileSection);
+ CGProfileSection->addFragment(*Frag);
// For each entry, reserve space for 2 32-bit indices and a 64-bit count.
size_t SectionBytes =
Asm.CGProfile.size() * (2 * sizeof(uint32_t) + sizeof(uint64_t));
@@ -595,7 +597,9 @@ void MCMachOStreamer::createAddrSigSection() {
MCSection *AddrSigSection =
Asm.getContext().getObjectFileInfo()->getAddrSigSection();
Asm.registerSection(*AddrSigSection);
- auto *Frag = new MCDataFragment(AddrSigSection);
+ auto *Frag = getContext().allocFragment<MCDataFragment>();
+ Frag->setParent(AddrSigSection);
+ AddrSigSection->addFragment(*Frag);
// We will generate a series of pointer-sized symbol relocations at offset
// 0x0. Set the section size to be large enough to contain a single pointer
// (instead of emitting a zero-sized section) so these relocations are
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index bf1ce76cdc14b..24bed3119d663 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -225,7 +225,7 @@ MCDataFragment *
MCObjectStreamer::getOrCreateDataFragment(const MCSubtargetInfo *STI) {
MCDataFragment *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
if (!F || !canReuseDataFragment(*F, *Assembler, STI)) {
- F = new MCDataFragment();
+ F = getContext().allocFragment<MCDataFragment>();
insert(F);
}
return F;
@@ -343,7 +343,7 @@ void MCObjectStreamer::emitULEB128Value(const MCExpr *Value) {
emitULEB128IntValue(IntValue);
return;
}
- insert(new MCLEBFragment(*Value, false));
+ insert(getContext().allocFragment<MCLEBFragment>(*Value, false));
}
void MCObjectStreamer::emitSLEB128Value(const MCExpr *Value) {
@@ -352,7 +352,7 @@ void MCObjectStreamer::emitSLEB128Value(const MCExpr *Value) {
emitSLEB128IntValue(IntValue);
return;
}
- insert(new MCLEBFragment(*Value, true));
+ insert(getContext().allocFragment<MCLEBFragment>(*Value, true));
}
void MCObjectStreamer::emitWeakReference(MCSymbol *Alias,
@@ -470,7 +470,8 @@ void MCObjectStreamer::emitInstToFragment(const MCInst &Inst,
// Always create a new, separate fragment here, because its size can change
// during relaxation.
- MCRelaxableFragment *IF = new MCRelaxableFragment(Inst, STI);
+ MCRelaxableFragment *IF =
+ getContext().allocFragment<MCRelaxableFragment>(Inst, STI);
insert(IF);
SmallString<128> Code;
@@ -544,7 +545,8 @@ void MCObjectStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta,
return;
}
const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel, SMLoc());
- insert(new MCDwarfLineAddrFragment(LineDelta, *AddrDelta));
+ insert(getContext().allocFragment<MCDwarfLineAddrFragment>(LineDelta,
+ *AddrDelta));
}
void MCObjectStreamer::emitDwarfLineEndEntry(MCSection *Section,
@@ -569,7 +571,8 @@ void MCObjectStreamer::emitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
const MCSymbol *Label,
SMLoc Loc) {
const MCExpr *AddrDelta = buildSymbolDiff(*this, Label, LastLabel, Loc);
- insert(new MCDwarfCallFrameFragment(*AddrDelta, nullptr));
+ insert(getContext().allocFragment<MCDwarfCallFrameFragment>(*AddrDelta,
+ nullptr));
}
void MCObjectStreamer::emitCVLocDirective(unsigned FunctionId, unsigned FileNo,
@@ -640,7 +643,8 @@ void MCObjectStreamer::emitValueToAlignment(Align Alignment, int64_t Value,
unsigned MaxBytesToEmit) {
if (MaxBytesToEmit == 0)
MaxBytesToEmit = Alignment.value();
- insert(new MCAlignFragment(Alignment, Value, ValueSize, MaxBytesToEmit));
+ insert(getContext().allocFragment<MCAlignFragment>(
+ Alignment, Value, ValueSize, MaxBytesToEmit));
// Update the maximum alignment on the current section if necessary.
MCSection *CurSec = getCurrentSectionOnly();
@@ -657,7 +661,7 @@ void MCObjectStreamer::emitCodeAlignment(Align Alignment,
void MCObjectStreamer::emitValueToOffset(const MCExpr *Offset,
unsigned char Value,
SMLoc Loc) {
- insert(new MCOrgFragment(*Offset, Value, Loc));
+ insert(getContext().allocFragment<MCOrgFragment>(*Offset, Value, Loc));
}
// Associate DTPRel32 fixup with data and resize data area
@@ -844,7 +848,8 @@ void MCObjectStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
flushPendingLabels(DF, DF->getContents().size());
assert(getCurrentSectionOnly() && "need a section");
- insert(new MCFillFragment(FillValue, 1, NumBytes, Loc));
+ insert(
+ getContext().allocFragment<MCFillFragment>(FillValue, 1, NumBytes, Loc));
}
void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
@@ -874,7 +879,8 @@ void MCObjectStreamer::emitFill(const MCExpr &NumValues, int64_t Size,
flushPendingLabels(DF, DF->getContents().size());
assert(getCurrentSectionOnly() && "need a section");
- insert(new MCFillFragment(Expr, Size, NumValues, Loc));
+ insert(
+ getContext().allocFragment<MCFillFragment>(Expr, Size, NumValues, Loc));
}
void MCObjectStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLength,
@@ -885,7 +891,8 @@ void MCObjectStreamer::emitNops(int64_t NumBytes, int64_t ControlledNopLength,
assert(getCurrentSectionOnly() && "need a section");
- insert(new MCNopsFragment(NumBytes, ControlledNopLength, Loc, STI));
+ insert(getContext().allocFragment<MCNopsFragment>(
+ NumBytes, ControlledNopLength, Loc, STI));
}
void MCObjectStreamer::emitFileDirective(StringRef Filename) {
diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 2a75f46c57aa8..db0443dd54356 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -80,7 +80,8 @@ void MCPseudoProbe::emit(MCObjectStreamer *MCOS,
if (AddrDelta->evaluateAsAbsolute(Delta, MCOS->getAssemblerPtr())) {
MCOS->emitSLEB128IntValue(Delta);
} else {
- MCOS->insert(new MCPseudoProbeAddrFragment(AddrDelta));
+ MCOS->insert(MCOS->getContext().allocFragment<MCPseudoProbeAddrFragment>(
+ AddrDelta));
}
} else {
// Emit the GUID of the split function that the sentinel probe represents.
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index e510e1e4031cd..5732b29b85d94 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -196,7 +196,7 @@ void MCWinCOFFStreamer::emitCOFFSafeSEH(MCSymbol const *Symbol) {
getAssembler().registerSection(*SXData);
SXData->ensureMinAlignment(Align(4));
- new MCSymbolIdFragment(Symbol, SXData);
+ getContext().allocFragment<MCSymbolIdFragment>(Symbol, SXData);
getAssembler().registerSymbol(*Symbol);
CSymbol->setIsSafeSEH();
@@ -212,7 +212,8 @@ void MCWinCOFFStreamer::emitCOFFSymbolIndex(MCSymbol const *Symbol) {
getAssembler().registerSection(*Sec);
Sec->ensureMinAlignment(Align(4));
- new MCSymbolIdFragment(Symbol, getCurrentSectionOnly());
+ getContext().allocFragment<MCSymbolIdFragment>(Symbol,
+ getCurrentSectionOnly());
getAssembler().registerSymbol(*Symbol);
}
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index a2b6c4e5c3a5c..e877bf88df81b 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -1097,8 +1097,9 @@ uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
// Create the contents of the .llvm_addrsig section.
if (Mode != DwoOnly && OWriter.EmitAddrsigSection) {
- auto Frag = new MCDataFragment(AddrsigSection);
- Frag->setLayoutOrder(0);
+ auto *Frag = Asm.getContext().allocFragment<MCDataFragment>();
+ Frag->setParent(AddrsigSection);
+ AddrsigSection->addFragment(*Frag);
raw_svector_ostream OS(Frag->getContents());
for (const MCSymbol *S : OWriter.AddrsigSyms) {
if (!S->isRegistered())
@@ -1118,8 +1119,9 @@ uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
// Create the contents of the .llvm.call-graph-profile section.
if (Mode != DwoOnly && CGProfileSection) {
- auto *Frag = new MCDataFragment(CGProfileSection);
- Frag->setLayoutOrder(0);
+ auto *Frag = Asm.getContext().allocFragment<MCDataFragment>();
+ Frag->setParent(CGProfileSection);
+ CGProfileSection->addFragment(*Frag);
raw_svector_ostream OS(Frag->getContents());
for (const MCAssembler::CGProfileEntry &CGPE : Asm.CGProfile) {
uint32_t FromIndex = CGPE.From->getSymbol().getIndex();
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 1b8462f2d258c..02d0aac4fed41 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -556,7 +556,9 @@ void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
isFirstMacroFusibleInst(Inst, *MCII))) {
// If we meet a unfused branch or the first instuction in a fusiable pair,
// insert a BoundaryAlign fragment.
- OS.insert(PendingBA = new MCBoundaryAlignFragment(AlignBoundary, STI));
+ PendingBA = OS.getContext().allocFragment<MCBoundaryAlignFragment>(
+ AlignBoundary, STI);
+ OS.insert(PendingBA);
}
}
@@ -589,7 +591,7 @@ void X86AsmBackend::emitInstructionEnd(MCObjectStreamer &OS,
// MCAssembler::relaxBoundaryAlign. The easiest way is to insert a new empty
// DataFragment.
if (isa_and_nonnull<MCDataFragment>(CF))
- OS.insert(new MCDataFragment());
+ OS.insert(OS.getContext().allocFragment<MCDataFragment>());
// Update the maximum alignment on the current section if necessary.
MCSection *Sec = OS.getCurrentSectionOnly();
More information about the llvm-commits
mailing list