summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
AgeCommit message (Collapse)Author
2025-11-02[CodeGen] Remove redundant declarations (NFC) (#166105)Kazu Hirata
In C++17, static constexpr members are implicitly inline, so they no longer require an out-of-line definition. Identified with readability-redundant-declaration.
2024-11-03[AsmPrinter] Remove unused includes (NFC) (#114698)Kazu Hirata
Identified with misc-include-cleaner.
2024-08-04[CodeGen] Construct SmallVector with ArrayRef (NFC) (#101841)Kazu Hirata
2024-06-14[llvm] Use llvm::unique (NFC) (#95628)Kazu Hirata
2024-04-09[DWARF] Refactor .debug_names bucket count computation (#88087)Fangrui Song
`getDebugNamesBucketAndHashCount` lures users to provide an array to compute the bucket count using an O(n log n) sort. This is inefficient as hash table based uniquifying is faster. The performance issue matters less for Clang as the number of names is relatively small. For `ld.lld --debug-names`, I plan to compute the unique hash count as a side product of parallel entry pool computation, and I just need a function to suggest a bucket count.
2024-03-13[CodeGen][Tablegen] Fix uninitialized var and shift overflow. (#84896)mahesh-attarde
Fix uninitialized var and shift overflow.
2024-03-01[DWARF] Use std::tie after #83047. NFCFangrui Song
The code suggestion was neglected when the patch landed.
2024-02-26[LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. (#83047)cmtice
llvm::dwarf::getDebugNamesBucketCount directly returns the bucket count, via return statement, but it also returns the hash count via a parameter. This changes the function to return them both as a std::pair, in the return statement. It also changes the name of the function to make it clear it returns both values.
2024-02-21[LLVM][DWARF] Refactor code for generating DWARF V5 .debug_names (#82394)cmtice
[LLVM][DWARF] Refactor code for generating DWARF v5 .debug_names Refactor the code that uniques the entries and computes the bucket count for the DWARF V5 .debug_names accelerator table.
2024-02-15[LLVM][DWARF] Fix for memory leak (#81828)Alexander Yermolovich
This is followup to https://github.com/llvm/llvm-project/pull/8120. Missed a destuctor.
2024-02-14[LLVM][DWARF] Change .debug_names abbrev to be an index (#81200)Alexander Yermolovich
Based on the discussion in https://github.com/llvm/llvm-project/pull/80229 changed implementation to align with how .debug_abbrev is handled. So that .debug_names abbrev tag is a monotonically increasing index. This allows for tools like LLDB to access it in constant time using array like data structure. clang-19 debug build before change
 [41] .debug_names PROGBITS 0000000000000000 8f9e0350 137fdbe0 00 0 0 4 after change [41] .debug_names PROGBITS 0000000000000000 8f9e0350 125bfdec 00 0 0 4 Reduction ~19.1MB
2024-01-19[AsmPrinter][DebugNames] Implement DW_IDX_parent entries (#77457)Felipe de Azevedo Piovezan
This implements the ideas discussed in [1]. To summarize, this commit changes AsmPrinter so that it outputs DW_IDX_parent information for debug_name entries. It will enable debuggers to speed up queries for fully qualified types (based on a DWARFDeclContext) significantly, as debuggers will no longer need to parse the entire CU in order to inspect the parent chain of a DIE. Instead, a debugger can simply take the parent DIE offset from the accelerator table and peek at its name in the debug_info/debug_str sections. The implementation uses two types of DW_FORM for the DW_IDX_parent attribute: 1. DW_FORM_ref4, which points to the accelerator table entry for the parent. 2. DW_FORM_flag_present, when the entry has a parent that is not in the table (that is, the parent doesn't have a name, or isn't allowed to be in the table as per the DWARF spec). This is space-efficient, since it takes 0 bytes. The implementation works by: 1. Changing how abbreviations are encoded (so that they encode which form, if any, was used to encode IDX_Parent) 2. Creating an MCLabel per accelerator table entry, so that they may be referred by IDX_parent references. When all patches related to this are merged, we are able to show that evaluating an expression such as: ``` lldb --batch -o 'b CodeGenFunction::GenerateCode' -o run -o 'expr Fn' -- \ clang++ -c -g test.cpp -o /dev/null ``` is far faster: from ~5000 ms to ~1500ms. Building llvm-project + clang with and without this patch, and looking at its impact on object file size: ``` ls -la $(find build_stage2_Debug_idx_parent_assert_dwarf5 -name \*.cpp.o) | awk '{s+=$5} END {printf "%\047d\n", s}' 11,507,327,592 -la $(find build_stage2_Debug_no_idx_parent_assert_dwarf5 -name \*.cpp.o) | awk '{s+=$5} END {printf "%\047d\n", s}' 11,436,446,616 ``` That is, an increase of 0.62% in total object file size. Looking only at debug_names: ``` $stage1_build/bin/llvm-objdump --section-headers $(find build_stage2_Debug_idx_parent_assert_dwarf5 -name \*.cpp.o) | grep __debug_names | awk '{s+="0x"$3} END {printf "%\047d\n", s}' 440,772,348 $stage1_build/bin/llvm-objdump --section-headers $(find build_stage2_Debug_no_idx_parent_assert_dwarf5 -name \*.cpp.o) | grep __debug_names | awk '{s+="0x"$3} END {printf "%\047d\n", s}' 369,867,920 ``` That is an increase of 19%. DWARF Linkers need to be changed in order to support this. This commit already brings support to "base" linker, but it does not attempt to modify the parallel linker. Accelerator entries refer to the corresponding DIE offset, and this patch also requires the parent DIE offset -- it's not clear how the parallel linker can access this. It may be obvious to someone familiar with it, but it would be nice to get help from its authors. [1]: https://discourse.llvm.org/t/rfc-improve-dwarf-5-debug-names-type-lookup-parsing-speed/74151/
2024-01-08[AccelTable][nfc] Add helper function to cast AccelTableData (#77100)Felipe de Azevedo Piovezan
Specializations of AccelTableBase are always interested in accessing the derived versions of their data classes (e.g. DWARF5AccelTableData). They do so by sprinkling `static_casts` all over the code. This commit adds a helper function to simplify this process, reducinng the number of casts that have to be made in the middle of code, making it easier to read.
2024-01-05[AsmPrinter][Dwarf5][nfc] Remove template from AccelTable class (#76296)Felipe de Azevedo Piovezan
This template is no longer used.
2023-12-21[AccelTable][NFC] Fix typos and duplicated code (#76155)Felipe de Azevedo Piovezan
Renaming a member variable from "Endoding" to "Encoding". Also replace inlined code for "isNormalized" with a call to the function, so that if the definition of normalization ever changes, we only need to change the one place.
2023-12-04[LLVM][DWARF] Add support for .debug_names with split dwarf (#73872)Alexander Yermolovich
Enables Type Units with DWARF5 accelerator tables for split dwarf. It is still under discussion what is the best way to implement support for de-duplication in DWP. This will be in follow up PR.
2023-11-18[LLVM][DWARF] Add support for monolithic types in .debug_names (#70515)Alexander Yermolovich
Enable Type Units with DWARF5 accelerator tables for monolithic DWARF. Implementation relies on linker to tombstone offset in LocalTU list to -1 when it deduplciates type units using COMDAT.
2023-10-25[LLVM[NFC] Refactor to allow debug_names entries to conatain DIE offset (#69399)Alexander Yermolovich
This is pre-cursor patch to enabling type units with DWARF5 acceleration tables. With this change it allows for entries to contain offsets directly, this way type units do not need to be preserved until .debug_names is written out.
2023-10-13[llvm] Stop including llvm/ADT/StringMap.h (NFC)Kazu Hirata
These source files do not use StringMap.
2023-10-05Revert "[LLVM][DWARF] Add support for monolithic types in .debug_names (#68131)"Nico Weber
This reverts commit 9bbd2bf654634cd95dd0be7948ec8402c3c76e1e. Accidental commit: https://github.com/llvm/llvm-project/pull/68131#issuecomment-1749430207
2023-10-05[LLVM][DWARF] Add support for monolithic types in .debug_names (#68131)Alexander Yermolovich
Added support for Type Units in monolithic DWARF in .debug_names.
2023-09-27[DWARFLinkerParallel] Add support of accelerator tables to DWARFLinkerParallel.Alexey Lapshin
This patch is extracted from D96035, it adds support for the accelerator tables to the DWARFLinkerParallel functionality. Differential Revision: https://reviews.llvm.org/D154793
2023-07-19AccelTable: Use MapVector to stabilize iteration orderFangrui Song
Entries of the same DJB hash are in the hash lookup table/name table are ordered by the iteration order of `Entries` (a StringMap). Change `Entries` to a MapVector to stabilize the order and simplify future changes like D142862 that change the StringMap hash function.
2023-06-14[DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platformsJonas Devlieghere
On Apple platforms, we generate .apple_names, .apple_types, .apple_namespaces and .apple_objc Apple accelerator tables for DWARF 4 and earlier. For DWARF 5 we should generate .debug_names, but instead we get no accelerator tables at all. In the backend we are correctly determining that we should be emitting .debug_names instead of .apple_names. However, when we get to the point of emitting the section, if the CU debug name table kind is not "default", the accelerator table emission is skipped. This patch sets the DebugNameTableKind to Apple in the frontend when target an Apple target. That way we know that the CU was compiled with the intent of emitting accelerator tables. For DWARF 4 and earlier, that means Apple accelerator tables. For DWARF 5 and later, that means .debug names. Differential revision: https://reviews.llvm.org/D118754
2023-06-14Revert "[DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platforms"Jonas Devlieghere
This reverts commit e0d57295bf6a3c04f2901d9c70f529d570f48b65 because the accel-tables-apple.ll test is failing on a few buildbots.
2023-06-14[DebugInfo] Always emit `.debug_names` with DWARF 5 for Apple platformsJonas Devlieghere
On Apple platforms, we generate .apple_names, .apple_types, .apple_namespaces and .apple_objc Apple accelerator tables for DWARF 4 and earlier. For DWARF 5 we should generate .debug_names, but instead we get no accelerator tables at all. In the backend we are correctly determining that we should be emitting .debug_names instead of .apple_names. However, when we get to the point of emitting the section, if the CU debug name table kind is not "default", the accelerator table emission is skipped. This patch sets the DebugNameTableKind to Apple in the frontend when target an Apple target. That way we know that the CU was compiled with the intent of emitting accelerator tables. For DWARF 4 and earlier, that means Apple accelerator tables. For DWARF 5 and later, that means .debug names. Differential revision: https://reviews.llvm.org/D118754
2023-04-21Fix uninitialized scalar members in CodeGenAkshay Khadse
This change fixes some static code analysis warnings. Reviewed By: LuoYuanke Differential Revision: https://reviews.llvm.org/D148811
2022-11-24[Alignment][NFC] Use Align in MCStreamer::emitValueToAlignmentGuillaume Chatelet
Differential Revision: https://reviews.llvm.org/D138674
2022-07-17[CodeGen] Qualify auto variables in for loops (NFC)Kazu Hirata
2022-06-10[MC] De-capitalize SwitchSection. NFCFangrui Song
Add SwitchSection to return switchSection. The API will be removed soon.
2022-03-12Cleanup includes: DebugInfo & CodeGenserge-sans-paille
Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121332
2021-02-25[debug-info] refactor emitDwarfUnitLengthChen Zheng
remove `Hi` `Lo` argument from `emitDwarfUnitLength`, so we can make caller of emitDwarfUnitLength easier. Reviewed By: MaskRay, dblaikie, ikudrin Differential Revision: https://reviews.llvm.org/D96409
2021-02-10[AsmPrinter] Use range-based for loops (NFC)Kazu Hirata
2020-09-15[DebugInfo] Make offsets of dwarf units 64-bit (19/19).Igor Kudrin
In the case of LTO, several DWARF units can be emitted in one section. For an extremely large application, they may exceed the limit of 4GiB for 32-bit offsets. As it is now possible to emit 64-bit debugging info, the patch enables storing the larger offsets. Differential Revision: https://reviews.llvm.org/D87026
2020-09-15[DebugInfo] Fix emitting DWARF64 .debug_names sections (16/19).Igor Kudrin
The patch fixes emitting the unit length field in the header of the table and offsets to the entry pool. Note that while the patch changes the common method to emit offsets, in fact, nothing is changed for Apple accelerator tables, because we do not yet support DWARF64 for those targets. Differential Revision: https://reviews.llvm.org/D87023
2020-09-02[DebugInfo] Emit a 1-byte value as a terminator of entries list in the name ↵Igor Kudrin
index. As stated in section 6.1.1.2, DWARFv5, p. 142, | The last entry for each name is followed by a zero byte that | terminates the list. There may be gaps between the lists. The patch changes emitting a 4-byte zero value to a 1-byte one, which effectively removes the gap between entry lists, and thus saves approximately 3 bytes per name; the calculation is not exact because the total size of the table is aligned to 4. Differential Revision: https://reviews.llvm.org/D86927
2020-09-02[DebugInfo] Remove Dwarf5AccelTableWriter::Header::UnitLength. NFC.Igor Kudrin
The member is not in use; the unit length for the table is emitted as a difference between two labels. Moreover, the type of the member might be misleading, because for DWARF64 the field should be 64 bit long. Differential Revision: https://reviews.llvm.org/D86912
2020-02-14[MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex}Fangrui Song
2020-02-14[MC] De-capitalize another set of MCStreamer::Emit* functionsFangrui Song
Emit{ValueTo,Code}Alignment Emit{DTP,TP,GP}* EmitSymbolValue etc
2020-02-14[MC] De-capitalize some MCStreamer::Emit* functionsFangrui Song
2020-02-13[AsmPrinter] De-capitalize some AsmPrinter::Emit* functionsFangrui Song
Similar to rL328848.
2019-07-09[CodeGen] AccelTable - remove non-constexpr (MSVC) Atom defsSimon Pilgrim
Now that we've dropped VS2015 support (D64326) we can enable the constexpr variables on MSVC builds as VS2017+ correctly handles them llvm-svn: 365477
2019-04-23Reapply: "DebugInfo: Emit only one kind of accelerated access/name table""David Blaikie
Originally committed in r358931 Reverted in r358997 Seems this change made Apple accelerator tables miss names (because names started respecting the CU NameTableKind GNU & assuming that shouldn't produce accelerated names too), which is never correct (apple accelerator tables don't have separators or CU lists - if present, they must describe all names in all CUs). Original Description: Currently to opt in to debug_names in DWARFv5, the IR must contain 'nameTableKind: Default' which also enables debug_pubnames. Instead, only allow one of {debug_names, apple_names, debug_pubnames, debug_gnu_pubnames}. nameTableKind: Default gives debug_names in DWARFv5 and greater, debug_pubnames in v4 and earlier - and apple_names when tuning for lldb on MachO. nameTableKind: GNU always gives gnu_pubnames llvm-svn: 359026
2019-04-23Revert "DebugInfo: Emit only one kind of accelerated access/name table"David Blaikie
Regresses some apple_names situations - still investigating. This reverts commit r358931. llvm-svn: 358997
2019-04-23Use llvm::stable_sortFangrui Song
While touching the code, simplify if feasible. llvm-svn: 358996
2019-04-22DebugInfo: Emit only one kind of accelerated access/name tableDavid Blaikie
Currently to opt in to debug_names in DWARFv5, the IR must contain 'nameTableKind: Default' which also enables debug_pubnames. Instead, only allow one of {debug_names, apple_names, debug_pubnames, debug_gnu_pubnames}. nameTableKind: Default gives debug_names in DWARFv5 and greater, debug_pubnames in v4 and earlier - and apple_names when tuning for lldb on MachO. nameTableKind: GNU always gives gnu_pubnames llvm-svn: 358931
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
2018-08-24DebugInfo: Fix skipping CUs in DWARFv5 debug_names tableDavid Blaikie
My previoust test case had skipped CUs from one TU out of a two-TU LTO scenario, which meant the CU index wasn't needed (as it was unambiguous which CU a table entry applied to) - expanding the test to use 3 TUs, skipping one (so long as it's not the last one) shows the indexes are miscomputed. Fix that with a little indirection for the index. llvm-svn: 340646
2018-08-16DebugInfo: Add metadata support for disabling DWARF pub sectionsDavid Blaikie
In cases where the debugger load time is a worthwhile tradeoff (or less costly - such as loading from a DWP instead of a variety of DWOs (possibly over a high-latency/distributed filesystem)) against object file size, it can be reasonable to disable pubnames and corresponding gdb-index creation in the linker. A backend-flag version of this was implemented for NVPTX in D44385/r327994 - which was fine for NVPTX which wouldn't mix-and-match CUs. Now that it's going to be a user-facing option (likely powered by "-gno-pubnames", the same as GCC) it should be encoded in the DICompileUnit so it can vary per-CU. After this, likely the NVPTX support should be migrated to the metadata & the previous flag implementation should be removed. Reviewers: aprantl Differential Revision: https://reviews.llvm.org/D50213 llvm-svn: 339939
2018-07-20Fix build breakage from r337562Pavel Labath
I changed a variable's type from pointer to reference, but forgot to update the assert-only code. llvm-svn: 337564