Skip to content

Commit e47d401

Browse files
committed
CodeView: Move MCCVDefRangeFragment storage to MCContext/MCFragment
Work toward making ~MCCVInlineLineTableFragment trivial.
1 parent 9a6e068 commit e47d401

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

llvm/include/llvm/MC/MCCodeView.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "llvm/ADT/SmallVector.h"
1919
#include "llvm/ADT/StringMap.h"
2020
#include "llvm/ADT/StringRef.h"
21+
#include <deque>
2122
#include <map>
2223
#include <vector>
2324

@@ -268,6 +269,9 @@ class CodeViewContext {
268269
/// Indicate whether we have already laid out the checksum table addresses or
269270
/// not.
270271
bool ChecksumOffsetsAssigned = false;
272+
273+
/// Storage of MCCVDefRangeFragment::Ranges.
274+
std::deque<std::pair<const MCSymbol *, const MCSymbol *>> DefRangeStorage;
271275
};
272276

273277
} // end namespace llvm

llvm/include/llvm/MC/MCFragment.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ class MCCVInlineLineTableFragment : public MCFragment {
492492

493493
/// Fragment representing the .cv_def_range directive.
494494
class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
495-
SmallVector<std::pair<const MCSymbol *, const MCSymbol *>, 2> Ranges;
496-
SmallString<32> FixedSizePortion;
495+
ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges;
496+
StringRef FixedSizePortion;
497497

498498
/// CodeViewContext has the real knowledge about this format, so let it access
499499
/// our members.
@@ -510,7 +510,7 @@ class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
510510
return Ranges;
511511
}
512512

513-
StringRef getFixedSizePortion() const { return FixedSizePortion.str(); }
513+
StringRef getFixedSizePortion() const { return FixedSizePortion; }
514514

515515
static bool classof(const MCFragment *F) {
516516
return F->getKind() == MCFragment::FT_CVDefRange;

llvm/lib/MC/MCCodeView.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ MCFragment *CodeViewContext::emitDefRange(
444444
StringRef FixedSizePortion) {
445445
// Create and insert a fragment into the current section that will be encoded
446446
// later.
447+
FixedSizePortion = MCCtx->allocateString(FixedSizePortion);
448+
auto Pos = DefRangeStorage.size();
449+
llvm::append_range(DefRangeStorage, Ranges);
450+
if (!Ranges.empty())
451+
Ranges = {&DefRangeStorage[Pos], Ranges.size()};
447452
auto *F =
448453
MCCtx->allocFragment<MCCVDefRangeFragment>(Ranges, FixedSizePortion);
449454
OS.insert(F);

0 commit comments

Comments
 (0)