summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/DIE.cpp
AgeCommit message (Collapse)Author
2025-06-28CSKY: Replace deprecated MCExpr::print with MCAsmInfo::printExprFangrui Song
2025-06-28MC: Migrate away from operator<< MCExprFangrui Song
MCExpr::print has an optional MCAsmInfo argument, which is error-prone when omitted. MCExpr::print and the convenience helper operator<< are discouraged to use. Switch to MCAsmInfo::printExpr instead. Use the target-specific MCAsmInfo if available.
2024-06-26[CodeGen] Use range-based for loops (NFC) (#96777)Kazu Hirata
2023-04-17[nfc][llvm] Replace pointer cast functions in PointerUnion by llvm casting ↵Shraiysh Vaishay
functions. This patch replaces the uses of PointerUnion.is function by llvm::isa, PointerUnion.get function by llvm::cast, and PointerUnion.dyn_cast by llvm::dyn_cast_if_present. This is according to the FIXME in the definition of the class PointerUnion. This patch does not remove them as they are being used in other subprojects. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D148449
2023-02-10[DebugInfo] Handle missed DW_FORM_addrx3 and DW_FORM_strx3 casesBenjamin Maxwell
This fixes a few places where the addrx3 and strx3 forms were missed. Previously this meant if one of these forms appeared somewhere various errors could occur. This now also adds an extra test case for the addrx3 form (which previously failed). Differential Revision: https://reviews.llvm.org/D143488
2023-01-16This patch allows llvm-dwarfutil to utilize accelerator tablesAlexey Lapshin
generation code from DWARFLinker. It adds command line option: --build-accelerator [none,DWARF] Build accelerator tables(default: none) =none - Do not build accelerators =DWARF - Build accelerator tables according to the resulting DWARF version DWARFv4: .debug_pubnames and .debug_pubtypes DWARFv5: .debug_names Differential Revision: https://reviews.llvm.org/D139638
2022-12-05[DebugInfo] llvm::Optional => std::optionalFangrui Song
https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-06-10[MC] De-capitalize SwitchSection. NFCFangrui Song
Add SwitchSection to return switchSection. The API will be removed soon.
2022-06-07[MC] De-capitalize MCStreamer functionsFangrui Song
Follow-up to c031378ce01b8485ba0ef486654bc9393c4ac024 . The class is mostly consistent now.
2022-03-12[DebugInfo] Include DW_TAG_skeleton_unit when looking for parent UnitDieWenlei He
`DIE::getUnitDie` looks up parent DIE until compile unit or type unit is found. However for skeleton CU with debug fission, we would have DW_TAG_skeleton_unit instead of DW_TAG_compile_unit as top level DIE. This change fixes the look up so we can get DW_TAG_skeleton_unit as UnitDie for skeleton CU. Differential Revision: https://reviews.llvm.org/D120610
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
2022-01-30[CodeGen] Use default member initialization (NFC)Kazu Hirata
Identified with modernize-use-default-member-init.
2022-01-12[CodeGen][Debuginfo][NFC] Refactor DIE values SizeOf method to not depend on ↵Alexey Lapshin
AsmPrinter. SizeOf() method of DIE values(unsigned SizeOf(const AsmPrinter *AP, dwarf::Form Form) const) depends on AsmPrinter. AsmPrinter is too specific class here. This patch removes dependency on AsmPrinter and use dwarf::FormParams structure instead. It allows calculate DIE values size without using AsmPrinter. That refactoring is useful for D96035([dsymutil][DWARFlinker] implement separate multi-thread processing for compile units.) Differential Revision: https://reviews.llvm.org/D116997
2021-01-28DebugInfo: Add a DWARF FORM extension for addrx+offset references to reduce ↵David Blaikie
relocations This is an alternative to the use of complex DWARF expressions for addresses - shaving off a few extra bytes of expression overhead.
2021-01-27DebugInfo: Deduplicate addresses in debug_addrDavid Blaikie
Experimental, using non-existent DWARF support to use an expr for the location involving an addr_index (to compute address + offset so addresses can be reused in more places). The global variable debug info had to be deferred until the end of the module (so bss variables would all be emitted first - so their labels would have the relevant section). Non-bss variables seemed to not have their label assigned to a section even at the end of the module, so I didn't know what to do there. Also, the hashing code is broken - doesn't know how to hash these expressions (& isn't hashing anything inside subprograms, which seems problematic), so for test purposes this change just skips the hash computation. (GCC's actually overly sensitive in its hash function, it seems - I'm forgetting the specific case right now - anyway, we might want to just use the frontend-known file hash and give up on optimistic .dwo/.dwp reuse)
2020-09-17[DebugInfo] Simplify DIEInteger::SizeOf().Igor Kudrin
An AsmPrinter should always be provided to the method because some forms depend on its parameters. The only place in the codebase which passed a nullptr value was found in the unit tests, so the patch updates it to use some dummy AsmPrinter instead. Differential Revision: https://reviews.llvm.org/D85293
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] Use a common method to determine a suitable form for section ↵Igor Kudrin
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
2020-09-15[DebugInfo] Fix emitting DWARF64 compilation units (5/19).Igor Kudrin
The patch also adds a method to choose an appropriate DWARF form to represent section offsets according to the version and the format of producing debug info. Differential Revision: https://reviews.llvm.org/D87014
2020-09-15[DebugInfo] Fix DIE value emitters to be compatible with DWARF64 (2/19).Igor Kudrin
DW_FORM_sec_offset and DW_FORM_strp imply values of different sizes with DWARF32 and DWARF64. The patch fixes DIE value classes to use correct sizes when emitting their values. For DIELocList it ensures that the requested DWARF form matches the current DWARF format because that class uses a method that selects the size automatically. Differential Revision: https://reviews.llvm.org/D87009
2020-08-07[DebugInfo] Clean up DIEUnit. NFC.Igor Kudrin
This removes members of the DIEUnit class which were used only in unit tests. Note also that child classes shadowed some of these methods, namely, getDwarfVersion() was overridden in DwartfUnit and getLength() was overridden in DwarfCompileUnit. Differential Revision: https://reviews.llvm.org/D85436
2020-08-03[DebugInfo] Make DIEDelta::SizeOf() more explicit. NFCI.Igor Kudrin
The patch restricts DIEDelta::SizeOf() to accept only DWARF forms that are actually used in the LLVM codebase. This should make the use of the class more explicit and help to avoid issues similar to fixed in D83958 and D84094. Differential Revision: https://reviews.llvm.org/D84095
2020-08-03[DebugInfo] Fix misleading using of DWARF forms with DIELabel. NFCI.Igor Kudrin
DIELabel can emit only 32- or 64-bit values, while it was created in some places with DW_FORM_udata, which implies emitting uleb128. Nevertheless, these places also expected to emit U32 or U64, but just used a misleading DWARF form. The patch updates those places to use more appropriate DWARF forms and restricts DIELabel::SizeOf() to accept only forms that are actually used in the LLVM codebase. Differential Revision: https://reviews.llvm.org/D84094
2020-08-03[DebugInfo] Make DIELocList::SizeOf() more explicit. NFCI.Igor Kudrin
DIELocList is used with a limited number of DWARF forms, see the only place where it is instantiated, DwarfCompileUnit::addLocationList(). The patch marks the unexpected execution path in DIELocList::SizeOf() as unreachable, to reduce ambiguity. Differential Revision: https://reviews.llvm.org/D84092
2020-07-17[DebugInfo] Fix a misleading usage of DWARF forms with DIEExpr. NFCI.Igor Kudrin
For now, DIEExpr is used only in two places: 1) in the debug info library unit test suite to emit a DW_AT_str_offsets_base attribute with the DW_FORM_sec_offset form, see dwarfgen::DIE::addStrOffsetsBaseAttribute(); 2) in DwarfCompileUnit::addLocationAttribute() to generate the location attribute for a TLS variable. The later case used an incorrect DWARF form of DW_FORM_udata, which implies storing an uleb128 value, not a 4/8 byte constant. The generated result was as expected because DIEExpr::SizeOf() did not handle the used form, but returned the size of the code pointer by default. The patch fixes the issue by using more appropriate DWARF forms for the problematic case and making DIEExpr::SizeOf() more straightforward. Differential Revision: https://reviews.llvm.org/D83958
2020-02-14[MCStreamer] De-capitalize EmitValue EmitIntValue{,InHex}Fangrui Song
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-12-05[DWARF5][Debuginfo] Compilation unit type (DW_UT_skeleton) and root DIE ↵Alexey Lapshin
(DW_TAG_compile_unit) do not match. That patch fixes incompatible compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) error. cat split-dwarf.cpp int main() { int a = 1; return 0; } clang++ -O -g -gsplit-dwarf -gdwarf-5 split-dwarf.cpp; llvm-dwarfdump --verify ./a.out | grep skeleton error: Compilation unit type (DW_UT_skeleton) and root DIE (DW_TAG_compile_unit) do not match. The fix is to change DW_TAG_compile_unit into DW_TAG_skeleton_unit when skeleton file is generated. Differential Revision: https://reviews.llvm.org/D70880
2019-11-15DebugInfo: Use loclistx for DWARFv5 location lists to reduce the number of ↵David Blaikie
relocations This only implements the non-dwo part, but loclistx is necessary to use location lists in DWARFv5, so it's a precursor to that work - and generally reduces relocations (only using one reloc, then indexes/relative offsets for all location list references) in non-split DWARF.
2019-03-19[DebugInfo] Introduce DW_OP_LLVM_convertMarkus Lavin
Introduce a DW_OP_LLVM_convert Dwarf expression pseudo op that allows for a convenient way to perform type conversions on the Dwarf expression stack. As an additional bonus it paves the way for using other Dwarf v5 ops that need to reference a base_type. The new DW_OP_LLVM_convert is used from lib/Transforms/Utils/Local.cpp to perform sext/zext on debug values but mainly the patch is about preparing terrain for adding other Dwarf v5 ops that need to reference a base_type. For Dwarf v5 the op maps to DW_OP_convert and for earlier versions a complex shift & mask pattern is generated to emulate sext/zext. This is a recommit of r356442 with trivial fixes for the failing tests. Differential Revision: https://reviews.llvm.org/D56587 llvm-svn: 356451
2019-03-19Revert "[DebugInfo] Introduce DW_OP_LLVM_convert"Markus Lavin
This reverts commit 1cf4b593a7ebd666fc6775f3bd38196e8e65fafe. Build bots found failing tests not detected locally. Failing Tests (3): LLVM :: DebugInfo/Generic/convert-debugloc.ll LLVM :: DebugInfo/Generic/convert-inlined.ll LLVM :: DebugInfo/Generic/convert-linked.ll llvm-svn: 356444
2019-03-19[DebugInfo] Introduce DW_OP_LLVM_convertMarkus Lavin
Introduce a DW_OP_LLVM_convert Dwarf expression pseudo op that allows for a convenient way to perform type conversions on the Dwarf expression stack. As an additional bonus it paves the way for using other Dwarf v5 ops that need to reference a base_type. The new DW_OP_LLVM_convert is used from lib/Transforms/Utils/Local.cpp to perform sext/zext on debug values but mainly the patch is about preparing terrain for adding other Dwarf v5 ops that need to reference a base_type. For Dwarf v5 the op maps to DW_OP_convert and for earlier versions a complex shift & mask pattern is generated to emulate sext/zext. Differential Revision: https://reviews.llvm.org/D56587 llvm-svn: 356442
2019-02-27[DebugInfo] Apply subprogram attributes on behalf of owner CUEugene Leviant
When using full LTO it is possible that template function definition DIE is bound to one compilation unit and it's declaration to another. We should add function declaration attributes on behalf of its owner CU otherwise we may end up with malformed file identifier in function declaration DW_AT_decl_file attribute. Differential revision: https://reviews.llvm.org/D58538 llvm-svn: 354978
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-11-28[DebugInfo] Rename EmitDebugThreadLocal back to EmitDebugValue. NFCSimon Atanasyan
This reverts r294500. DwarfCompileUnit::addAddressExpr uses DIEExpr for PCOffset. In that case the expression is unrelated to thread locals and so emitting a value of the DIEExpr does not have to always mean emit-debug-thread-local. llvm-svn: 347744
2018-10-24[DEBUGINFO, NVPTX] Try to pack bytes data into a single string.Alexey Bataev
Summary: If the target does not support `.asciz` and `.ascii` directives, the strings are represented as bytes and each byte is placed on the new line as a separate byte directive `.b8 <data>`. NVPTX target allows to represent the vector of the data of the same type as a vector, where values are separated using `,` symbol: `.b8 <data1>,<data2>,...`. This allows to reduce the size of the final PTX file. Ptxas tool includes ptx files into the resulting binary object, so reducing the size of the PTX file is important. Reviewers: tra, jlebar, echristo Subscribers: jholewinski, llvm-commits Differential Revision: https://reviews.llvm.org/D45822 llvm-svn: 345142
2018-10-20DebugInfo: Use address pool forms in debug_rnglistsDavid Blaikie
Save no relocations by reusing addresses from the address pool. llvm-svn: 344836
2018-10-20DebugInfo: Use debug_addr for non-dwo addresses in DWARF 5David Blaikie
Putting addresses in the address pool, even with non-fission, can reduce relocations - reusing the addresses from debug_info and debug_rnglists (the latter coming soon) llvm-svn: 344834
2018-05-14Rename DEBUG macro to LLVM_DEBUG.Nicola Zaghen
The DEBUG() macro is very generic so it might clash with other projects. The renaming was done as follows: - git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g' - git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM - Manual change to APInt - Manually chage DOCS as regex doesn't match it. In the transition period the DEBUG() macro is still present and aliased to the LLVM_DEBUG() one. Differential Revision: https://reviews.llvm.org/D43624 llvm-svn: 332240
2018-04-30IWYU for llvm-config.h in llvm, additions.Nico Weber
See r331124 for how I made a list of files missing the include. I then ran this Python script: for f in open('filelist.txt'): f = f.strip() fl = open(f).readlines() found = False for i in xrange(len(fl)): p = '#include "llvm/' if not fl[i].startswith(p): continue if fl[i][len(p):] > 'Config': fl.insert(i, '#include "llvm/Config/llvm-config.h"\n') found = True break if not found: print 'not found', f else: open(f, 'w').write(''.join(fl)) and then looked through everything with `svn diff | diffstat -l | xargs -n 1000 gvim -p` and tried to fix include ordering and whatnot. No intended behavior change. llvm-svn: 331184
2018-04-02[dsymutil] Upstream emitting of papertrail warnings.Jonas Devlieghere
When running dsymutil as part of your build system, it can be desirable for warnings to be part of the end product, rather than just being emitted to the output stream. This patch upstreams that functionality. Differential revision: https://reviews.llvm.org/D44639 llvm-svn: 328965
2018-03-29Style update. NFC.Rafael Espindola
Rename 3 functions to start with lowercase letters. Don't repeat the name in the comments. llvm-svn: 328848
2018-03-14Fix msvc compiler error in r327498Pavel Labath
msvc reports an "illegal indirection" error here. Attempt to appease it with a different initialization syntax. llvm-svn: 327500
2018-03-14Explicitly initialize dwarf::FormParams in DIEInteger::SizeOfPavel Labath
This could end up inititialized if someone called the function with a null AsmPrinter. Right now this only happens in DIEHash unit tests, presumably because it was hard to create an AsmPrinter in the context of unit tests. This only worked before r327486 because those tests did not use any dwarf forms whose size actually depended on the dwarf version (otherwise, they would have crashed due to null dereference). I fix the uninitialized error, by explicitly initializing FormParams to an invalid value, which will cause getFixedFormByteSize to return None if called with a form with version-dependent size. A more principled solution might be to fix the DIEHash tests to always pass in a valid AsmPrinter. llvm-svn: 327498
2018-03-14DWARF: Unify form size handling codePavel Labath
Summary: This patch replaces the two switches which are deducing the size of various forms with a single implementation. I have put the new implementation into BinaryFormat, to avoid introducing dependencies between the two independent libraries (DebugInfo and CodeGen) that need this functionality. Reviewers: aprantl, JDevlieghere, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44418 llvm-svn: 327486
2018-01-26[DWARF] Generate DWARF v5 string offsets tables along with strx* index forms.Wolfgang Pieb
Summary: This is the producer side for DWARF v5 string offsets tables. The reader/consumer side was committed with r321295. All compile and type units in a module share a contribution to the string offsets table. Indirect strings use the strx{1,2,3,4} index forms. Reviewers: dblaikie, aprantl, JDevliegehere Differential Revision: https://reviews.llvm.org/D42021 llvm-svn: 323546
2017-12-18Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header."Paul Robinson
Adds missing support for DW_FORM_data16. Update of r320852/r320886, fixing the unittest again, this time use a raw char string for the test data. Differential Revision: https://reviews.llvm.org/D41090 llvm-svn: 321011
2017-12-15Revert "Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header.""Paul Robinson
This reverts commit 0afef672f63f0e4e91938656bc73424a8c058bfc. Still failing at runtime on bots. llvm-svn: 320888
2017-12-15Recommit "[DWARFv5] Dump an MD5 checksum in the line-table header."Paul Robinson
Adds missing support for DW_FORM_data16. Update of r320852, fixing the unittest to use a hand-coded struct instead of std::array to guarantee data layout. Differential Revision: https://reviews.llvm.org/D41090 llvm-svn: 320886