diff options
Diffstat (limited to 'llvm/lib/MC/MCCodeView.cpp')
-rw-r--r-- | llvm/lib/MC/MCCodeView.cpp | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/llvm/lib/MC/MCCodeView.cpp b/llvm/lib/MC/MCCodeView.cpp index 9e4a69e..e78f5a0 100644 --- a/llvm/lib/MC/MCCodeView.cpp +++ b/llvm/lib/MC/MCCodeView.cpp @@ -25,11 +25,9 @@ using namespace llvm; using namespace llvm::codeview; -CodeViewContext::~CodeViewContext() { - // If someone inserted strings into the string table but never actually - // emitted them somewhere, clean up the fragment. - if (!InsertedStrTabFragment && StrTabFragment) - StrTabFragment->destroy(); +void CodeViewContext::finish() { + if (StrTabFragment) + StrTabFragment->setContents(StrTab); } /// This is a valid number for use with .cv_loc if we've already seen a .cv_file @@ -133,26 +131,15 @@ void CodeViewContext::recordCVLoc(MCContext &Ctx, const MCSymbol *Label, Label, FunctionId, FileNo, Line, Column, PrologueEnd, IsStmt}); } -MCDataFragment *CodeViewContext::getStringTableFragment() { - if (!StrTabFragment) { - StrTabFragment = MCCtx->allocFragment<MCDataFragment>(); - // Start a new string table out with a null byte. - StrTabFragment->appendContents(1, '\0'); - } - return StrTabFragment; -} - std::pair<StringRef, unsigned> CodeViewContext::addToStringTable(StringRef S) { - SmallVectorImpl<char> &Contents = getStringTableFragment()->getContents(); auto Insertion = - StringTable.insert(std::make_pair(S, unsigned(Contents.size()))); + StringTable.insert(std::make_pair(S, unsigned(StrTab.size()))); // Return the string from the table, since it is stable. std::pair<StringRef, unsigned> Ret = std::make_pair(Insertion.first->first(), Insertion.first->second); if (Insertion.second) { // The string map key is always null terminated. - StrTabFragment->appendContents( - ArrayRef(Ret.first.begin(), Ret.first.end() + 1)); + StrTab.append(Ret.first.begin(), Ret.first.end() + 1); } return Ret; } @@ -178,9 +165,9 @@ void CodeViewContext::emitStringTable(MCObjectStreamer &OS) { // Put the string table data fragment here, if we haven't already put it // somewhere else. If somebody wants two string tables in their .s file, one // will just be empty. - if (!InsertedStrTabFragment) { - OS.insert(getStringTableFragment()); - InsertedStrTabFragment = true; + if (!StrTabFragment) { + StrTabFragment = Ctx.allocFragment<MCDataFragment>(); + OS.insert(StrTabFragment); } OS.emitValueToAlignment(Align(4), 0); @@ -375,11 +362,9 @@ void CodeViewContext::emitLineTableForFunction(MCObjectStreamer &OS, return Loc.getFileNum() != CurFileNum; }); unsigned EntryCount = FileSegEnd - I; - OS.AddComment( - "Segment for file '" + - Twine(getStringTableFragment() - ->getContents()[Files[CurFileNum - 1].StringTableOffset]) + - "' begins"); + OS.AddComment("Segment for file '" + + Twine(StrTab[Files[CurFileNum - 1].StringTableOffset]) + + "' begins"); OS.emitCVFileChecksumOffsetDirective(CurFileNum); OS.emitInt32(EntryCount); uint32_t SegmentSize = 12; |