aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DIBuilder.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-11-08Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical ↵Vladislav Dzhidzhoev1-27/+10
block scopes (4/7)" This caused assert: llvm/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:110: void llvm::DwarfFile::addScopeVariable(LexicalScope *, DbgVariable *): Assertion `Ret.second' failed. See comments https://reviews.llvm.org/D144006#4656350. This reverts commit 3b449bd46a11a55a40cbc0016a99b202fa05248e.
2023-11-02[DebugMetadata][DwarfDebug] Support function-local types in lexical block ↵Vladislav Dzhidzhoev1-10/+27
scopes (4/7) RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Similar to imported declarations, the patch tracks function-local types in DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with the aforementioned metadata change and provided a support of function-local types scoped within a lexical block. The patch assumes that DICompileUnit's 'enums field' no longer tracks local types and DwarfDebug would assert if any locally-scoped types get placed there. Reviewed By: jmmartinez Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144006
2023-09-29Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical ↵Hans Wennborg1-27/+10
block scopes (4/7)" This caused asserts: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2331: virtual void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction *): Assertion `LScopes.getAbstractScopesList().size() == NumAbstractSubprograms && "getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed. See comment on the code review for reproducer. > RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 > > Similar to imported declarations, the patch tracks function-local types in > DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with > the aforementioned metadata change and provided a support of function-local > types scoped within a lexical block. > > The patch assumes that DICompileUnit's 'enums field' no longer tracks local > types and DwarfDebug would assert if any locally-scoped types get placed there. > > Reviewed By: jmmartinez > > Differential Revision: https://reviews.llvm.org/D144006 This reverts commit f8aab289b5549086062588fba627b0e4d3a5ab15.
2023-09-26[DebugMetadata][DwarfDebug] Support function-local types in lexical block ↵Vladislav Dzhidzhoev1-10/+27
scopes (4/7) RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Similar to imported declarations, the patch tracks function-local types in DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with the aforementioned metadata change and provided a support of function-local types scoped within a lexical block. The patch assumes that DICompileUnit's 'enums field' no longer tracks local types and DwarfDebug would assert if any locally-scoped types get placed there. Reviewed By: jmmartinez Differential Revision: https://reviews.llvm.org/D144006
2023-06-26[LLDB] Add DWARF definitions for the new Mojo languagewalter erquinigo1-1/+1
The new language Mojo recently received a proper DWARF code, which can be seen in https://dwarfstd.org/languages.html, and this patch adds the basic definitions for using this language in DWARF. Differential Revision: https://reviews.llvm.org/D153073
2023-06-25[llvm] Add missing StringExtras.h includesElliot Goodrich1-0/+2
In preparation for removing the `#include "llvm/ADT/StringExtras.h"` from the header to source file of `llvm/Support/Error.h`, first add in all the missing includes that were previously included transitively through this header.
2023-06-20Revert "Reland "[DebugMetadata][DwarfDebug] Support function-local types in ↵Vladislav Dzhidzhoev1-25/+9
lexical block scopes (4/7)" (2)" This reverts commit cb9ac7051589ea0d05507f9370d0716bef86b4ae. It causes an assert in clang: virtual void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction*): Assertion `LScopes.getAbstractScopesList().size() == NumAbstractSubprograms && "getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed. https://bugs.chromium.org/p/chromium/issues/detail?id=1456288#c2
2023-06-20Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical ↵Vladislav Dzhidzhoev1-9/+25
block scopes (4/7)" (2) Test "local-type-as-template-parameter.ll" is now enabled only for x86_64. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144006 Depends on D144005
2023-06-20Revert "Reland "[DebugMetadata][DwarfDebug] Support function-local types in ↵Vladislav Dzhidzhoev1-25/+9
lexical block scopes (4/7)"" This reverts commit 2da45172c4bcd42f704c57c656926f56f32fc5ce. Test local-type-as-template-parameter.ll fails on ppc64-aix.
2023-06-19Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical ↵Vladislav Dzhidzhoev1-9/+25
block scopes (4/7)" Test "local-type-as-template-parameter.ll" now requires linux-system. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144006 Depends on D144005
2023-06-19Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical ↵Vladislav Dzhidzhoev1-25/+9
block scopes (4/7)" This reverts commit 66511b401042f28c74d2ded3aac76d19a53bd7c4. llvm/test/DebugInfo/Generic/local-type-as-template-parameter.ll is broken.
2023-06-19[DebugMetadata][DwarfDebug] Support function-local types in lexical block ↵Vladislav Dzhidzhoev1-9/+25
scopes (4/7) RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Similar to imported declarations, the patch tracks function-local types in DISubprogram's 'retainedNodes' field. DwarfDebug is adjusted in accordance with the aforementioned metadata change and provided a support of function-local types scoped within a lexical block. The patch assumes that DICompileUnit's 'enums field' no longer tracks local types and DwarfDebug would assert if any locally-scoped types get placed there. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144006 Depends on D144005
2023-06-16Reland "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local ↵Vladislav Dzhidzhoev1-10/+10
imported entities (3/7)" Got rid of non-determinism in MetadataLoader.cpp. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144004
2023-06-15Revert "Reland "[DebugMetadata][DwarfDebug] Fix DWARF emisson of ↵Vladislav Dzhidzhoev1-10/+10
function-local imported entities (3/7)"" This reverts commit fcc3981626821addc6c77b98006d02030b8ceb7f, since Bitcode-upgrading code doesn't seem to be deterministic.
2023-06-15Reland "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local ↵Vladislav Dzhidzhoev1-10/+10
imported entities (3/7)" Run split-dwarf-local-impor3.ll only on x86_64-linux.
2023-06-15Revert "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local ↵Vladislav Dzhidzhoev1-10/+10
imported entities (3/7)" This reverts commit d80fdc6fc1a6e717af1bcd7a7313e65de433ba85. split-dwarf-local-impor3.ll fails because of an issue with Dwo sections emission on Windows platform.
2023-06-15[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported ↵Vladislav Dzhidzhoev1-10/+10
entities (3/7) RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Fixed PR51501 (tests from D112337). 1. Reuse of DISubprogram's 'retainedNodes' to track other function-local entities together with local variables and labels (this patch cares about function-local import while D144006 and D144008 use the same approach for local types and static variables). So, effectively this patch moves ownership of tracking local import from DICompileUnit's 'imports' field to DISubprogram's 'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout is considered unsupported (DwarfDebug would assert on such debug metadata). DICompileUnit's 'imports' field is supposed to track global imported declarations as it does before. This addresses various FIXMEs and simplifies the next part of the patch. 2. Postpone emission of function-local imported entities from `DwarfDebug::endFunctionImpl()` to `DwarfDebug::endModule()`. While in `DwarfDebug::endFunctionImpl()` we do not have all the information about a parent subprogram or a referring subprogram (whether a subprogram inlined or not), so we can't guarantee we emit an imported entity correctly and place it in a proper subprogram tree. So now, we just gather needed details about the import itself and its parent entity (either a Subprogram or a LexicalBlock) during processing in `DwarfDebug::endFunctionImpl()`, but all the real work is done in `DwarfDebug::endModule()` when we have all the required information to make proper emission. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144004
2023-06-15Revert "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local ↵Vladislav Dzhidzhoev1-10/+10
imported entities (3/7)" This reverts commit ed578f02cf44a52adde16647150e7421f3ef70f3. Tests llvm/test/DebugInfo/Generic/split-dwarf-local-import*.ll fail when x86_64 target is not registered.
2023-06-15[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported ↵Vladislav Dzhidzhoev1-10/+10
entities (3/7) RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Fixed PR51501 (tests from D112337). 1. Reuse of DISubprogram's 'retainedNodes' to track other function-local entities together with local variables and labels (this patch cares about function-local import while D144006 and D144008 use the same approach for local types and static variables). So, effectively this patch moves ownership of tracking local import from DICompileUnit's 'imports' field to DISubprogram's 'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout is considered unsupported (DwarfDebug would assert on such debug metadata). DICompileUnit's 'imports' field is supposed to track global imported declarations as it does before. This addresses various FIXMEs and simplifies the next part of the patch. 2. Postpone emission of function-local imported entities from `DwarfDebug::endFunctionImpl()` to `DwarfDebug::endModule()`. While in `DwarfDebug::endFunctionImpl()` we do not have all the information about a parent subprogram or a referring subprogram (whether a subprogram inlined or not), so we can't guarantee we emit an imported entity correctly and place it in a proper subprogram tree. So now, we just gather needed details about the import itself and its parent entity (either a Subprogram or a LexicalBlock) during processing in `DwarfDebug::endFunctionImpl()`, but all the real work is done in `DwarfDebug::endModule()` when we have all the required information to make proper emission. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144004
2023-06-15Revert "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local ↵Vladislav Dzhidzhoev1-10/+10
imported entities (3/7)" This reverts commit d04452d54829cd7af5b43d670325ffa755ab0030 since test llvm-project/llvm/test/Bitcode/DIImportedEntity_backward.ll is broken.
2023-06-15[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported ↵Vladislav Dzhidzhoev1-10/+10
entities (3/7) RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Fixed PR51501 (tests from D112337). 1. Reuse of DISubprogram's 'retainedNodes' to track other function-local entities together with local variables and labels (this patch cares about function-local import while D144006 and D144008 use the same approach for local types and static variables). So, effectively this patch moves ownership of tracking local import from DICompileUnit's 'imports' field to DISubprogram's 'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout is considered unsupported (DwarfDebug would assert on such debug metadata). DICompileUnit's 'imports' field is supposed to track global imported declarations as it does before. This addresses various FIXMEs and simplifies the next part of the patch. 2. Postpone emission of function-local imported entities from `DwarfDebug::endFunctionImpl()` to `DwarfDebug::endModule()`. While in `DwarfDebug::endFunctionImpl()` we do not have all the information about a parent subprogram or a referring subprogram (whether a subprogram inlined or not), so we can't guarantee we emit an imported entity correctly and place it in a proper subprogram tree. So now, we just gather needed details about the import itself and its parent entity (either a Subprogram or a LexicalBlock) during processing in `DwarfDebug::endFunctionImpl()`, but all the real work is done in `DwarfDebug::endModule()` when we have all the required information to make proper emission. Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com> Differential Revision: https://reviews.llvm.org/D144004
2023-06-12[DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)Vladislav Dzhidzhoev1-47/+28
RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Currently, `retainedNodes` tracks function-local variables and labels. To support function-local import, types and static variables (which are globals in LLVM IR), subsequent patches use the same field. So this patch makes preliminary refactoring of the code tracking local entities to apply future functional changes lucidly and cleanly. No functional changes intended. Differential Revision: https://reviews.llvm.org/D143984 Authored-by: Kristina Bessonova <kbessonova@accesssoftek.com>
2023-06-08Revert "[DebugMetadata] Simplify handling subprogram's retainedNodes field. ↵Vladislav Dzhidzhoev1-28/+47
NFCI (1/7)" This reverts commit 4418434c6de7a861e241ba2448ea4a12080cf08f. Reverted because it breaks tests of OCaml bindings.
2023-06-07[DebugMetadata] Simplify handling subprogram's retainedNodes field. NFCI (1/7)Kristina Bessonova1-47/+28
RFC https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544 Currently, `retainedNodes` tracks function-local variables and labels. To support function-local import, types and static variables (which are globals in LLVM IR), subsequent patches use the same field. So this patch makes preliminary refactoring of the code tracking local entities to apply future functional changes lucidly and cleanly. No functional changes intended. Differential Revision: https://reviews.llvm.org/D143984
2023-04-17[nfc][llvm] Replace pointer cast functions in PointerUnion by llvm casting ↵Shraiysh Vaishay1-10/+10
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-04-04[DebugInfo] don't make an MDTuple just to leak itJameson Nash1-2/+1
There does not seem to be any purpose to allocating this object, which is Metadata, so LLVM will simply leak it until the context is destroyed (the subprogram metadata it contains are distinct, so there is little chance of it being reused later). This should not have a functional change. This seems to be left over from an earlier design, when it used to call ``` CUNode->replaceSubprograms(SPs.get()); ``` here also. (removed in http://reviews.llvm.org/D19034) Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D147469
2023-03-02[DebugInfo] Remove `dbg.addr` from IRJ. Ryan Stinnett1-35/+2
Part of `dbg.addr` removal Discussed in https://discourse.llvm.org/t/what-is-the-status-of-dbg-addr/62898 Differential Revision: https://reviews.llvm.org/D144801
2022-12-16[llvm][DebugInfo] Add IsDefault parameter to ↵Michael Buch1-2/+3
DIBuilder::createTemplateTemplateParameter This is in preparation for Clang to emit `DW_AT_default_value` for defaulted template template parameters. Differential Revision: https://reviews.llvm.org/D139989
2022-12-06DebugInfo: Add support for new DWARFv5 language codesDavid Blaikie1-1/+1
2022-12-04DebugInfoMetadata: convert Optional to std::optionalKrzysztof Parzyszek1-5/+5
2022-12-02[IR] Use std::nullopt instead of None (NFC)Kazu Hirata1-16/+17
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-08[Assignment Tracking][6/*] Add trackAssignments functionOCHyams1-1/+31
The Assignment Tracking debug-info feature is outlined in this RFC: https://discourse.llvm.org/t/ rfc-assignment-tracking-a-better-way-of-specifying-variable-locations-in-ir Add trackAssignments which adds assignment tracking metadata to a function for a specified set of variables. The intended callers are the inliner and the front end - those calls will be added in separate patches. I've added a pass called declare-to-assign (AssignmentTrackingPass) that converts dbg.declare intrinsics to dbg.assigns using trackAssignments so that the function can be easily tested (see llvm/test/DebugInfo/Generic/track-assignments.ll). The pass could also be used by front ends to easily test out enabling assignment tracking. Reviewed By: jmorse Differential Revision: https://reviews.llvm.org/D132225
2022-11-03[DebugInfo][Metadata] Make AllEnumTypes holding TrackingMDNodeRefKristina Bessonova1-2/+4
Having AllEnumtypes to be a vector of TrackingMDNodeRef makes it possible to reflect changes in metadata in the vector if they took place before DIBuilder being finalized. Otherwise, we end up with heap-use-after-free because AllEnumTypes contains metadata that no longer valid. Consider a case where we have a class containing a definition of a enum, so this enum has the class as a scope. For some reason (doesn't matter for the current issue), we create a temporary debug metadata for this class, and then resolve it while finalizing CGDebugInfo. In the case of collision during uniqifying the temporary, we then need to replace its uses with a new pointer. If a temporary's user is unique (this is the enum mentioned above), we may need re-uniquefying it, which may return a new pointer in the case of another collision. If so, the pointer we stored in AllEnumTypes vector become dangling. Making AllEnumTypes hodling TrackingMDNodeRef should solve this problem (see debug-info-enum-metadata-collision.cpp test for details). Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D137067
2022-09-22[clang][DebugInfo] Emit access specifiers for typedefsJonathan Camilleri1-2/+2
The accessibility level of a typedef or using declaration in a struct or class was being lost when producing debug information. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D134339
2022-04-15[DebugInfo] Add a TargetFuncName field in DISubprogram forChih-Ping Chen1-2/+3
specifying DW_AT_trampoline as a string. Also update the signature of DIBuilder::createFunction to reflect this addition. Differential Revision: https://reviews.llvm.org/D123697
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
2022-02-11Adding DiBuilder interface for assumed length stringsYASHASVI KHATAVKAR1-0/+16
2022-02-10Reverting an entire stack of changes causing build failuresYASHASVI KHATAVKAR1-16/+0
2022-02-10updated local branch to incorporate latest changesYASHASVI KHATAVKAR1-2/+2
2022-02-10worked on review commentsYASHASVI KHATAVKAR1-1/+1
2022-02-10Updated the test to include addtional detailsYASHASVI KHATAVKAR1-3/+3
2022-02-10Added StringLocationExp to the new apisYASHASVI KHATAVKAR1-3/+5
2022-02-10Addressed review commentsYASHASVI KHATAVKAR1-4/+4
2022-02-10Adding DIBuilder interface for assumed length stringYASHASVI KHATAVKAR1-0/+14
2022-02-02Cleanup header dependencies in LLVMCoreserge-sans-paille1-2/+0
Based on the output of include-what-you-use. This is a big chunk of changes. It is very likely to break downstream code unless they took a lot of care in avoiding hidden ehader dependencies, something the LLVM codebase doesn't do that well :-/ I've tried to summarize the biggest change below: - llvm/include/llvm-c/Core.h: no longer includes llvm-c/ErrorHandling.h - llvm/IR/DIBuilder.h no longer includes llvm/IR/DebugInfo.h - llvm/IR/IRBuilder.h no longer includes llvm/IR/IntrinsicInst.h - llvm/IR/LLVMRemarkStreamer.h no longer includes llvm/Support/ToolOutputFile.h - llvm/IR/LegacyPassManager.h no longer include llvm/Pass.h - llvm/IR/Type.h no longer includes llvm/ADT/SmallPtrSet.h - llvm/IR/PassManager.h no longer includes llvm/Pass.h nor llvm/Support/Debug.h And the usual count of preprocessed lines: $ clang++ -E -Iinclude -I../llvm/include ../llvm/lib/IR/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l before: 6400831 after: 6189948 200k lines less to process is no that bad ;-) Discourse thread on the topic: https://llvm.discourse.group/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D118652
2022-01-19Fix modules build by moving implementation into .cpp fileAdrian Prantl1-0/+18
2022-01-18[debug-info] Add support for llvm.dbg.addr in DIBuilder.Michael Gottesman1-9/+30
I based this off of the API already create for llvm.dbg.value since both intrinsics have the same arguments at the API level. I added some tests exercising the API a little as well as an additional small test that shows how one can use llvm.dbg.addr to limit the PC range where an address value is available in the debugger. This is done by calling llvm.dbg.value with undef and the same metadata info as one used to create the llvm.dbg.addr. rdar://83957028 Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D117442
2021-12-27[clang][CodeGen] Remove the signed version of createExpressionShao-Ce SUN1-6/+0
Fix a TODO. Remove the callers of this signed version and delete. Reviewed By: CodaFi Differential Revision: https://reviews.llvm.org/D116014
2021-12-08[llvm] Use range-based for loops (NFC)Kazu Hirata1-4/+4
2021-11-29[DebugInfo] Do not replace existing nodes from DICompileUnitEllis Hoag1-1/+14
When creating a new DIBuilder with an existing DICompileUnit, load the DINodes from the current DICompileUnit so they don't get overwritten. This is done in the MachineOutliner pass, but it didn't change the CU so the bug never appeared. We need this if we ever want to add DINodes to the CU after it has been created, e.g., DIGlobalVariables. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D114556