summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* DebugInfoFinder: Check for null imported entitiesDuncan P. N. Exon Smith2015-03-201-0/+2
| | | | | | | | Don't use the accessors in `DIImportedEntity` on a null pointer. (A WIP patch to make `DIDescriptor` accessors more strict crashes here otherwise.) llvm-svn: 232833
* IR: Take advantage of -verify checks for MDExpressionDuncan P. N. Exon Smith2015-03-161-7/+1
| | | | | | | | | | | | | | | | | | Now that we check `MDExpression` during `-verify` (r232299), make the `DIExpression` wrapper more strict: - remove redundant checks in `DebugInfoVerifier`, - overload `get()` to `cast_or_null<MDExpression>` (superseding `getRaw()`), - stop checking for null in any accessor, and - remove `DIExpression::Verify()` entirely in favour of `MDExpression::isValid()`. There is still some logic in this class, mostly to do with high-level iterators; I'll defer cleaning up those until the rest of the wrappers are similarly strict. llvm-svn: 232412
* DebugInfo: Simplify logic in DIType::Verify(), NFCDuncan P. N. Exon Smith2015-03-161-18/+20
| | | | | | | | | | Clarify the logic in `DIType::Verify()` by checking `isBasicType()` earlier, by skipping `else` after `return`s, and by documenting an otherwise opaque check. No functionality change. llvm-svn: 232410
* Fix DwarfExpression::AddMachineRegExpression so it doesn't read past theAdrian Prantl2015-03-041-2/+2
| | | | | | | end of an expression that ends with DW_OP_plus. Caught by the ASAN build bots. llvm-svn: 231260
* DebugInfo: Move new hierarchy into placeDuncan P. N. Exon Smith2015-03-031-696/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the specialized metadata nodes for the new debug info hierarchy into place, finishing off PR22464. I've done bootstraps (and all that) and I'm confident this commit is NFC as far as DWARF output is concerned. Let me know if I'm wrong :). The code changes are fairly mechanical: - Bumped the "Debug Info Version". - `DIBuilder` now creates the appropriate subclass of `MDNode`. - Subclasses of DIDescriptor now expect to hold their "MD" counterparts (e.g., `DIBasicType` expects `MDBasicType`). - Deleted a ton of dead code in `AsmWriter.cpp` and `DebugInfo.cpp` for printing comments. - Big update to LangRef to describe the nodes in the new hierarchy. Feel free to make it better. Testcase changes are enormous. There's an accompanying clang commit on its way. If you have out-of-tree debug info testcases, I just broke your build. - `upgrade-specialized-nodes.sh` is attached to PR22564. I used it to update all the IR testcases. - Unfortunately I failed to find way to script the updates to CHECK lines, so I updated all of these by hand. This was fairly painful, since the old CHECKs are difficult to reason about. That's one of the benefits of the new hierarchy. This work isn't quite finished, BTW. The `DIDescriptor` subclasses are almost empty wrappers, but not quite: they still have loose casting checks (see the `RETURN_FROM_RAW()` macro). Once they're completely gutted, I'll rename the "MD" classes to "DI" and kill the wrappers. I also expect to make a few schema changes now that it's easier to reason about everything. llvm-svn: 231082
* DebugInfo: Use TempMDNode in DIDescriptor::replaceAllUsesWith()Duncan P. N. Exon Smith2015-02-281-13/+9
| | | | | | | | | | | | | | Start using `TempMDNode` in `DIDescriptor::replaceAllUsesWith()` (effectively `std::unique_ptr<MDNode, MDNode::deleteTemporary>`). Besides making ownership more explicit, this prepares for when `DIDescriptor` refers to nodes that are *not* `MDTuple`. The old logic for "replacing" a node with itself used `MDNode::get()` to return a new (uniqued) `MDTuple`, while the new logic just defers to `MDNode::replaceWithUniqued()` (which also typically saves an allocation and RAUW traffic by mutating the temporary in place). llvm-svn: 230879
* IR: Add helper to split debug info flags bitfieldDuncan P. N. Exon Smith2015-02-211-0/+24
| | | | | | | | Split debug info 'flags' bitfield over a vector so the current flags can be iterated over. This API (in combination with r230107) will be used for assembly support for symbolic constants. llvm-svn: 230108
* IR: Add debug info flag string conversionsDuncan P. N. Exon Smith2015-02-211-0/+19
| | | | | | | | | Add `DIDescriptor::getFlag(StringRef)` and `DIDescriptor::getFlagString(unsigned)`. The latter only converts exact matches; I'll add separate API for breaking the flags bitfield up into parts. llvm-svn: 230107
* IR: Drop the scope in DI template parametersDuncan P. N. Exon Smith2015-02-181-2/+0
| | | | | | | | | | | The scope/context is always the compile unit, which we replace with `nullptr` anyway (via `getNonCompileUnitScope()`). Drop it explicitly. I noticed this field was always null while writing testcase upgrade scripts to transition to the new hierarchy. Seems wasteful to transition it over if it's already out-of-use. llvm-svn: 229740
* Fix -DNDEBUG -Werror build after r229733Duncan P. N. Exon Smith2015-02-181-0/+2
| | | | llvm-svn: 229736
* IR: isScopeRef() should check isScope()Duncan P. N. Exon Smith2015-02-181-1/+3
| | | | | | | r229733 removed an invalid use of `DIScopeRef`, so now we can enforce that a `DIScopeRef` is actually a scope. llvm-svn: 229734
* IR: Avoid DIScopeRef in DIImportedEntity::getEntity()Duncan P. N. Exon Smith2015-02-181-0/+17
| | | | | | | | | | `DIImportedEntity::getEntity()` currently returns a `DIScopeRef`, but the nodes it references aren't always `DIScope`s. In particular, it can reference global variables. Introduce `DIDescriptorRef` to avoid the lie. llvm-svn: 229733
* IR: fieldIsMDNode() should be false for MDStringDuncan P. N. Exon Smith2015-02-171-8/+1
| | | | | | | Simplify the code. It has been a while since the schema has been so "flexible". llvm-svn: 229573
* Prefer SmallVector::append/insert over push_back loops.Benjamin Kramer2015-02-171-9/+5
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229500
* DebugInfo: Don't crash if 'Debug Info Version' has a strange valueDavid Majnemer2015-02-161-1/+1
| | | | llvm-svn: 229356
* Debug info: Use DW_OP_bit_piece instead of DW_OP_piece in theAdrian Prantl2015-02-091-8/+8
| | | | | | | | | | | intermediate representation. This - increases consistency by using the same granularity everywhere - allows for pieces < 1 byte - DW_OP_piece didn't actually allow storing an offset. Part of PR22495. llvm-svn: 228631
* DebugInfo: Remove DW_TAG_constantDuncan P. N. Exon Smith2015-02-091-2/+1
| | | | | | | | Remove handling for DW_TAG_constant. We started producing it in r110656, but reverted that in r110876 without dropping the support. Finish the job. llvm-svn: 228623
* DebugInfo: Fix use after return found by asan.Benjamin Kramer2015-01-241-1/+1
| | | | llvm-svn: 227012
* Address more review comments for DIExpression::iterator.Adrian Prantl2015-01-231-4/+9
| | | | | | | | - input_iterator - define an operator-> - make constructors private were possible llvm-svn: 226967
* Move the accessor functions from DIExpression::iterator into a wrapperAdrian Prantl2015-01-231-6/+5
| | | | | | | | DIExpression::Operand, so we can write range-based for loops. Thanks to David Blaikie for the idea. llvm-svn: 226939
* Rewrite DIExpression::printInternal() to use the iterator interface.Adrian Prantl2015-01-221-9/+5
| | | | | | NFC. llvm-svn: 226836
* Rename DIExpressionIterator to DIExpression::iterator.Adrian Prantl2015-01-221-4/+4
| | | | | | Addresses review feedback from Duncan. llvm-svn: 226835
* Rewrite DIExpression::Verify() using an iterator. NFC.Adrian Prantl2015-01-221-15/+23
| | | | | | Addresses review comments for r226627. llvm-svn: 226747
* Let subprograms with instructions without parent scopes fail theAdrian Prantl2015-01-211-1/+2
| | | | | | | | verification. Tested via a unit test. Follow-up to r226616. llvm-svn: 226684
* Make DIExpression::Verify() stricter by checking that the number ofAdrian Prantl2015-01-211-5/+24
| | | | | | elements and the ordering is sane and cleanup the accessors. llvm-svn: 226627
OpenPOWER on IntegriCloud