aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCCodeView.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-06-14 09:39:32 -0700
committerGitHub <noreply@github.com>2024-06-14 09:39:32 -0700
commitf808abf508a6b890b40fc2594ea36ce896bb1f37 (patch)
tree9f21f531de19567e57fd793f9675538ea34bca6c /llvm/lib/MC/MCCodeView.cpp
parent8b9dce333f71bc21b3534e89a41e1ea8672aa063 (diff)
downloadllvm-f808abf508a6b890b40fc2594ea36ce896bb1f37.zip
llvm-f808abf508a6b890b40fc2594ea36ce896bb1f37.tar.gz
llvm-f808abf508a6b890b40fc2594ea36ce896bb1f37.tar.bz2
[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
Diffstat (limited to 'llvm/lib/MC/MCCodeView.cpp')
-rw-r--r--llvm/lib/MC/MCCodeView.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp
index d234ce1..713ae07 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,