summaryrefslogtreecommitdiff
path: root/llvm/lib/ObjectYAML/DWARFEmitter.cpp
AgeCommit message (Collapse)Author
2025-02-07[ObjectYAML] Avoid repeated hash lookups (NFC) (#126187)Kazu Hirata
2024-11-17[ObjectYAML] Remove unused includes (NFC) (#116530)Kazu Hirata
Identified with misc-include-cleaner.
2024-11-12[llvm] Remove redundant control flow statements (NFC) (#115831)Kazu Hirata
Identified with readability-redundant-control-flow.
2024-08-12[dwarf2yaml] Correctly emit type and split unit headers (#102471)Pavel Labath
(DWARFv5) split units have an extra `dwo_id` field in the header. Type units have `type_signature` and `type_offset`.
2024-02-12[DWARFYAML] Implement debug_names support (#79666)Felipe de Azevedo Piovezan
This commit brings support for debug_names in DWARFYAML. It parses YAML and generates emits a DWARF5 Accelerator table with the following limitations: 1. All forms must have a fixed length (zero length is also ok). 2. Hard-coded support for DWARF 5 and DWARF32. 3. The generated table does not contain a hash index All of these limitations can be lifted in the future, but for now this is good enough to enable testing.
2023-02-10[NFC][TargetParser] Replace uses of llvm/Support/Host.hArchibald Elliott
The forwarding header is left in place because of its use in `polly/lib/External/isl/interface/extract_interface.cc`, but I have added a GCC warning about the fact it is deprecated, because it is used in `isl` from where it is included by Polly.
2022-12-06[YAML] Convert Optional to std::optionalKrzysztof Parzyszek
2022-06-18[llvm] Use value_or instead of getValueOr (NFC)Kazu Hirata
2021-01-18[llvm] Populate std::vector at construction time (NFC)Kazu Hirata
2020-12-17Make LLVM build in C++20 modeBarry Revzin
Part of the <=> changes in C++20 make certain patterns of writing equality operators ambiguous with themselves (sorry!). This patch goes through and adjusts all the comparison operators such that they should work in both C++17 and C++20 modes. It also makes two other small C++20-specific changes (adding a constructor to a type that cases to be an aggregate, and adding casts from u8 literals which no longer have type const char*). There were four categories of errors that this review fixes. Here are canonical examples of them, ordered from most to least common: // 1) Missing const namespace missing_const { struct A { #ifndef FIXED bool operator==(A const&); #else bool operator==(A const&) const; #endif }; bool a = A{} == A{}; // error } // 2) Type mismatch on CRTP namespace crtp_mismatch { template <typename Derived> struct Base { #ifndef FIXED bool operator==(Derived const&) const; #else // in one case changed to taking Base const& friend bool operator==(Derived const&, Derived const&); #endif }; struct D : Base<D> { }; bool b = D{} == D{}; // error } // 3) iterator/const_iterator with only mixed comparison namespace iter_const_iter { template <bool Const> struct iterator { using const_iterator = iterator<true>; iterator(); template <bool B, std::enable_if_t<(Const && !B), int> = 0> iterator(iterator<B> const&); #ifndef FIXED bool operator==(const_iterator const&) const; #else friend bool operator==(iterator const&, iterator const&); #endif }; bool c = iterator<false>{} == iterator<false>{} // error || iterator<false>{} == iterator<true>{} || iterator<true>{} == iterator<false>{} || iterator<true>{} == iterator<true>{}; } // 4) Same-type comparison but only have mixed-type operator namespace ambiguous_choice { enum Color { Red }; struct C { C(); C(Color); operator Color() const; bool operator==(Color) const; friend bool operator==(C, C); }; bool c = C{} == C{}; // error bool d = C{} == Red; } Differential revision: https://reviews.llvm.org/D78938
2020-10-09[DWARFYAML] Make the opcode_base and the standard_opcode_lengths fields ↵Xing GUO
optional. This patch makes the opcode_base and the standard_opcode_lengths fields of the line table optional. When both of them are not specified, yaml2obj emits them according to the line table's version. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D88355
2020-09-24[DWARFYAML] Make the ExtLen field of extended opcodes optional.Xing GUO
This patch makes the 'ExtLen' field of extended opcodes optional. We don't need to manually calculate it in the future. Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D88136
2020-09-21DWARFEmitter.cpp - use auto const& iterators in for-range loops to avoid ↵Simon Pilgrim
copies. NFCI.
2020-09-21DWARFYAML::emitDebugSections - remove unnecessary cantFail(success) call. NFCI.Simon Pilgrim
As mentioned on rG6bb912336804.
2020-09-20DWARFYAML::emitDebugSections - fix use after std::move warnings. NFCI.Simon Pilgrim
We were using Err after it had been moved into cantFail - avoid this by calling cantFail with Error::success() directly.
2020-09-08[DWARFYAML] Make the debug_ranges section optional.Xing GUO
This patch makes the debug_ranges section optional. When we specify an empty debug_ranges section, yaml2obj only emits the section header. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D87263
2020-09-07[DWARFYAML] Make the debug_addr section optional.Xing GUO
This patch makes the debug_addr section optional. When an empty debug_addr section is specified, yaml2obj only emits a section header for it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D87205
2020-09-01[DWARFYAML] Make the debug_str section optional.Xing GUO
This patch makes the debug_str section optional. When the debug_str section exists but doesn't contain anything, yaml2obj will emit a section header for it. Reviewed By: grimar Differential Revision: https://reviews.llvm.org/D86860
2020-08-29[DWARFYAML] Make the debug_abbrev_offset field optional.Xing GUO
This patch helps make the debug_abbrev_offset field optional. We don't need to calculate the value of this field in the future. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86614
2020-08-28[DWARFYAML] Abbrev codes in a new abbrev table should start from 1 (by default).Xing GUO
The abbrev codes in a new abbrev table should start from 1 (by default), rather than inherit the value from the code in the previous table. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86545
2020-08-26[DWARFYAML] Make the unit_length and header_length fields optional.Xing GUO
This patch makes the unit_length and header_length fields of line tables optional. yaml2obj is able to infer them for us. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D86590
2020-08-26[DWARFYAML] Use writeDWARFOffset() to write the prologue_length field. NFC.Xing GUO
Use writeDWARFOffset() to simplify the logic. NFC.
2020-08-21Recommit: [DWARFYAML] Add support for referencing different abbrev tables.Xing GUO
The original commit (7ff0ace96db9164dcde232c36cab6519ea4fce8) was causing build failure and was reverted in 6d242a73264ef1e3e128547f00e0fe2d20d3ada0 ==================== Original Commit Message ==================== This patch adds support for referencing different abbrev tables. We use 'ID' to distinguish abbrev tables and use 'AbbrevTableID' to explicitly assign an abbrev table to compilation units. The syntax is: ``` debug_abbrev: - ID: 0 Table: ... - ID: 1 Table: ... debug_info: - ... AbbrevTableID: 1 ## Reference the second abbrev table. - ... AbbrevTableID: 0 ## Reference the first abbrev table. ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D83116
2020-08-21Revert "[DWARFYAML] Add support for referencing different abbrev tables."Xing GUO
This reverts commit f7ff0ace96db9164dcde232c36cab6519ea4fce8. This change is causing build failure. http://lab.llvm.org:8011/builders/clang-cmake-armv7-global-isel/builds/10400
2020-08-21[DWARFYAML] Add support for referencing different abbrev tables.Xing GUO
This patch adds support for referencing different abbrev tables. We use 'ID' to distinguish abbrev tables and use 'AbbrevTableID' to explicitly assign an abbrev table to compilation units. The syntax is: ``` debug_abbrev: - ID: 0 Table: ... - ID: 1 Table: ... debug_info: - ... AbbrevTableID: 1 ## Reference the second abbrev table. - ... AbbrevTableID: 0 ## Reference the first abbrev table. ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D83116
2020-08-21[DWARFYAML] Add support for emitting multiple abbrev tables.Xing GUO
This patch adds support for emitting multiple abbrev tables. Currently, compilation units will always reference the first abbrev table. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D86194
2020-08-19Make helpers static. NFC.Benjamin Kramer
2020-08-13[DWARFYAML] Replace InitialLength with Format and Length. NFC.Xing GUO
This change replaces the InitialLength of pub-tables with Format and Length. All the InitialLength fields have been removed. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85880
2020-08-12[DWARFYAML] Make the address size of compilation units optional.Xing GUO
This patch makes the 'AddrSize' field optional. If the address size is missing, yaml2obj will infer it from the object file. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85805
2020-08-12[DWARFYAML] Teach yaml2obj emit the correct line table program.Xing GUO
The following issues are addressed in this patch. 1. The operands of DW_LNE_set_discriminator should be an ULEB128 number rather than an address. 2. Test the emitted opcodes. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85717
2020-08-11[DWARFYAML] Let the address size of line tables inferred from the object file.Xing GUO
Currently, the line table uses the first compilation unit's address size as its address size. It's not the right behavior. The address size should be inferred from the target machine. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85707
2020-08-06[DWARFYAML][debug_info] Pull out dwarf::FormParams from DWARFYAML::Unit.Xing GUO
Unit.Format, Unit.Version and Unit.AddrSize are replaced with dwarf::FormParams in D84496 to get rid of unnecessary functions getOffsetSize() and getRefSize(). However, that change makes it difficult to make AddrSize optional (Optional<uint8_t>). This change pulls out dwarf::FormParams from DWARFYAML::Unit and use it as a helper struct in DWARFYAML::emitDebugInfo(). Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D85296
2020-08-05[DWARFYAML] Fix unintialized value Is64BitAddrSize. NFC.Xing GUO
This patch fixes the undefined behavior that reported by ubsan. http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/44524/
2020-08-03[DWARFYAML] Implement the .debug_loclists section.Xing GUO
This patch implements the .debug_loclists section. There are only two DWARF expressions are implemented in this patch (DW_OP_consts, DW_OP_stack_value). We will implement more in the future. The YAML description of the .debug_loclists section is: ``` debug_loclists: - Format: DWARF32 ## Optional Length: 0x1234 ## Optional Version: 5 ## Optional (5 by default) AddressSize: 8 ## Optional SegmentSelectorSize: 0 ## Optional (0 by default) OffsetEntryCount: 1 ## Optional Offsets: [ 1 ] ## Optional Lists: - Entries: - Operator: DW_LLE_startx_endx Values: [ 0x1234, 0x4321 ] DescriptorsLength: 0x1234 ## Optional Descriptors: - Operator: DW_OP_consts Values: [ 0x1234 ] ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84234
2020-08-03[DWARFYAML] Offsets should be omitted when the OffsetEntryCount is 0.Xing GUO
The offsets field should be omitted when the 'OffsetEntryCount' entry is specified to be 0. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85006
2020-07-31[DWARFYAML] Make the debug_aranges entry optional.Xing GUO
This patch makes the 'debug_aranges' entry optional. If the entry is empty, yaml2obj will only emit the header for it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84921
2020-07-31[DWARFYAML] Add helper function getDWARFEmitterByName(). NFC.Xing GUO
In this patch, we add a helper function getDWARFEmitterByName(). This function returns the proper DWARF section emitting method by the name. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84952
2020-07-31[DWARFYAML] Add emitDebug[GNU]Pub[names/types] functions. NFC.Xing GUO
In this patch, emitDebugPubnames(), emitDebugPubtypes(), emitDebugGNUPubnames(), emitDebugGNUPubtypes() are added. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D85003
2020-07-30[DWARFYAML] Make the 'Length' field of the address range table optional.Xing GUO
This patch makes the 'Length' field of the address range table optional. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84911
2020-07-30[DWARFYAML] Make the 'AddressSize', 'SegmentSelectorSize' fields optional.Xing GUO
This patch makes the 'AddressSize' and 'SegmentSelectorSize' fields of address range table optional. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84907
2020-07-28[DWARFYAML] Rename checkListEntryOperands() to checkOperandCount(). NFC.Xing GUO
This patch renames checkListEntryOperands() to checkOperandCount(), so that we are able to check DWARF expression operands using the same function. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D84624
2020-07-28[DWARFYAML] Add support for emitting custom range list content.Xing GUO
This patch adds support for emitting custom range list content. We are able to handcraft a custom range list via the following syntax. ``` debug_rnglists: - Lists: - Entries: - Operator: DW_RLE_startx_endx Values: [ 0x1234, 0x1234 ] - Content: '1234567890abcdef' - Content: 'abcdef1234567890' ``` Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84618
2020-07-24[DWARFYAML] Replace 'Format', 'Version', etc with 'FormParams'. NFC.Xing GUO
This patch replaces 'Format', 'Version' fields, etc with 'FormParams' to simplify codes. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D84496
2020-07-24[DWARFYAML] Use writeDWARFOffset() to simplify emitting offsets. NFC.Xing GUO
This patch uses writeDWARFOffset() to simplify some codes. NFC.
2020-07-23[DWARFYAML] Refactor emitDebugInfo() to make the length be inferred.Xing GUO
This patch refactors `emitDebugInfo()` to make the length field be inferred from its content. Besides, the `Visitor` class is removed in this patch. The original `Visitor` class helps us determine an appropriate length and emit the .debug_info section. These two processes can be merged into one process. Besides, the length field should be inferred when it's missing rather than when it's zero. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D84008
2020-07-23[DWARFYAML] Pull out common helper functions for rnglist and loclist tables. ↵Xing GUO
NFC. This patch helps pull out some common helper functions for range list and location list tables. NFC. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D84383
2020-07-23[DWARFYAML] Refactor range list table to hold more data structure.Xing GUO
This patch refactors the range list table to hold both the range list table and the location list table. Reviewed By: jhenderson, labath Differential Revision: https://reviews.llvm.org/D84239
2020-07-20[DWARFYAML] Remove 'default' tag. NFC.Xing GUO
This patch is trying to make build bots happy. Failed bots: http://lab.llvm.org:8011/builders/ppc64le-lld-multistage-test/builds/10705 http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/33595
2020-07-20[DWARFYAML] Implement the .debug_rnglists section.Xing GUO
This patch implements the .debug_rnglists section. We are able to produce the .debug_rnglists section by the following syntax. ``` debug_rnglists: - Format: DWARF32 ## Optional Length: 0x1234 ## Optional Version: 5 ## Optional AddressSize: 0x08 ## Optional SegmentSelectorSize: 0x00 ## Optional OffsetEntryCount: 2 ## Optional Offsets: [1, 2] ## Optional Lists: - Entries: - Operator: DW_RLE_base_address Values: [ 0x1234 ] ``` The generated .debug_rnglists is verified by llvm-dwarfdump, except for the operator DW_RLE_startx_endx, since llvm-dwarfdump doesn't support it. Reviewed By: jhenderson Differential Revision: https://reviews.llvm.org/D83624
2020-07-16[DWARFYAML] Implement the .debug_str_offsets section.Xing GUO
This patch helps add support for emitting the .debug_str_offsets section to yaml2elf. Reviewed By: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D83853