Skip to content

Commit

Permalink
[DebugInfo] Use a common method to determine a suitable form for sect…
Browse files Browse the repository at this point in the history
…ion offsts (6/19).

This is mostly an NFC patch because the involved methods are used when
emitting DWO files, which is incompatible with DWARFv3, or for platforms
where DWARF64 is not supported yet.

Differential Revision: https://reviews.llvm.org/D87015
  • Loading branch information
igorkudrin committed Sep 15, 2020
1 parent 5dd1c59 commit cae7c1e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/AsmPrinter/DIE.cpp
Expand Up @@ -550,6 +550,8 @@ unsigned DIEDelta::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const {
switch (Form) {
case dwarf::DW_FORM_data4:
return 4;
case dwarf::DW_FORM_data8:
return 8;
case dwarf::DW_FORM_sec_offset:
return AP->getDwarfOffsetByteSize();
default:
Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
Expand Up @@ -300,10 +300,7 @@ void DwarfUnit::addLabel(DIELoc &Die, dwarf::Form Form, const MCSymbol *Label) {

void DwarfUnit::addSectionOffset(DIE &Die, dwarf::Attribute Attribute,
uint64_t Integer) {
if (DD->getDwarfVersion() >= 4)
addUInt(Die, Attribute, dwarf::DW_FORM_sec_offset, Integer);
else
addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer);
addUInt(Die, Attribute, DD->getDwarfSectionOffsetForm(), Integer);
}

unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) {
Expand Down Expand Up @@ -1750,8 +1747,7 @@ DIE::value_iterator
DwarfUnit::addSectionDelta(DIE &Die, dwarf::Attribute Attribute,
const MCSymbol *Hi, const MCSymbol *Lo) {
return Die.addValue(DIEValueAllocator, Attribute,
DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset
: dwarf::DW_FORM_data4,
DD->getDwarfSectionOffsetForm(),
new (DIEValueAllocator) DIEDelta(Hi, Lo));
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/unittests/CodeGen/DIETest.cpp
Expand Up @@ -162,8 +162,10 @@ INSTANTIATE_TEST_CASE_P(
DIETestParams, DIEDeltaFixture,
testing::Values(
DIETestParams{4, dwarf::DWARF32, dwarf::DW_FORM_data4, 4u},
DIETestParams{4, dwarf::DWARF32, dwarf::DW_FORM_data8, 8u},
DIETestParams{4, dwarf::DWARF32, dwarf::DW_FORM_sec_offset, 4u},
DIETestParams{4, dwarf::DWARF64, dwarf::DW_FORM_data4, 4u},
DIETestParams{4, dwarf::DWARF64, dwarf::DW_FORM_data8, 8u},
DIETestParams{4, dwarf::DWARF64, dwarf::DW_FORM_sec_offset, 8u}), );

struct DIELocListFixture : public DIEFixtureBase {
Expand Down

0 comments on commit cae7c1e

Please sign in to comment.