diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DIE.cpp | 54 |
1 files changed, 8 insertions, 46 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp index 0832544c0d6..d935c05dcc6 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DIE.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DIE.cpp @@ -425,51 +425,15 @@ void DIEInteger::EmitValue(const AsmPrinter *Asm, dwarf::Form Form) const { /// SizeOf - Determine size of integer value in bytes. /// unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { + dwarf::FormParams Params; + if (AP) + Params = {AP->getDwarfVersion(), uint8_t(AP->getPointerSize()), + AP->OutStreamer->getContext().getDwarfFormat()}; + + if (Optional<uint8_t> FixedSize = dwarf::getFixedFormByteSize(Form, Params)) + return *FixedSize; + switch (Form) { - case dwarf::DW_FORM_implicit_const: - case dwarf::DW_FORM_flag_present: - return 0; - case dwarf::DW_FORM_flag: - case dwarf::DW_FORM_ref1: - case dwarf::DW_FORM_data1: - case dwarf::DW_FORM_strx1: - case dwarf::DW_FORM_addrx1: - return sizeof(int8_t); - case dwarf::DW_FORM_ref2: - case dwarf::DW_FORM_data2: - case dwarf::DW_FORM_strx2: - case dwarf::DW_FORM_addrx2: - return sizeof(int16_t); - case dwarf::DW_FORM_strx3: - return 3; - case dwarf::DW_FORM_ref4: - case dwarf::DW_FORM_data4: - case dwarf::DW_FORM_ref_sup4: - case dwarf::DW_FORM_strx4: - case dwarf::DW_FORM_addrx4: - return sizeof(int32_t); - case dwarf::DW_FORM_ref8: - case dwarf::DW_FORM_ref_sig8: - case dwarf::DW_FORM_data8: - case dwarf::DW_FORM_ref_sup8: - return sizeof(int64_t); - case dwarf::DW_FORM_ref_addr: - if (AP->getDwarfVersion() == 2) - return AP->getPointerSize(); - LLVM_FALLTHROUGH; - case dwarf::DW_FORM_strp: - case dwarf::DW_FORM_GNU_ref_alt: - case dwarf::DW_FORM_GNU_strp_alt: - case dwarf::DW_FORM_line_strp: - case dwarf::DW_FORM_sec_offset: - case dwarf::DW_FORM_strp_sup: - switch (AP->OutStreamer->getContext().getDwarfFormat()) { - case dwarf::DWARF32: - return 4; - case dwarf::DWARF64: - return 8; - } - llvm_unreachable("Invalid DWARF format"); case dwarf::DW_FORM_GNU_str_index: case dwarf::DW_FORM_GNU_addr_index: case dwarf::DW_FORM_ref_udata: @@ -478,8 +442,6 @@ unsigned DIEInteger::SizeOf(const AsmPrinter *AP, dwarf::Form Form) const { return getULEB128Size(Integer); case dwarf::DW_FORM_sdata: return getSLEB128Size(Integer); - case dwarf::DW_FORM_addr: - return AP->getPointerSize(); default: llvm_unreachable("DIE Value form not supported yet"); } } |

