aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/IR/MetadataTest.cpp
AgeCommit message (Collapse)AuthorFilesLines
2022-06-07Revert "[Metadata] Add a resize capability to MDNodes and add a push_back ↵Wolfgang Pieb1-124/+0
interface to MDNodes" This reverts commit e3f6eda8c6ebc567755377911746d4ca2367e649. Failure in unittest on https://lab.llvm.org/buildbot*builders/171/builds/15666
2022-06-07[Metadata] Add a resize capability to MDNodes and add a push_back interface ↵Wolfgang Pieb1-0/+124
to MDNodes A change to the allocation characteristics of MDNodes, introducing the ability to add operands one at a time. This functionality is restricted to MDTuples. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D125998
2022-05-23[NFC][Metadata] Define move constructor and move assignment operator for ↵Wolfgang Pieb1-0/+29
MDOperand. This is a preparatory patch for the MDNode resize functionality. Reviewed By: dexonsmith Differential Revision: https://reviews.llvm.org/D125994
2022-04-15[DebugInfo] Add a TargetFuncName field in DISubprogram forChih-Ping Chen1-20/+49
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
2021-11-14[NFC] Use Optional<ProfileCount> to model invalid countsMircea Trofin1-8/+9
ProfileCount could model invalid values, but a user had no indication that the getCount method could return bogus data. Optional<ProfileCount> addresses that, because the user must dereference the optional. In addition, the patch removes concept duplication. Differential Revision: https://reviews.llvm.org/D113839
2021-10-02[IR]PATCH 2/2: Add MDNode::printTree and dumpTreeMin-Yih Hsu1-0/+61
This patch adds the functionalities to print MDNode in tree shape. For example, instead of printing a MDNode like this: ``` <0x5643e1166888> = !DILocalVariable(name: "foo", arg: 2, scope: <0x5643e11c9740>, file: <0x5643e11c6ec0>, line: 8, type: <0x5643e11ca8e0>, flags: DIFlagPublic | DIFlagFwdDecl, align: 8) ``` The printTree/dumpTree functions can give you: ``` <0x5643e1166888> = !DILocalVariable(name: "foo", arg: 2, scope: <0x5643e11c9740>, file: <0x5643e11c6ec0>, line: 8, type: <0x5643e11ca8e0>, flags: DIFlagPublic | DIFlagFwdDecl, align: 8) <0x5643e11c9740> = distinct !DISubprogram(scope: null, spFlags: 0) <0x5643e11c6ec0> = distinct !DIFile(filename: "file.c", directory: "/path/to/dir") <0x5643e11ca8e0> = distinct !DIDerivedType(tag: DW_TAG_pointer_type, baseType: <0x5643e11668d8>, size: 1, align: 2) <0x5643e11668d8> = !DIBasicType(tag: DW_TAG_unspecified_type, name: "basictype") ``` Which is useful when using it in debugger. Where sometimes printing the whole module to see all MDNodes is too expensive. Differential Revision: https://reviews.llvm.org/D110113
2021-09-16[DebugInfo] Enhance DIImportedEntity to accept children entitiesAlok Kumar Sharma1-0/+19
New field `elements` is added to '!DIImportedEntity', representing list of aliased entities. This is needed to dump optimized debugging information where all names in a module are imported, but a few names are imported with overriding aliases. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D109343
2021-08-26[DebugInfo] generate btf_tag annotations for func parametersYonghong Song1-32/+43
Generate btf_tag annotations for function parameters. A field "annotations" is introduced to DILocalVariable, and annotations are represented as an DINodeArray, similar to DIComposite elements. The following example illustrates how annotations are encoded in IR: distinct !DILocalVariable(name: "info",, arg: 1, ..., annotations: !10) !10 = !{!11, !12} !11 = !{!"btf_tag", !"a"} !12 = !{!"btf_tag", !"b"} Differential Revision: https://reviews.llvm.org/D106620
2021-08-26[DebugInfo] generate btf_tag annotations for DIGlobalVariableYonghong Song1-15/+20
Generate btf_tag annotations for DIGlobalVariable. A field "annotations" is introduced to DIGlobalVariable, and annotations are represented as an DINodeArray, similar to DIComposite elements. The following example illustrates how annotations are encoded in IR: distinct !DIGlobalVariable(..., annotations: !10) !10 = !{!11, !12} !11 = !{!"btf_tag", !"a"} !12 = !{!"btf_tag", !"b"} Differential Revision: https://reviews.llvm.org/D106619
2021-08-05Add a DIExpression const-folder to prevent silly expressions.Paul Robinson1-0/+49
It's entirely possible (because it actually happened) for a bool variable to end up with a 256-bit DW_AT_const_value. This came about when a local bool variable was initialized from a bitfield in a 32-byte struct of bitfields, and after inlining and constant propagation, the variable did have a constant value. The sequence of optimizations had it carrying "i256" values around, but once the constant made it into the llvm.dbg.value, no further IR changes could affect it. Technically the llvm.dbg.value did have a DIExpression to reduce it back down to 8 bits, but the compiler is in no way ready to emit an oversized constant *and* a DWARF expression to manipulate it. Depending on the circumstances, we had either just the very fat bool value, or an expression with no starting value. The sequence of optimizations that led to this state did seem pretty reasonable, so the solution I came up with was to invent a DWARF constant expression folder. Currently it only does convert ops, but there's no reason it couldn't do other ops if that became useful. This broke three tests that depended on having convert ops survive into the DWARF, so I added an operator that would abort the folder to each of those tests. Differential Revision: https://reviews.llvm.org/D106915
2021-03-09[DebugInfo] Add replaceArg function to simplify DBG_VALUE_LIST expressionsgbtozers1-0/+28
The LiveDebugValues and LiveDebugVariables implementations for handling DBG_VALUE_LIST instructions can be simplified significantly if they do not have to deal with any duplicated operands, such as a DBG_VALUE_LIST that uses the same register multiple times in its expression. This patch adds a function, replaceArg, that can be used to simplify a DIExpression in the case of duplicated operands. Differential Revision: https://reviews.llvm.org/D83896
2021-03-05[DebugInfo] Add DIArgList MD to store multple values in DbgVariableIntrinsicsgbtozers1-0/+36
This patch adds a new metadata node, DIArgList, which contains a list of SSA values. This node is in many ways similar in function to the existing ValueAsMetadata node, with the difference being that it tracks a list instead of a single value. Internally, it uses ValueAsMetadata to track the individual values, but there is also a reasonable amount of DIArgList-specific value-tracking logic on top of that. Similar to ValueAsMetadata, it is a special case in parsing and printing due to the fact that it requires a function state (as it may reference function-local values). This patch should not result in any immediate functional change; it allows for DIArgLists to be parsed and printed, but debug variable intrinsics do not yet recognize them as a valid argument (outside of parsing). Differential Revision: https://reviews.llvm.org/D88175
2020-12-18[DebugInfo] Support Fortran 'use <external module>' statement.Chih-Ping Chen1-9/+13
The main change is to add a 'IsDecl' field to DIModule so that when IsDecl is set to true, the debug info entry generated for the module would be marked as a declaration. That way, the debugger would look up the definition of the module in the gloabl scope. Please see the comments in llvm/test/DebugInfo/X86/dimodule.ll for what the debug info entries would look like. Differential Revision: https://reviews.llvm.org/D93462
2020-10-29[DebugInfo] Support for DW_TAG_generic_subrangeAlok Kumar Sharma1-0/+146
This is needed to support fortran assumed rank arrays which have runtime rank. Summary: Fortran assumed rank arrays have dynamic rank. DWARF TAG DW_TAG_generic_subrange is needed to support that. Testing: unit test cases added (hand-written) check llvm check debug-info Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D89218
2020-10-10[DebugInfo] Support for DWARF attribute DW_AT_rankAlok Kumar Sharma1-0/+48
This patch adds support for DWARF attribute DW_AT_rank. Summary: Fortran assumed rank arrays have dynamic rank. DWARF attribute DW_AT_rank is needed to support that. Testing: unit test cases added (hand-written) check llvm check debug-info Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D89141
2020-05-28[DebugInfo] Upgrade DISubrange to support Fortran dynamic arraysAlok Kumar Sharma1-3/+136
This patch upgrades DISubrange to support fortran requirements. Summary: Below are the updates/addition of fields. lowerBound - Now accepts signed integer or DIVariable or DIExpression, earlier it accepted only signed integer. upperBound - This field is now added and accepts signed interger or DIVariable or DIExpression. stride - This field is now added and accepts signed interger or DIVariable or DIExpression. This is required to describe bounds of array which are known at runtime. Testing: unit test cases added (hand-written) check clang check llvm check debug-info Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D80197
2020-05-15[DebugInfo] support for DW_AT_data_location in llvmAlok Kumar Sharma1-0/+63
This patch adds support for DWARF attribute DW_AT_data_location. Summary: Dynamic arrays in fortran are described by array descriptor and data allocation address. Former is mapped to DW_AT_location and later is mapped to DW_AT_data_location. Testing: unit test cases added (hand-written) check llvm check debug-info Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D79592
2020-05-13[DebugInfo] Fortran module DebugInfo support in LLVMSourabh Singh Tomar1-13/+22
This patch extends DIModule Debug metadata in LLVM to support Fortran modules. DIModule is extended to contain File and Line fields, these fields will be used by Flang FE to create debug information necessary for representing Fortran modules at IR level. Furthermore DW_TAG_module is also extended to contain these fields. If these fields are missing, debuggers like GDB won't be able to show Fortran modules information correctly. Reviewed By: aprantl Differential Revision: https://reviews.llvm.org/D79484
2020-04-18[DebugInfo] Change DIEnumerator payload type from int64_t to APIntLemonBoy1-1/+10
This allows the representation of arbitrarily large enumeration values. See https://lists.llvm.org/pipermail/llvm-dev/2017-December/119475.html for context. Reviewed By: andrewrk, aprantl, MaskRay Differential Revision: https://reviews.llvm.org/D62475
2020-03-11Add debug info support for Swift/Clang APINotes.Adrian Prantl1-6/+15
In order for dsymutil to collect .apinotes files (which capture attributes such as nullability, Swift import names, and availability), I want to propose adding an apinotes: field to DIModule that gets translated into a DW_AT_LLVM_apinotes (path) nested inside DW_TAG_module. This will be primarily used by LLDB to indirectly extract the Swift names of Clang declarations that were deserialized from DWARF. <rdar://problem/59514626> Differential Revision: https://reviews.llvm.org/D75585
2020-03-11Add an SDK attribute to DICompileUnitAdrian Prantl1-3/+7
This is part of PR44213 https://bugs.llvm.org/show_bug.cgi?id=44213 When importing (system) Clang modules, LLDB needs to know which SDK (e.g., MacOSX, iPhoneSimulator, ...) they came from. While the sysroot attribute contains the absolute path to the SDK, this doesn't work well when the debugger is run on a different machine than the compiler, and the SDKs are installed in different directories. It thus makes sense to just store the name of the SDK instead of the absolute path, so it can be found relative to LLDB. rdar://problem/51645582 Differential Revision: https://reviews.llvm.org/D75646
2020-03-02Reland "[DebugInfo][clang][DWARF5]: Added support for debuginfo generation ↵Awanish Pandey1-13/+22
for defaulted parameters in C++ templates." This was reverted in 802b22b5c8c30bebc1695a217478be02653c6b53 due to missing .bc file and a chromium bot failure. https://bugs.chromium.org/p/chromium/issues/detail?id=1057559#c1 This revision address both of them. Summary: This patch adds support for debuginfo generation for defaulted parameters in clang and also extends corresponding DebugMetadata/IR to support this feature. Reviewers: probinson, aprantl, dblaikie Reviewed By: aprantl, dblaikie Differential Revision: https://reviews.llvm.org/D73462
2020-03-02Revert "[DebugInfo][clang][DWARF5]: Added support for debuginfo generation ↵Hans Wennborg1-22/+13
for defaulted parameters" The Bitcode/DITemplateParameter-5.0.ll test is failing: FAIL: LLVM :: Bitcode/DITemplateParameter-5.0.ll (5894 of 36324) ******************** TEST 'LLVM :: Bitcode/DITemplateParameter-5.0.ll' FAILED ******************** Script: -- : 'RUN: at line 1'; /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/llvm-dis -o - /usr/local/google/home/thakis/src/llvm-project/llvm/test/Bitcode/DITemplateParameter-5.0.ll.bc | /usr/local/google/home/thakis/src/llvm-project/out/gn/bin/FileCheck /usr/local/google/home/thakis/src/llvm-project/llvm/test/Bitcode/DITemplateParameter-5.0.ll -- Exit Code: 2 Command Output (stderr): -- It looks like the Bitcode/DITemplateParameter-5.0.ll.bc file was never checked in. This reverts commit c2b437d53d40b6dc5603c97f527398f477d9c5f1.
2020-03-02[DebugInfo][clang][DWARF5]: Added support for debuginfo generation for ↵Awanish Pandey1-13/+22
defaulted parameters in C++ templates. Summary: This patch adds support for debuginfo generation for defaulted parameters in clang and also extends corresponding DebugMetadata/IR to support this feature. Reviewers: probinson, aprantl, dblaikie Reviewed By: aprantl, dblaikie Differential Revision: https://reviews.llvm.org/D73462
2020-01-17Move the sysroot attribute from DIModule to DICompileUnitAdrian Prantl1-19/+13
[this re-applies c0176916a4824812d25a5a22c4ff7c95857b0cd6 with the correct commit message and phabricator link] This addresses point 1 of PR44213. https://bugs.llvm.org/show_bug.cgi?id=44213 The DW_AT_LLVM_sysroot attribute is used for Clang module debug info, to allow LLDB to import a Clang module from source. Currently it is part of each DW_TAG_module, however, it is the same for all modules in a compile unit. It is more efficient and less ambiguous to store it once in the DW_TAG_compile_unit. This should have no effect on DWARF consumers other than LLDB. Differential Revision: https://reviews.llvm.org/D71732
2020-01-17Revert "Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysroot"Adrian Prantl1-13/+19
This reverts commit 12e479475a896f664fb721f98c2d6805185ac352. I accidentally landed this patch with the wrong commit message ...
2020-01-17Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysrootAdrian Prantl1-19/+13
This is a purely cosmetic change that is NFC in terms of the binary output. I bugs me that I called the attribute DW_AT_LLVM_isysroot since the "i" is an artifact of GCC command line option syntax (-isysroot is in the category of -i options) and doesn't carry any useful information otherwise. This attribute only appears in Clang module debug info. Differential Revision: https://reviews.llvm.org/D71722
2019-12-20Rename DW_AT_LLVM_isysroot to DW_AT_LLVM_sysrootAdrian Prantl1-1/+1
This is a purely cosmetic change that is NFC in terms of the binary output. I bugs me that I called the attribute DW_AT_LLVM_isysroot since the "i" is an artifact of GCC command line option syntax (-isysroot is in the category of -i options) and doesn't carry any useful information otherwise. This attribute only appears in Clang module debug info. Differential Revision: https://reviews.llvm.org/D71722
2019-12-03Fix signed mismatch warnings in MetadataTests.cppDavid Blaikie1-9/+9
2019-12-03[DebugInfo] Make DebugVariable class available in DebugInfoMetadatastozer1-0/+38
The DebugVariable class is a class declared in LiveDebugValues.cpp which is used to uniquely identify a single variable, using its source variable, inline location, and fragment info to do so. This patch moves this class into DebugInfoMetadata.h, making it available in a much broader scope.
2019-11-26[DebugInfo] Disallow fragmenting DIExpressions with shift operatorsstozer1-0/+43
DIExpressions with shift operators should not be fragmented for the same reason as arithmetic operators: carry over cannot be expressed from one fragment to the other, so an invalid result would be produced. Differential Revision: https://reviews.llvm.org/D70601
2019-10-10Print quoted backslashes in LLVM IR as \\ instead of \5CReid Kleckner1-1/+1
This improves readability of Windows path string literals in LLVM IR. The LLVM assembler has supported \\ in IR strings for a long time, but the lexer doesn't tolerate escaped quotes, so they have to be printed as \22 for now. llvm-svn: 374415
2019-08-15[llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere1-3/+3
Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
2019-05-20[DebugInfoMetadata] Refactor DIExpression::prepend constants (NFC)Petar Jovanovic1-1/+5
Refactor DIExpression::With* into a flag enum in order to be less error-prone to use (as discussed on D60866). Patch by Djordje Todorovic. Differential Revision: https://reviews.llvm.org/D61943 llvm-svn: 361137
2019-04-24Add optional arg to profile count getters to filterXinliang David Li1-1/+1
synthetic profile count. Differential Revision: http://reviews.llvm.org/D61025 llvm-svn: 359131
2019-02-01[opaque pointer types] Add a FunctionCallee wrapper type, and use it.James Y Knight1-2/+3
Recommit r352791 after tweaking DerivedTypes.h slightly, so that gcc doesn't choke on it, hopefully. Original Message: The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352827
2019-01-31Revert "[opaque pointer types] Add a FunctionCallee wrapper type, and use it."James Y Knight1-3/+2
This reverts commit f47d6b38c7a61d50db4566b02719de05492dcef1 (r352791). Seems to run into compilation failures with GCC (but not clang, where I tested it). Reverting while I investigate. llvm-svn: 352800
2019-01-31[opaque pointer types] Add a FunctionCallee wrapper type, and use it.James Y Knight1-2/+3
The FunctionCallee type is effectively a {FunctionType*,Value*} pair, and is a useful convenience to enable code to continue passing the result of getOrInsertFunction() through to EmitCall, even once pointer types lose their pointee-type. Then: - update the CallInst/InvokeInst instruction creation functions to take a Callee, - modify getOrInsertFunction to return FunctionCallee, and - update all callers appropriately. One area of particular note is the change to the sanitizer code. Previously, they had been casting the result of `getOrInsertFunction` to a `Function*` via `checkSanitizerInterfaceFunction`, and storing that. That would report an error if someone had already inserted a function declaraction with a mismatching signature. However, in general, LLVM allows for such mismatches, as `getOrInsertFunction` will automatically insert a bitcast if needed. As part of this cleanup, cause the sanitizer code to do the same. (It will call its functions using the expected signature, however they may have been declared.) Finally, in a small number of locations, callers of `getOrInsertFunction` actually were expecting/requiring that a brand new function was being created. In such cases, I've switched them to Function::Create instead. Differential Revision: https://reviews.llvm.org/D57315 llvm-svn: 352791
2019-01-24[llvm] Clarify responsiblity of some of DILocation discriminator APIsMircea Trofin1-11/+17
Summary: Renamed setBaseDiscriminator to cloneWithBaseDiscriminator, to match similar APIs. Also changed its behavior to copy over the other discriminator components, instead of eliding them. Renamed cloneWithDuplicationFactor to cloneByMultiplyingDuplicationFactor, which more closely matches what this API does. Reviewers: dblaikie, wmi Reviewed By: dblaikie Subscribers: zzheng, llvm-commits Differential Revision: https://reviews.llvm.org/D56220 llvm-svn: 351996
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-12-21[llvm] API for encoding/decoding DWARF discriminators.Mircea Trofin1-0/+101
Summary: Added a pair of APIs for encoding/decoding the 3 components of a DWARF discriminator described in http://lists.llvm.org/pipermail/llvm-dev/2016-October/106532.html: the base discriminator, the duplication factor (useful in profile-guided optimization) and the copy index (used to identify copies of code in cases like loop unrolling) The encoding packs 3 unsigned values in 32 bits. This CL addresses 2 issues: - communicates overflow back to the user - supports encoding all 3 components together. Current APIs assume a sequencing of events. For example, creating a new discriminator based on an existing one by changing the base discriminator was not supported. Reviewers: davidxl, danielcdh, wmi, dblaikie Reviewed By: dblaikie Subscribers: zzheng, dmgreen, aprantl, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D55681 llvm-svn: 349973
2018-11-25[MetadataTest] Fix off-by-one strncpy warning reported by gcc8. (NFC)Florian Hahn1-5/+3
llvm-svn: 347528
2018-11-19[DebugInfo] DISubprogram flags get their own flags word. NFC.Paul Robinson1-95/+92
This will hold flags specific to subprograms. In the future we could potentially free up scarce bits in DIFlags by moving subprogram-specific flags from there to the new flags word. This patch does not change IR/bitcode formats, that will be done in a follow-up. Differential Revision: https://reviews.llvm.org/D54597 llvm-svn: 347239
2018-11-13DebugInfo: Add a CU metadata attribute for use of DWARF ranges base address ↵David Blaikie1-3/+3
specifiers Summary: Ranges base address specifiers can save a lot of object size in relocation records especially in optimized builds. For an optimized self-host build of Clang with split DWARF and debug info compression in object files, but uncompressed debug info in the executable, this change produces about 18% smaller object files and 6% larger executable. While it would've been nice to turn this on by default, gold's 32 bit gdb-index support crashes on this input & I don't think there's any perfect heuristic to implement solely in LLVM that would suffice - so we'll need a flag one way or another (also possible people might want to aggressively optimized for executable size that contains debug info (even with compression this would still come at some cost to executable size)) - so let's plumb it through. Differential Revision: https://reviews.llvm.org/D54242 llvm-svn: 346788
2018-11-02Allow null-valued function operands in getCalledFunction()David Stenberg1-0/+21
Summary: Change the dynamic cast in CallBase::getCalledFunction() to allow null-valued function operands. This patch fixes a crash that occurred when a funtion operand of a call instruction was dropped, and later on a metadata-carrying instruction was printed out. When allocating the metadata slot numbers, getCalledFunction() would be invoked on the call with the dropped operand, resulting in a failed non-null assertion in isa<>. This fixes PR38924, in which a printout in DBCE crashed due to this. This aligns getCalledFunction() with getCalledValue(), as the latter allows the operand to be null. Reviewers: vsk, dexonsmith, hfinkel Reviewed By: dexonsmith Subscribers: hfinkel, llvm-commits Differential Revision: https://reviews.llvm.org/D52537 llvm-svn: 345966
2018-10-03Emit template type and value parameter DIEs for template variables.Matthew Voss1-31/+45
Summary: Ensure the TemplateParam attribute of the DIGlobalVariable node is translated into the proper DIEs. Resolves https://bugs.llvm.org/show_bug.cgi?id=22119 Reviewers: dblaikie, probinson, aprantl, JDevlieghere, clayborg, whitequark, deadalnix Reviewed By: dblaikie Subscribers: llvm-commits Tags: #debug-info Differential Revision: https://reviews.llvm.org/D52057 llvm-svn: 343706
2018-08-24Prevent DILocation::getMergedLocation() from creating invalid metadata.Adrian Prantl1-0/+78
The function's new implementation from r340583 had a bug in it that could cause an invalid scope to be generated when merging two DILocations with no common ancestor scope. This patch detects this situation and picks the scope of the first location. This is not perfect, because the scope is misleading, but on the other hand, this will be a line 0 location. rdar://problem/43687474 Differential Revision: https://reviews.llvm.org/D51238 llvm-svn: 340672
2018-08-16DebugInfo: Add metadata support for disabling DWARF pub sectionsDavid Blaikie1-3/+4
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-08-14[DebugInfoMetadata] Added DIFlags interface in DIBasicType.Adrian Prantl1-9/+17
Flags in DIBasicType will be used to pass attributes used in DW_TAG_base_type, such as DW_AT_endianity. Patch by Chirag Patel! Differential Revision: https://reviews.llvm.org/D49610 llvm-svn: 339714
2018-07-26[DebugInfo] LowerDbgDeclare: Add derefs when handling CallInst usersVedant Kumar1-2/+8
LowerDbgDeclare inserts a dbg.value before each use of an address described by a dbg.declare. When inserting a dbg.value before a CallInst use, however, it fails to append DW_OP_deref to the DIExpression. The DW_OP_deref is needed to reflect the fact that a dbg.value describes a source variable directly (as opposed to a dbg.declare, which relies on pointer indirection). This patch adds in the DW_OP_deref where needed. This results in the correct values being shown during a debug session for a program compiled with ASan and optimizations (see https://reviews.llvm.org/D49520). Note that ConvertDebugDeclareToDebugValue is already correct -- no changes there were needed. One complication is that SelectionDAG is unable to distinguish between direct and indirect frame-index (FRAMEIX) SDDbgValues. This patch also fixes this long-standing issue in order to not regress integration tests relying on the incorrect assumption that all frame-index SDDbgValues are indirect. This is a necessary fix: the newly-added DW_OP_derefs cannot be lowered properly otherwise. Basically the fix prevents a direct SDDbgValue with DIExpression(DW_OP_deref) from being dereferenced twice by a debugger. There were a handful of tests relying on this incorrect "FRAMEIX => indirect" assumption which actually had incorrect DW_AT_locations: these are all fixed up in this patch. Testing: - check-llvm, and an end-to-end test using lldb to debug an optimized program. - Existing unit tests for DIExpression::appendToStack fully cover the new DIExpression::append utility. - check-debuginfo (the debug info integration tests) Differential Revision: https://reviews.llvm.org/D49454 llvm-svn: 338069