summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* DebugInfo: Remove dead code for accessing fieldsDuncan P. N. Exon Smith2015-04-061-45/+0
| | | | | | | Most fields are now accessed via the new debug info hierarchy. I'll make the rest of this code dead soon. llvm-svn: 234182
* DebugInfo: Use MDFile instead of accessing operands directly, NFCDuncan P. N. Exon Smith2015-04-061-2/+4
| | | | llvm-svn: 234175
* git-clang-format r233603.Rafael Espindola2015-04-011-1/+1
| | | | | | Thanks to Meador Inge for noticing. llvm-svn: 233808
* Verifier: Move over DISubprogram::Verify()Duncan P. N. Exon Smith2015-03-311-33/+1
| | | | | | | | | | | | | Move over the remaining (somewhat complicated) check from `DISubprogram::Verify()`. I suspect this check could be optimized -- e.g., it would be nice not to do another full traversal here -- but it's not exactly obvious how. For now, just bring it over as is. Once we have a better model for the "canonical" subprogram of a `Function`, we should enforce that all `!dbg` attachments lead to the canonical one. llvm-svn: 233663
* DebugInfo: Rewrite llvm::getDISubprogram(), NFCDuncan P. N. Exon Smith2015-03-311-11/+3
| | | | | | | | Simplify implementation of `llvm::getDISubprogram()`. I might go through and see how difficult it is to update the users, since this function doesn't really seem necessary anymore. llvm-svn: 233662
* DebugInfo: Hide isScopeRef() and isTypeRef() behind NDEBUGDuncan P. N. Exon Smith2015-03-311-1/+1
| | | | | | | | | The copies of these in `lib/IR/DebugInfo.cpp` are apparently [1] only used in assertions now, so hide them behind `#ifndef NDEBUG`. [1]: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/9238 llvm-svn: 233661
* Verifier: Check reference flags in debug infoDuncan P. N. Exon Smith2015-03-311-18/+2
| | | | | | Move over checks of `&` and `&&` flags. llvm-svn: 233658
* Verifier: Move more debug info checks away from Verify()Duncan P. N. Exon Smith2015-03-311-42/+2
| | | | | | | | | | Most of these checks were already in the `Verifier` so this is more of a cleanup. Now almost everything is over there. Now that require a `name:` for `MDGlobalVariable`, add a check in `LLParser` for it. llvm-svn: 233657
* Verifier: Move checks over from DIDescriptor::Verify()Duncan P. N. Exon Smith2015-03-311-56/+5
| | | | | | | | | | | | | | Move over some more checks from `DIDescriptor::Verify()`, and change `LLParser` to require non-null `file:` fields in compile units. I've ignored the comment in test/Assembler/metadata-null-operands.ll since I disagree with it. At the time that test was written (r229960), the debug info verifier wasn't on by default, so my comment there is in the context of not expecting the verifier to be useful. It is now, and besides that, since r233394 we can check when parsing textual IR whether an operand is null that shouldn't be. llvm-svn: 233654
* Fix PR23045.Rafael Espindola2015-03-301-10/+19
| | | | | | | | | Keep a note in the materializer that we are stripping debug info so that user doing a lazy read of the module don't hit outdated formats. Thanks to Duncan for suggesting the fix. llvm-svn: 233603
* Use range loops and add missing braces.Rafael Espindola2015-03-301-7/+7
| | | | llvm-svn: 233598
* IR: Use the new DebugLoc API, NFCDuncan P. N. Exon Smith2015-03-301-12/+10
| | | | | | | | Update lib/IR and lib/Bitcode to use the new `DebugLoc` API. Added an explicit conversion to `bool` (avoiding a conversion to `MDLocation`), since a couple of these use cases need to handle broken code. llvm-svn: 233585
* DebugInfo: Reflow printDebugLoc() to use early returns, NFCDuncan P. N. Exon Smith2015-03-301-15/+18
| | | | llvm-svn: 233580
* DebugInfo: Implement MDLocation::getInlinedAtScope()Duncan P. N. Exon Smith2015-03-301-3/+1
| | | | | | | | | Write `MDLocation::getInlinedAtScope()` and use it to re-implement `DebugLoc::getScopeNode()` (and simplify `DISubprogram::Verify()`). This follows the inlined-at linked list and returns the scope of the deepest/last location. llvm-svn: 233568
* DebugInfo: Simplify logic in DISubprogram::Verify(), NFCDuncan P. N. Exon Smith2015-03-301-13/+8
| | | | | | | Simplify the logic in `DISubprogram::Verify()` by using the new debug info hierarchy directly instead of the `DebugLoc` wrapper. llvm-svn: 233563
* DebugInfo: Permit DW_TAG_structure_type, DW_TAG_member, DW_TAG_typedef tags ↵Peter Collingbourne2015-03-251-1/+3
| | | | | | | | | | | | | | | | | with empty file names. Some languages, such as Go, have pre-defined structure types (e.g. "string" is essentially a pointer/length pair) or pre-defined "typedef" types (e.g. "error" is essentially a typedef for a specific interface type). Such types do not have associated source location, so a Go frontend would be correct not to associate a file name with such types. This change relaxes the DIType verifier to permit unlocated types with these tags. Differential Revision: http://reviews.llvm.org/D8588 llvm-svn: 233200
* DebugInfo: Overload get() in DIDescriptor subclassesDuncan P. N. Exon Smith2015-03-231-25/+44
| | | | | | | | | | | | | | | Continue to simplify the `DIDescriptor` subclasses, so that they behave more like raw pointers. Remove `getRaw()`, replace it with an overloaded `get()`, and overload the arrow and cast operators. Two testcases started to crash on the arrow operators with this change because of `scope:` references that weren't real scopes. I fixed them. Soon I'll add verifier checks for them too. This also adds explicit dereference operators. Previously, the builtin dereference against `operator MDNode *()` would have worked, but now the builtins are ambiguous. llvm-svn: 233030
OpenPOWER on IntegriCloud