aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-11-03[AsmPrinter] Remove unused includes (NFC) (#114698)Kazu Hirata1-1/+0
Identified with misc-include-cleaner.
2024-08-04[CodeGen] Construct SmallVector with ArrayRef (NFC) (#101841)Kazu Hirata1-1/+1
2024-06-14[llvm] Use llvm::unique (NFC) (#95628)Kazu Hirata1-3/+1
2024-04-09[DWARF] Refactor .debug_names bucket count computation (#88087)Fangrui Song1-4/+3
`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-attarde1-1/+2
Fix uninitialized var and shift overflow.
2024-03-01[DWARF] Use std::tie after #83047. NFCFangrui Song1-3/+2
The code suggestion was neglected when the patch landed.
2024-02-26[LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. (#83047)cmtice1-1/+3
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)cmtice1-12/+2
[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 Yermolovich1-1/+4
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 Yermolovich1-80/+50
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 Piovezan1-14/+113
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 Piovezan1-6/+5
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 Piovezan1-37/+25
This template is no longer used.
2023-12-21[AccelTable][NFC] Fix typos and duplicated code (#76155)Felipe de Azevedo Piovezan1-2/+2
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 Yermolovich1-10/+28
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 Yermolovich1-58/+117
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 Yermolovich1-13/+11
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 Hirata1-1/+0
These source files do not use StringMap.
2023-10-05Revert "[LLVM][DWARF] Add support for monolithic types in .debug_names (#68131)"Nico Weber1-112/+60
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 Yermolovich1-60/+112
Added support for Type Units in monolithic DWARF in .debug_names.
2023-09-27[DWARFLinkerParallel] Add support of accelerator tables to DWARFLinkerParallel.Alexey Lapshin1-6/+9
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 Song1-3/+3
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 Devlieghere1-2/+6
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 Devlieghere1-6/+2
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 Devlieghere1-2/+6
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 Khadse1-2/+2
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 Chatelet1-1/+1
Differential Revision: https://reviews.llvm.org/D138674
2022-07-17[CodeGen] Qualify auto variables in for loops (NFC)Kazu Hirata1-6/+6
2022-06-10[MC] De-capitalize SwitchSection. NFCFangrui Song1-1/+1
Add SwitchSection to return switchSection. The API will be removed soon.
2022-03-12Cleanup includes: DebugInfo & CodeGenserge-sans-paille1-1/+0
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 Zheng1-10/+7
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 Hirata1-3/+3
2020-09-15[DebugInfo] Make offsets of dwarf units 64-bit (19/19).Igor Kudrin1-0/+4
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 Kudrin1-4/+3
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 Kudrin1-1/+1
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 Kudrin1-1/+0
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 Song1-1/+1
2020-02-14[MC] De-capitalize another set of MCStreamer::Emit* functionsFangrui Song1-8/+8
Emit{ValueTo,Code}Alignment Emit{DTP,TP,GP}* EmitSymbolValue etc
2020-02-14[MC] De-capitalize some MCStreamer::Emit* functionsFangrui Song1-1/+1
2020-02-13[AsmPrinter] De-capitalize some AsmPrinter::Emit* functionsFangrui Song1-11/+11
Similar to rL328848.
2019-07-09[CodeGen] AccelTable - remove non-constexpr (MSVC) Atom defsSimon Pilgrim1-20/+0
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 Blaikie1-2/+2
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 Blaikie1-2/+2
Regresses some apple_names situations - still investigating. This reverts commit r358931. llvm-svn: 358997
2019-04-23Use llvm::stable_sortFangrui Song1-8/+7
While touching the code, simplify if feasible. llvm-svn: 358996
2019-04-22DebugInfo: Emit only one kind of accelerated access/name tableDavid Blaikie1-2/+2
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 Carruth1-4/+3
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 Blaikie1-2/+5
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 Blaikie1-0/+10
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 Labath1-3/+3
I changed a variable's type from pointer to reference, but forgot to update the assert-only code. llvm-svn: 337564
2018-07-20DwarfDebug: Reduce duplication in addAccel*** methodsPavel Labath1-3/+3
Summary: Each of the four methods had a dozen lines and was doing almost exactly the same thing: get the appropriate accelerator table kind and insert an entry into it. I move this common logic to a helper function and make these methods delegate to it. This came up in the context of D49493, where I've needed to make adding a string to a string pool slightly more complicated, and it seemed to make sense to do it in one place instead of five. To make this work I've needed to unify the interface of the AccelTable data types, as some used to store DIE& and others DIE*. I chose to unify to a reference as that's what the caller uses. This technically isn't NFC, because it changes the StringPool used for apple tables in the DWO case (now it uses the main file like DWARF v5 instead of the DWO file). However, that shouldn't matter, as DWO is not a thing on apple targets (clang frontend simply ignores -gsplit-dwarf). Reviewers: JDevlieghere, aprantl, probinson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49542 llvm-svn: 337562