Use value types instead of 'new'd objects to store dwarf labels for asm files

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206009 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-04-11 00:43:52 +00:00
parent 62fc093cf2
commit e6cd1ac2d5
2 changed files with 12 additions and 26 deletions

View File

@@ -137,7 +137,7 @@ namespace llvm {
/// The information gathered from labels that will have dwarf label /// The information gathered from labels that will have dwarf label
/// entries when generating dwarf assembly source files. /// entries when generating dwarf assembly source files.
std::vector<const MCGenDwarfLabelEntry *> MCGenDwarfLabelEntries; std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
/// The string to embed in the debug information for the compile unit, if /// The string to embed in the debug information for the compile unit, if
/// non-empty. /// non-empty.
@@ -383,11 +383,10 @@ namespace llvm {
void setGenDwarfSectionEndSym(MCSymbol *Sym) { void setGenDwarfSectionEndSym(MCSymbol *Sym) {
GenDwarfSectionEndSym = Sym; GenDwarfSectionEndSym = Sym;
} }
const std::vector<const MCGenDwarfLabelEntry *> const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
&getMCGenDwarfLabelEntries() const {
return MCGenDwarfLabelEntries; return MCGenDwarfLabelEntries;
} }
void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry *E) { void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E) {
MCGenDwarfLabelEntries.push_back(E); MCGenDwarfLabelEntries.push_back(E);
} }

View File

@@ -727,28 +727,24 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
// Third part: the list of label DIEs. // Third part: the list of label DIEs.
// Loop on saved info for dwarf labels and create the DIEs for them. // Loop on saved info for dwarf labels and create the DIEs for them.
const std::vector<const MCGenDwarfLabelEntry *> &Entries = const std::vector<MCGenDwarfLabelEntry> &Entries =
MCOS->getContext().getMCGenDwarfLabelEntries(); MCOS->getContext().getMCGenDwarfLabelEntries();
for (std::vector<const MCGenDwarfLabelEntry *>::const_iterator it = for (const auto &Entry : Entries) {
Entries.begin(), ie = Entries.end(); it != ie;
++it) {
const MCGenDwarfLabelEntry *Entry = *it;
// The DW_TAG_label DIE abbrev (2). // The DW_TAG_label DIE abbrev (2).
MCOS->EmitULEB128IntValue(2); MCOS->EmitULEB128IntValue(2);
// AT_name, of the label without any leading underbar. // AT_name, of the label without any leading underbar.
MCOS->EmitBytes(Entry->getName()); MCOS->EmitBytes(Entry.getName());
MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string. MCOS->EmitIntValue(0, 1); // NULL byte to terminate the string.
// AT_decl_file, index into the file table. // AT_decl_file, index into the file table.
MCOS->EmitIntValue(Entry->getFileNumber(), 4); MCOS->EmitIntValue(Entry.getFileNumber(), 4);
// AT_decl_line, source line number. // AT_decl_line, source line number.
MCOS->EmitIntValue(Entry->getLineNumber(), 4); MCOS->EmitIntValue(Entry.getLineNumber(), 4);
// AT_low_pc, start address of the label. // AT_low_pc, start address of the label.
const MCExpr *AT_low_pc = MCSymbolRefExpr::Create(Entry->getLabel(), const MCExpr *AT_low_pc = MCSymbolRefExpr::Create(Entry.getLabel(),
MCSymbolRefExpr::VK_None, context); MCSymbolRefExpr::VK_None, context);
MCOS->EmitValue(AT_low_pc, AddrSize); MCOS->EmitValue(AT_low_pc, AddrSize);
@@ -761,14 +757,6 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
// Add the NULL DIE terminating the DW_TAG_unspecified_parameters DIE's. // Add the NULL DIE terminating the DW_TAG_unspecified_parameters DIE's.
MCOS->EmitIntValue(0, 1); MCOS->EmitIntValue(0, 1);
} }
// Deallocate the MCGenDwarfLabelEntry classes that saved away the info
// for the dwarf labels.
for (std::vector<const MCGenDwarfLabelEntry *>::const_iterator it =
Entries.begin(), ie = Entries.end(); it != ie;
++it) {
const MCGenDwarfLabelEntry *Entry = *it;
delete Entry;
}
// Add the NULL DIE terminating the Compile Unit DIE's. // Add the NULL DIE terminating the Compile Unit DIE's.
MCOS->EmitIntValue(0, 1); MCOS->EmitIntValue(0, 1);
@@ -856,9 +844,8 @@ void MCGenDwarfLabelEntry::Make(MCSymbol *Symbol, MCStreamer *MCOS,
MCOS->EmitLabel(Label); MCOS->EmitLabel(Label);
// Create and entry for the info and add it to the other entries. // Create and entry for the info and add it to the other entries.
MCGenDwarfLabelEntry *Entry = MCOS->getContext().addMCGenDwarfLabelEntry(
new MCGenDwarfLabelEntry(Name, FileNumber, LineNumber, Label); MCGenDwarfLabelEntry(Name, FileNumber, LineNumber, Label));
MCOS->getContext().addMCGenDwarfLabelEntry(Entry);
} }
static int getDataAlignmentFactor(MCStreamer &streamer) { static int getDataAlignmentFactor(MCStreamer &streamer) {