summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DebugInfo.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* DebugLocs without a scope should fail the verification.Adrian Prantl2015-01-201-3/+3
| | | | | | Follow-up to r226588. llvm-svn: 226616
* Add an assertion and prefer a crash over an infinite loop.Adrian Prantl2015-01-201-0/+3
| | | | llvm-svn: 226588
* IR: Remove MDNodeFwdDeclDuncan P. N. Exon Smith2015-01-191-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove `MDNodeFwdDecl` (as promised in r226481). Aside from API changes, there's no real functionality change here. `MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`, which returns a tuple with `isTemporary()` equal to true. The main point is that we can now add temporaries of other `MDNode` subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the first place because I didn't recognize this need, and thought they were only needed to handle forward references). A few things left out of (or highlighted by) this commit: - I've had to remove the (few) uses of `std::unique_ptr<>` to deal with temporaries, since the destructor is no longer public. `getTemporary()` should probably return the equivalent of `std::unique_ptr<T, MDNode::deleteTemporary>`. - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually does exist, but does the wrong thing: `MDNode::getTemporary()` is inherited and returns an `MDTuple`). - `MDNode` now only has one subclass, `UniquableMDNode`, and the distinction between them is actually somewhat confusing. I'll fix those up next. llvm-svn: 226501
* IR: Move MDLocation into placeDuncan P. N. Exon Smith2015-01-141-13/+6
| | | | | | | | | | | | | | | | | | | | This commit moves `MDLocation`, finishing off PR21433. There's an accompanying clang commit for frontend testcases. I'll attach the testcase upgrade script I used to PR21433 to help out-of-tree frontends/backends. This changes the schema for `DebugLoc` and `DILocation` from: !{i32 3, i32 7, !7, !8} to: !MDLocation(line: 3, column: 7, scope: !7, inlinedAt: !8) Note that empty fields (line/column: 0 and inlinedAt: null) don't get printed by the assembly writer. llvm-svn: 226048
* Remove isSubroutineType test for isCompositeType, getTag() is enough.Yaron Keren2014-12-191-1/+1
| | | | llvm-svn: 224621
* Try fixing MSVC build after r223802Hans Wennborg2014-12-091-1/+1
| | | | | | | | | | | LLVM_EXPLICIT is only supported by recent version of MSVC, and it seems the not-so-recent versions get confused about the operator bool() when tryint to resolve operator== calls. This removed the operator bool()'s since they don't seem to be used anyway. llvm-svn: 223824
* IR: Split Metadata from ValueDuncan P. N. Exon Smith2014-12-091-56/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Split `Metadata` away from the `Value` class hierarchy, as part of PR21532. Assembly and bitcode changes are in the wings, but this is the bulk of the change for the IR C++ API. I have a follow-up patch prepared for `clang`. If this breaks other sub-projects, I apologize in advance :(. Help me compile it on Darwin I'll try to fix it. FWIW, the errors should be easy to fix, so it may be simpler to just fix it yourself. This breaks the build for all metadata-related code that's out-of-tree. Rest assured the transition is mechanical and the compiler should catch almost all of the problems. Here's a quick guide for updating your code: - `Metadata` is the root of a class hierarchy with three main classes: `MDNode`, `MDString`, and `ValueAsMetadata`. It is distinct from the `Value` class hierarchy. It is typeless -- i.e., instances do *not* have a `Type`. - `MDNode`'s operands are all `Metadata *` (instead of `Value *`). - `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively. If you're referring solely to resolved `MDNode`s -- post graph construction -- just use `MDNode*`. - `MDNode` (and the rest of `Metadata`) have only limited support for `replaceAllUsesWith()`. As long as an `MDNode` is pointing at a forward declaration -- the result of `MDNode::getTemporary()` -- it maintains a side map of its uses and can RAUW itself. Once the forward declarations are fully resolved RAUW support is dropped on the ground. This means that uniquing collisions on changing operands cause nodes to become "distinct". (This already happened fairly commonly, whenever an operand went to null.) If you're constructing complex (non self-reference) `MDNode` cycles, you need to call `MDNode::resolveCycles()` on each node (or on a top-level node that somehow references all of the nodes). Also, don't do that. Metadata cycles (and the RAUW machinery needed to construct them) are expensive. - An `MDNode` can only refer to a `Constant` through a bridge called `ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`). As a side effect, accessing an operand of an `MDNode` that is known to be, e.g., `ConstantInt`, takes three steps: first, cast from `Metadata` to `ConstantAsMetadata`; second, extract the `Constant`; third, cast down to `ConstantInt`. The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have metadata schema owners transition away from using `Constant`s when the type isn't important (and they don't care about referring to `GlobalValue`s). In the meantime, I've added transitional API to the `mdconst` namespace that matches semantics with the old code, in order to avoid adding the error-prone three-step equivalent to every call site. If your old code was: MDNode *N = foo(); bar(isa <ConstantInt>(N->getOperand(0))); baz(cast <ConstantInt>(N->getOperand(1))); bak(cast_or_null <ConstantInt>(N->getOperand(2))); bat(dyn_cast <ConstantInt>(N->getOperand(3))); bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4))); you can trivially match its semantics with: MDNode *N = foo(); bar(mdconst::hasa <ConstantInt>(N->getOperand(0))); baz(mdconst::extract <ConstantInt>(N->getOperand(1))); bak(mdconst::extract_or_null <ConstantInt>(N->getOperand(2))); bat(mdconst::dyn_extract <ConstantInt>(N->getOperand(3))); bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4))); and when you transition your metadata schema to `MDInt`: MDNode *N = foo(); bar(isa <MDInt>(N->getOperand(0))); baz(cast <MDInt>(N->getOperand(1))); bak(cast_or_null <MDInt>(N->getOperand(2))); bat(dyn_cast <MDInt>(N->getOperand(3))); bay(dyn_cast_or_null<MDInt>(N->getOperand(4))); - A `CallInst` -- specifically, intrinsic instructions -- can refer to metadata through a bridge called `MetadataAsValue`. This is a subclass of `Value` where `getType()->isMetadataTy()`. `MetadataAsValue` is the *only* class that can legally refer to a `LocalAsMetadata`, which is a bridged form of non-`Constant` values like `Argument` and `Instruction`. It can also refer to any other `Metadata` subclass. (I'll break all your testcases in a follow-up commit, when I propagate this change to assembly.) llvm-svn: 223802
* Fix a bug when pretty-printing DW_OP_deref.Adrian Prantl2014-12-051-0/+3
| | | | llvm-svn: 223493
* Debug Info: revert r222195, r222210 and r222239.Manman Ren2014-11-211-3/+3
| | | | | | | This is no longer needed after David's fix at r222377 + r222485. rdar://18958417 llvm-svn: 222563
* Update SetVector to rely on the underlying set's insert to return a ↵David Blaikie2014-11-191-7/+7
| | | | | | | | | | | | | pair<iterator, bool> This is to be consistent with StringSet and ultimately with the standard library's associative container insert function. This lead to updating SmallSet::insert to return pair<iterator, bool>, and then to update SmallPtrSet::insert to return pair<iterator, bool>, and then to update all the existing users of those functions... llvm-svn: 222334
OpenPOWER on IntegriCloud