summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
Commit message (Collapse)AuthorAgeFilesLines
* DI: Reverse direction of subprogram -> function edge.Peter Collingbourne2015-11-051-18/+4
| | | | | | | | | | | | | | | | | | | | | | | Previously, subprograms contained a metadata reference to the function they described. Because most clients need to get or set a subprogram for a given function rather than the other way around, this created unneeded inefficiency. For example, many passes needed to call the function llvm::makeSubprogramMap() to build a mapping from functions to subprograms, and the IR linker needed to fix up function references in a way that caused quadratic complexity in the IR linking phase of LTO. This change reverses the direction of the edge by storing the subprogram as function-level metadata and removing DISubprogram's function field. Since this is an IR change, a bitcode upgrade has been provided. Fixes PR23367. An upgrade script for textual IR for out-of-tree clients is attached to the PR. Differential Revision: http://reviews.llvm.org/D14265 llvm-svn: 252219
* IR: Remove implicit iterator conversions from lib/IR, NFCDuncan P. N. Exon Smith2015-10-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Stop converting implicitly between iterators and pointers/references in lib/IR. For convenience, I've added a `getIterator()` accessor to `ilist_node` so that callers don't need to know how to spell the iterator class (i.e., they can use `X.getIterator()` instead of `Function::iterator(X)`). I'll eventually disallow these implicit conversions entirely, but there's a lot of code, so it doesn't make sense to do it all in one patch. One library or so at a time. Why? To root out cases of `getNextNode()` and `getPrevNode()` being used in iterator logic. The design of `ilist` makes that invalid when the current node could be at the back of the list, but it happens to "work" right now because of a bug where those functions never return `nullptr` if you're using a half-node sentinel. Before I can fix the function, I have to remove uses of it that rely on it misbehaving. (Maybe the function should just be deleted anyway? But I don't want deleting it -- potentially a huge project -- to block fixing ilist/iplist.) llvm-svn: 249782
* DI: Simplify DebugInfoFinder::processType(), NFCDuncan P. N. Exon Smith2015-07-241-7/+9
| | | | | | | | | | | Handle `DISubroutineType` up-front rather than as part of a branch for `DICompositeTypeBase`. The only shared code path was looking through the base type, but `DISubroutineType` can never have a base type. This also removes the last use of `DICompositeTypeBase`, since we can strengthen the cast to `DICompositeType`. llvm-svn: 243159
* DI: Remove dead code: getDICompositeType()Duncan P. N. Exon Smith2015-07-241-15/+0
| | | | llvm-svn: 243158
* DI: Strengthen some dyn_casts to DIDerivedType, NFCDuncan P. N. Exon Smith2015-07-241-2/+2
| | | | | | | | The surrounding code proves in both cases that these must be `DIDerivedType` if they're `DIDerivedTypeBase`, so strengthen the `dyn_cast`s to the more specific type. llvm-svn: 243143
* Add a DIModule metadata node to the IR.Adrian Prantl2015-06-291-0/+4
| | | | | | | | | | | | | | | | | | | It is meant to be used to record modules @imported by the current compile unit, so a debugger an import the same modules to replicate this environment before dropping into the expression evaluator. DIModule is a sibling to DINamespace and behaves quite similarly. In addition to the name of the module it also records the module configuration details that are necessary to uniquely identify the module. This includes the configuration macros (e.g., -DNDEBUG), the include path where the module.map file is to be found, and the isysroot. The idea is that the backend will turn this into a DW_TAG_module. http://reviews.llvm.org/D9614 rdar://problem/20965932 llvm-svn: 241017
* IR: Give 'DI' prefix to debug info metadataDuncan P. N. Exon Smith2015-04-291-42/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Finish off PR23080 by renaming the debug info IR constructs from `MD*` to `DI*`. The last of the `DIDescriptor` classes were deleted in r235356, and the last of the related typedefs removed in r235413, so this has all baked for about a week. Note: If you have out-of-tree code (like a frontend), I recommend that you get everything compiling and tests passing with the *previous* commit before updating to this one. It'll be easier to keep track of what code is using the `DIDescriptor` hierarchy and what you've already updated, and I think you're extremely unlikely to insert bugs. YMMV of course. Back to *this* commit: I did this using the rename-md-di-nodes.sh upgrade script I've attached to PR23080 (both code and testcases) and filtered through clang-format-diff.py. I edited the tests for test/Assembler/invalid-generic-debug-node-*.ll by hand since the columns were off-by-three. It should work on your out-of-tree testcases (and code, if you've followed the advice in the previous paragraph). Some of the tests are in badly named files now (e.g., test/Assembler/invalid-mdcompositetype-missing-tag.ll should be 'dicompositetype'); I'll come back and move the files in a follow-up commit. llvm-svn: 236120
* DebugInfo: Remove DIArray and DITypeArray typedefsDuncan P. N. Exon Smith2015-04-211-1/+1
| | | | | | | Remove the `DIArray` and `DITypeArray` typedefs, preferring the underlying types (`DebugNodeArray` and `MDTypeRefArray`, respectively). llvm-svn: 235413
* DebugInfo: Remove DIDescriptor from the DebugInfo APIDuncan P. N. Exon Smith2015-04-171-31/+31
| | | | | | | Stop using `DIDescriptor` and its subclasses in the `DebugInfoFinder` API, as well as the rest of the API hanging around in `DebugInfo.h`. llvm-svn: 235240
* DebugInfo: DIRef<> => TypedDebugNodeRef<>Duncan P. N. Exon Smith2015-04-161-14/+0
| | | | | | | | Delete `DIRef<>`, and replace the remaining uses of it with `TypedDebugNodeRef<>`. To minimize code churn, I've added typedefs from `MDTypeRef` to `DITypeRef` (etc.). llvm-svn: 235071
* DebugInfo: Gut DIDescriptorDuncan P. N. Exon Smith2015-04-161-15/+0
| | | | | | | | | | | | | | | PR23080 is almost finished. With this commit, there's no consequential API in `DIDescriptor` and its subclasses. What's left? - Default-constructed to `nullptr`. - Handy `const_cast<>` (constructed from `const`, but accessors are non-`const`). I think the safe way to catch those is to delete the classes and fix compile errors. That'll be my next step, after I delete the `DITypeRef` (etc.) wrapper around `MDTypeRef`. llvm-svn: 235069
* DebugInfo: Gut DIScope, DIEnumerator and DISubrangeDuncan P. N. Exon Smith2015-04-161-2/+0
| | | | | | The only class the still has API left is `DIDescriptor` itself. llvm-svn: 235067
* DebugInfo: Gut DIType and subclassesDuncan P. N. Exon Smith2015-04-161-12/+11
| | | | | | | | Continuing PR23080, gut `DIType` and its various subclasses, leaving behind thin wrappers around the pointer types in the new debug info hierarchy. llvm-svn: 235064
* DebugInfo: Gut DICompileUnit and DIFileDuncan P. N. Exon Smith2015-04-151-2/+2
| | | | | | | Continuing gutting `DIDescriptor` subclasses; this edition, `DICompileUnit` and `DIFile`. In the name of PR23080. llvm-svn: 235055
* DebugInfo: Remove 'inlinedAt:' field from MDLocalVariableDuncan P. N. Exon Smith2015-04-151-10/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove 'inlinedAt:' from MDLocalVariable. Besides saving some memory (variables with it seem to be single largest `Metadata` contributer to memory usage right now in -g -flto builds), this stops optimization and backend passes from having to change local variables. The 'inlinedAt:' field was used by the backend in two ways: 1. To tell the backend whether and into what a variable was inlined. 2. To create a unique id for each inlined variable. Instead, rely on the 'inlinedAt:' field of the intrinsic's `!dbg` attachment, and change the DWARF backend to use a typedef called `InlinedVariable` which is `std::pair<MDLocalVariable*, MDLocation*>`. This `DebugLoc` is already passed reliably through the backend (as verified by r234021). This commit removes the check from r234021, but I added a new check (that will survive) in r235048, and changed the `DIBuilder` API in r235041 to require a `!dbg` attachment whose 'scope:` is in the same `MDSubprogram` as the variable's. If this breaks your out-of-tree testcases, perhaps the script I used (mdlocalvariable-drop-inlinedat.sh) will help; I'll attach it to PR22778 in a moment. llvm-svn: 235050
* Fix crash in DebugInfoFinder when adding a module with forward declared ↵Anders Waldenborg2015-04-141-1/+1
| | | | | | | | | | | | | | | composite type The testcase that is included in the patch caused a crash when doing DebugInfoFinder::processModule on the module due to DCT->getElements() returning nullptr in DebugInfoFinder::processType. By doing "DCT->getElements()" instead of "DCT->getElements()->operands()" one gets a DIArray instead of a raw MDTuple. The former has code to handle null as a 0-element array and therefore avoids the crash. Differential Revision: http://reviews.llvm.org/D9008 llvm-svn: 234875
* DebugInfo: Update signature of DICompileUnit::replace*()Duncan P. N. Exon Smith2015-04-141-12/+0
| | | | | | | | Change `DICompileUnit::replaceSubprograms()` and `DICompileUnit::replaceGlobalVariables()` to match the `MDCompileUnit` equivalents that they're wrapping. llvm-svn: 234852
* DebugInfo: Gut DISubprogram and DILexicalBlock*Duncan P. N. Exon Smith2015-04-141-7/+7
| | | | | | | Gut the `DIDescriptor` wrappers around `MDLocalScope` subclasses. Note that `DILexicalBlock` wraps `MDLexicalBlockBase`, not `MDLexicalBlock`. llvm-svn: 234850
* DebugInfo: Gut DINamespace and DITemplate*ParameterDuncan P. N. Exon Smith2015-04-141-8/+6
| | | | | | | Continue gutting `DIDescriptor` subclasses, turning them into as-bare-as-possible pointer wrappers. llvm-svn: 234843
* DebugInfo: Gut DIVariable and DIGlobalVariableDuncan P. N. Exon Smith2015-04-141-6/+6
| | | | | | | | | | Gut all the non-pointer API from the variable wrappers, except an implicit conversion from `DIGlobalVariable` to `DIDescriptor`. Note that if you're updating out-of-tree code, `DIVariable` wraps `MDLocalVariable` (`MDVariable` is a common base class shared with `MDGlobalVariable`). llvm-svn: 234840
* DebugInfo: Move DIVariable::printExtendedName() to its only callerDuncan P. N. Exon Smith2015-04-141-35/+0
| | | | | | Move the local function `printDebugLoc()` along with it. llvm-svn: 234838
* DebugInfo: Gut DIObjCProperty and DIImportedEntityDuncan P. N. Exon Smith2015-04-141-1/+1
| | | | | | | Gut a couple more classes in the DIDescriptor hierarchy. Leave behind an implicit conversion to `DIDescriptor`, the old base class. llvm-svn: 234836
* DebugInfo: Gut DILocationDuncan P. N. Exon Smith2015-04-141-2/+2
| | | | | | | | This is along the same lines as r234832, but for `DILocation`. Clean out all accessors from `DILocation`. Any callers should be using `MDLocation` directly (e.g., via `operator->()`). llvm-svn: 234835
* DebugInfo: Move DILocation::computeNewDiscriminators()Duncan P. N. Exon Smith2015-04-141-5/+0
| | | | | | | | | As documented in PR23200 (and the FIXMEs I've added to the code here), this logic is fairly broken: it modifies the `LLVMContext` in a way that affects other modules and cannot be serialized to assembly/bitcode. For now, move it over to `MDLocation::computeNewDiscriminators()` anyway. llvm-svn: 234825
* AddDiscriminators: Create new MDLocation directlyDuncan P. N. Exon Smith2015-04-141-9/+0
| | | | | | | | | | I don't see a reason to add the `copyWithNewScope()` API over to `MDLocation` -- it seems to be a holdover from when creating locations required knowing details of operand layout -- so change `AddDiscriminators` to call `MDLocation::get()` directly. Should be no functionality change here. llvm-svn: 234824
* SelectionDAG: Stop using DIVariable::isInlinedFnArgument()Duncan P. N. Exon Smith2015-04-131-10/+0
| | | | | | | | | | | | | | | | | | Instead of calling the somewhat confusingly-named `DIVariable::isInlinedFnArgument()`, do the check directly here. There's possibly a small functionality change here: instead of `dyn_cast<>`'ing `DV->getScope()` to `MDSubprogram`, I'm looking up the scope chain for the actual subprogram. I suspect that this is a no-op for function arguments so in practise there isn't a real difference. I've also added a `FIXME` to check the `inlinedAt:` chain instead, since I wonder if that would be more reliable than the `MDSubprogram::describes()` function. Since this was the only user of `DIVariable::isInlinedFnArgument()`, delete it. llvm-svn: 234799
* DebugInfo: Remove DIGlobalVariable::getGlobal()Duncan P. N. Exon Smith2015-04-131-4/+0
| | | | | | | | `DIGlobalVariable::getGlobal()` isn't really helpful, it just does a `dyn_cast_or_null<>`. Simplify its only user by doing the cast directly and delete the code. llvm-svn: 234796
* DebugInfo: Migrate DISubprogram::describes() to new hierarchy, NFCDuncan P. N. Exon Smith2015-04-131-12/+0
| | | | | | | | I don't really like this function at all -- I think it should be as simple as `return getFunction() == F` -- but for now this seems like the best we can do. llvm-svn: 234778
* Reapply "Verifier: Check for incompatible bit piece expressions"Duncan P. N. Exon Smith2015-04-131-13/+0
| | | | | | | | | | | | | | | | | | | | | This reverts commit r234717, reapplying r234698 (in spirit). As described in r234717, the original `Verifier` check had a use-after-free. Instead of storing pointers to "interesting" debug info intrinsics whose bit piece expressions should be verified once we have typerefs, do a second traversal. I've added a testcase to catch the `llc` crasher. Original commit message: Verifier: Check for incompatible bit piece expressions Convert an assertion into a `Verifier` check. Bit piece expressions must fit inside the variable, and mustn't be the entire variable. Catching this in the verifier will help us find bugs sooner, and makes `DIVariable::getSizeInBits()` dead code. llvm-svn: 234776
* Revert "Verifier: Check for incompatible bit piece expressions"Duncan P. N. Exon Smith2015-04-131-0/+13
| | | | | | | | | | | | | This reverts commit r234698. This caused a use-after-free: `QueuedBitPieceExpressions` holds onto references to `DbgInfoIntrinsic`s and references them past where they're deleted (this is because the verifier is run as a function pass, and then `verifyTypeRefs()` is called during `doFinalization()`). I'll include a reduced crasher for `llc` when I recommit the check. llvm-svn: 234717
* DebugInfo: Make MDSubprogram::getFunction() return ConstantDuncan P. N. Exon Smith2015-04-111-6/+0
| | | | | | | | Change `MDSubprogram::getFunction()` and `MDGlobalVariable::getConstant()` to return a `Constant`. Previously, both returned `ConstantAsMetadata`. llvm-svn: 234699
* Verifier: Check for incompatible bit piece expressionsDuncan P. N. Exon Smith2015-04-111-13/+0
| | | | | | | | | Convert an assertion into a `Verifier` check. Bit piece expressions must fit inside the variable, and mustn't be the entire variable. Catching this in the verifier will help us find bugs sooner, and makes `DIVariable::getSizeInBits()` dead code. llvm-svn: 234698
* DebugInfo: Remove dead DIDescriptor::replaceAllUsesWith()Duncan P. N. Exon Smith2015-04-111-27/+0
| | | | | | | | r234696 replaced the only use of `DIDescriptor::replaceAllUsesWith()` with `DIBuilder::replaceTemporary()` (added in r234695). Delete the dead code. llvm-svn: 234697
* DebugInfo: Assume a valid pointer for DISubprogram::getFunction()Duncan P. N. Exon Smith2015-04-111-3/+2
| | | | llvm-svn: 234693
* DebugInfo: Move DIScope::getName() and getContext() to MDScopeDuncan P. N. Exon Smith2015-04-111-31/+0
| | | | | | | | Continue gutting the `DIDescriptor` hierarchy. In this case, move the guts of `DIScope::getName()` and `DIScope::getContext()` to `MDScope::getName()` and `MDScope::getScope()`. llvm-svn: 234691
* DebugInfo: Add forwarding getFilename() accessor to new hierarchyDuncan P. N. Exon Smith2015-04-111-14/+0
| | | | | | | | Add forwarding `getFilename()` and `getDirectory()` accessors to nodes in the new hierarchy that define a `getFile()`. Use that to re-implement existing functionality in the `DIDescriptor` hierarchy. llvm-svn: 234671
* DebugInfo: Remove dead DIDescriptor::getDescriptorField()Duncan P. N. Exon Smith2015-04-101-19/+0
| | | | llvm-svn: 234665
* DebugInfo: Remove constructors for DIRef<>Duncan P. N. Exon Smith2015-04-071-56/+4
| | | | | | | Remove all constructors for `DIRef<>` *except* the ones forwarding from `TypedDebugNodeRef`. llvm-svn: 234340
* IR: Remove MDTupleTypedArrayWrapper::operator MDTuple*()Duncan P. N. Exon Smith2015-04-071-2/+2
| | | | | | | | | | | | Remove `MDTupleTypedArrayWrapper::operator MDTuple*()`, since it causes ambiguity (at least in some [1] compilers [2]) when using indexes to `MDTupleTypedArrayWrapper::operator[](unsigned)` that are convertible to (but not the same as) `unsigned`. [1]: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/2308 [2]: http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/4442 llvm-svn: 234326
* DebugInfo: Remove DITypedArray<>, replace with typedefsDuncan P. N. Exon Smith2015-04-071-32/+18
| | | | | | | | | | | | | | | | | Replace all uses of `DITypedArray<>` with `MDTupleTypedArrayWrapper<>` and `MDTypeRefArray`. The APIs are completely different, but the provided functionality is the same: treat an `MDTuple` as if it's an array of a particular element type. To simplify this patch a bit, I've temporarily typedef'ed `DebugNodeArray` to `DIArray` and `MDTypeRefArray` to `DITypeArray`. I've also temporarily conditionalized the accessors to check for null -- eventually these should be changed to asserts and the callers should check for null themselves. There's a tiny accompanying patch to clang. llvm-svn: 234290
* DebugInfo: Remove DICompositeType mutation APIDuncan P. N. Exon Smith2015-04-071-15/+0
| | | | | | | Change `DIBuilder` to mutate `MDCompositeTypeBase` directly, and remove the wrapping API in `DICompositeType`. llvm-svn: 234289
* DebugInfo: Move DIExpression bit-piece API to MDExpressionDuncan P. N. Exon Smith2015-04-071-15/+0
| | | | llvm-svn: 234286
* DebugInfo: Remove special iterators from DIExpressionDuncan P. N. Exon Smith2015-04-071-5/+0
| | | | | | | | | | Remove special iterators from `DIExpression` in favour of same in `MDExpression`. There should be no functionality change here. Note that the APIs are slightly different: `getArg(unsigned)` counts from 0, not 1, in the `MDExpression` version of the iterator. llvm-svn: 234285
* DebugInfo: Move DIFlag-related API from DIDescriptor to DebugNodeDuncan P. N. Exon Smith2015-04-071-43/+0
| | | | llvm-svn: 234274
* IR: Stop using DIDescriptor::is*() and auto-castingDuncan P. N. Exon Smith2015-04-061-83/+75
| | | | | | | | | | | | | | | | | | | | | | | | | `DIDescriptor`'s subclasses allow construction from incompatible pointers, and `DIDescriptor` defines a series of `isa<>`-like functions (e.g., `isCompileUnit()` instead of `isa<MDCompileUnit>()`) that clients tend to use like this: if (DICompileUnit(N).isCompileUnit()) foo(DICompileUnit(N)); These construction patterns work together to make `DIDescriptor` behave differently from normal pointers. Instead, use built-in `isa<>`, `dyn_cast<>`, etc., and only build `DIDescriptor`s from pointers that are valid for their type. I've split this into a few commits for different parts of LLVM and clang (to decrease the patch size and increase the chance of review). Generally the changes I made were NFC, but in a few places I made things stricter if it made sense from the surrounded code. Eventually a follow-up commit will remove the API for the "old" way. llvm-svn: 234255
* DebugInfo: Reimplement DIRef<>::resolve() using TypedDebugNodeRef<>Duncan P. N. Exon Smith2015-04-061-0/+14
| | | | | | | | | | | | | Gut `DIRef<>::resolve()`, reimplementing it using `TypedDebugNodeRef<>::resolve()`. Use three separate functions rather than some sort of type traits, since the latter (i.e., mapping `DIScope` => `MDScope`) seems heavy-handed. I don't expect `DIRef<>` to last much longer in tree anyway. As a drive-by fix, make `TypedDebugNodeRef<>::resolve()` do the right thing with `nullptr`. llvm-svn: 234248
* DebugInfo: Drop confusing forwarding API from DILexicalBlockFileDuncan P. N. Exon Smith2015-04-061-3/+0
| | | | | | | | | | | | | | | | | Remove `DILexicalBlockFile::getScope()` (whose last use was removed from clang in r234245), which illegally returned a `DILexicalBlock` despite its scope sometimes being an `MDSubprogram`. Also remove the `getLineNumber()` and `getColumnNumber()` methods that just forwarded to `DILexicalBlock`'s versions, since there don't seem to be any callers. Note that the block of code removed from `DebugInfo.cpp` was actually dead code, since `isLexicalBlock()` (the previous branch) always returns true when `isLexicalBlockFile()` returns true. An earlier (broken and untested) version of this was squashed into r234222 and reverted in r234225. llvm-svn: 234246
* DebugInfo: Remove DIDescriptor::Verify()Duncan P. N. Exon Smith2015-04-061-61/+0
| | | | | | | | | | | | Remove `DIDescriptor::Verify()` and the `Verify()`s from subclasses. They had already been gutted, and just did an `isa<>` check. In a couple of cases I've temporarily dropped the check entirely, but subsequent commits are going to disallow conversions to the `DIDescriptor`s directly from `MDNode`, so the checks will come back in another form soon enough. llvm-svn: 234201
* DebugInfo: Use MDTypeRef throughout the hierarchyDuncan P. N. Exon Smith2015-04-061-1/+1
| | | | | | | | | | | | | | Use `MDTypeRef` (etc.) in the new debug info hierarchy rather than raw `Metadata *` pointers. I rolled in a change to `DIBuilder` that looks unrelated: take `DIType` instead of `DITypeRef` as type arguments when creating variables. However, this was the simplest way to use `MDTypeRef` within the functions, and didn't require any cleanups from callers in clang (since they were all passing in `DIType`s anyway, relying on their implicit conversions to `DITypeRef`). llvm-svn: 234197
* DebugInfo: Create MDTypeRef, etc., to replace DITypeRefDuncan P. N. Exon Smith2015-04-061-8/+1
| | | | | | | Create a string-based wrapper in the debug info hierarchy for type references. llvm-svn: 234188
OpenPOWER on IntegriCloud