summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* DebugInfo: Drop fake DW_TAG_expressionDuncan P. N. Exon Smith2015-03-171-1/+0
| | | | | | | | | | | | | Break MDExpression off of DebugNode (inherit directly from `MDNode`) and drop the fake `DW_TAG_expression` tag in the process. AFAICT, there's no real functionality change here. The tag was originally used by `DIDescriptor::isExpression()` to discriminate between `MDNode`s, but in the new hierarchy we don't need that. Fixes PR22780. llvm-svn: 232550
* Verifier: Set --verify-debug-info=true by defaultDuncan P. N. Exon Smith2015-03-171-1/+1
| | | | | | | | | | | | | | | | | | | r186634 started verifying debug info, and r194986 disabled it by default because it was too expensive to run the checks on every function (since most of the graph was reachable from each function). r206300 moved the checks to module-level to make it cheaper, but there was already quite a bit of testcase bitrot (and the verifier would only print `<badref>`) so I guess no one had time to turn it back on. This does just that. Upgrade scripts this past autumn and winter probably fixed some of the bitrot, and this weekend I fixed the verifier output (r232275, r232417, r232418) and thusly the remaining failing testcases (r232290, r232415). This is part of PR22777. llvm-svn: 232505
* Verifier: Don't call debug info verifier if the module is brokenDuncan P. N. Exon Smith2015-03-161-1/+6
| | | | | | | | | | | | | | | | | | | | If `Verifier` has already found a failure, don't call `DebugInfoVerifier`. The latter sometimes crashes in `DebugInfoFinder` when the former would give a nice message. The only two cases I found it crashing are explicit verifier tests I've added: - test/Verifier/llvm.dbg.declare-expression.ll - test/Verifier/llvm.dbg.value-expression.ll However, I assume frontends with bugs will create invalid IR as well. IMO, the `DebugInfoVerifier` should never crash (instead, it should fail to verify), but subtleties like that will be easier to work out once it's enabled again. This is part of PR22777. llvm-svn: 232418
* Verifier: Simplify logic in processCallInst(), NFCDuncan P. N. Exon Smith2015-03-161-8/+4
| | | | | | No need for local variables here. llvm-svn: 232413
* IR: Take advantage of -verify checks for MDExpressionDuncan P. N. Exon Smith2015-03-161-4/+0
| | | | | | | | | | | | | | | | | | 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
* Verifier: Remove unnecessary double-checksDuncan P. N. Exon Smith2015-03-161-4/+0
| | | | | | | | | | | Turns out `visitIntrinsicFunctionCall()` descends into all operands already, so explicitly descending in `visitDbgIntrinsic()` (part of r232296) isn't useful. Updating a testcase that doesn't really need `-verify-debug-info` (since r231082) as confirmation. llvm-svn: 232408
* Fix doxygen comments from r232268Duncan P. N. Exon Smith2015-03-161-8/+8
| | | | llvm-svn: 232388
* DbgIntrinsicInst: Downcast to specialized MDNodes in accessorsDuncan P. N. Exon Smith2015-03-151-2/+2
| | | | | | | Change accessors to downcast to `MDLocalVariable` and `MDExpression`, now that we have -verify checks in place to confirm that it's safe. llvm-svn: 232299
* Verifier: Check debug info intrinsic argumentsDuncan P. N. Exon Smith2015-03-151-0/+24
| | | | | | | | | | | | | | | | | | | Verify that debug info intrinsic arguments are valid. (These checks will not recurse through the full debug info graph, so they don't need to be cordoned of in `DebugInfoVerifier`.) With those checks in place, changing the `DbgIntrinsicInst` accessors to downcast to `MDLocalVariable` and `MDExpression` is natural (added isa specializations in `Metadata.h` to support this). Added tests to `test/Verifier` for the new -verify checks, and fixed the debug info in all the in-tree tests. If you have out-of-tree testcases that have started to fail to -verify, hopefully the verify checks are helpful. The most likely problem is that the expression argument is `!{}` (instead of `!MDExpression()`). llvm-svn: 232296
* Verifier: Remove unnecessary null checkDuncan P. N. Exon Smith2015-03-151-3/+3
| | | | | | | This is already assumed to be non-null above due to a dyn_cast<>. Also remove extraneous braces around statement. llvm-svn: 232292
* Verifier: Make the raw_ostream constructor argument requiredDuncan P. N. Exon Smith2015-03-151-2/+2
| | | | | | This was passed inconsistently; seems clearer to make it required anyway. llvm-svn: 232291
* IR: Make Metadata::print() reliable and usefulDuncan P. N. Exon Smith2015-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replumb the `AsmWriter` so that `Metadata::print()` is generally useful. (Similarly change `Metadata::printAsOperand()`.) - `SlotTracker` now has a mode where all metadata will be correctly numbered when initializing a `Module`. Normally, `Metadata` only referenced from within `Function`s gets numbered when the `Function` is incorporated. - `Metadata::print()` and `Metadata::printAsOperand()` (and `Metadata::dump()`) now take an optional `Module` argument. When provided, `SlotTracker` is initialized with the new mode, and the numbering will be complete and consistent for all calls to `print()`. - `Value::print()` uses the new `SlotTracker` mode when printing intrinsics with `MDNode` operands, `MetadataAsValue` operands, or the bodies of functions. Thus, metadata numbering will be consistent between calls to `Metadata::print()` and `Value::print()`. - `Metadata::print()` (and `Metadata::dump()`) now print the full definition of `MDNode`s: !5 = !{!6, !"abc", !7} This matches behaviour for `Value::print()`, which includes the name of instructions. - Updated call sites in `Verifier` to call `print()` instead of `printAsOperand()`. All this, so that `Verifier` can print out useful failure messages that involve `Metadata` for PR22777. Note that `Metadata::printAsOperand()` previously took an optional `bool` and `Module` operand. The former was cargo-culted from `Value::printAsOperand()` and wasn't doing anything useful. The latter didn't give consistent results (without the new `SlotTracker` mode). llvm-svn: 232275
* Recover the ability to 'b CheckFailed' after r231577Duncan P. N. Exon Smith2015-03-141-6/+15
| | | | | | | | | | Given that the stated purpose of `CheckFailed()` is to provide a nice spot for a breakpoint, it'd be nice not to have to use a regex to break on it. Recover the ability to simply use `b CheckFailed` by specializing the message-only version, and by changing the variadic version to call into the message-only version. llvm-svn: 232268
* Fix an infinite recursion in the verifier caused by calling isSized on a ↵Owen Anderson2015-03-131-1/+2
| | | | | | recursive type. llvm-svn: 232143
* Fix another verifier crash where a GC intrinsic would look at the internals ↵Owen Anderson2015-03-111-0/+5
| | | | | | | | | | | of another intrinsic in order to verify itself. This causes a crash if the referenced intrinsic was malformed. In this case, we would already have reported an error on the referenced intrinsic, but then crashed on the second one when it tried to introspect the first without error checking. llvm-svn: 231910
* Fix an issue in the verifier where we could try to read information out of a ↵Owen Anderson2015-03-101-1/+5
| | | | | | | | | | malformed statepoint intrinsic. In this situation we would always have already flagged an error on the statepoint intrinsic, but then we carry on to parse other, related GC intrinsics, and could end up crashing during that verification when they try to access data from the malformed statepoint. llvm-svn: 231759
* Simplify expressions involving boolean constants with clang-tidyDavid Blaikie2015-03-091-2/+2
| | | | | | | | Patch by Richard (legalize at xmission dot com). Differential Revision: http://reviews.llvm.org/D8154 llvm-svn: 231617
* Make the assertion macros in Verifier and Linter truly variadic.Benjamin Kramer2015-03-071-923/+888
| | | | | | NFC. llvm-svn: 231577
* Remove accidental errs() call in VerifierReid Kleckner2015-03-051-1/+0
| | | | llvm-svn: 231391
* Replace llvm.frameallocate with llvm.frameescapeReid Kleckner2015-03-051-11/+44
| | | | | | | | | | Turns out it's pretty straightforward and simplifies the implementation. Reviewers: andrew.w.kaylor Differential Revision: http://reviews.llvm.org/D8051 llvm-svn: 231386
* Teach the verifier to enforce that the alignment argument of memory ↵Owen Anderson2015-03-021-2/+8
| | | | | | intrinsics must be a power of 2. llvm-svn: 230941
* Verifier: Unused comdats might not have a corresponding GVDavid Majnemer2015-02-201-8/+1
| | | | | | This fixes PR22646. llvm-svn: 230051
* Implement invoke statepoint verification.Igor Laevsky2015-02-191-9/+49
| | | | | | Differential Revision: http://reviews.llvm.org/D7366 llvm-svn: 229840
* Prefer SmallVector::append/insert over push_back loops.Benjamin Kramer2015-02-171-2/+1
| | | | | | Same functionality, but hoists the vector growth out of the loop. llvm-svn: 229500
* Verifier: Diagnose module flags which have null ID operandsDavid Majnemer2015-02-161-1/+1
| | | | llvm-svn: 229361
* IR: Add MDExpression::ExprOperandDuncan P. N. Exon Smith2015-02-131-0/+1
| | | | | | | | Port `DIExpression::Operand` over to `MDExpression::ExprOperand`. The logic is needed directly in `MDExpression` to support printing in assembly. llvm-svn: 229002
* Verifier: Check for null operands in !llvm.module.flagsDavid Majnemer2015-02-111-1/+1
| | | | llvm-svn: 228818
* Verifier: Make sure !llvm.ident's operand isn't nullDavid Majnemer2015-02-111-1/+1
| | | | llvm-svn: 228815
* Verifier: reuse getInlinedAt() result, NFCDuncan P. N. Exon Smith2015-02-101-3/+2
| | | | llvm-svn: 228655
* Verifier: Check for valid tags in debug nodesDuncan P. N. Exon Smith2015-02-101-21/+107
| | | | | | Check that specialized `DebugNode`s have valid `DW_TAG`s. llvm-svn: 228649
* Verifier: Add simple checks for MDLocationDuncan P. N. Exon Smith2015-02-101-1/+7
| | | | llvm-svn: 228647
* Verifier: Create stubs for specialized metadata nodesDuncan P. N. Exon Smith2015-02-101-0/+37
| | | | llvm-svn: 228645
* Verifier: Const-qualify Metadata, NFCDuncan P. N. Exon Smith2015-02-091-7/+7
| | | | llvm-svn: 228609
* Masked Gather and Scatter Intrinsics.Elena Demikhovsky2015-02-081-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Gather and Scatter are new introduced intrinsics, comming after recently implemented masked load and store. This is the first patch for Gather and Scatter intrinsics. It includes only the syntax, parsing and verification. Gather and Scatter intrinsics allow to perform multiple memory accesses (read/write) in one vector instruction. The intrinsics are not target specific and will have the following syntax: Gather: declare <16 x i32> @llvm.masked.gather.v16i32(<16 x i32*> <vector of ptrs>, i32 <alignment>, <16 x i1> <mask>, <16 x i32> <passthru>) declare <8 x float> @llvm.masked.gather.v8f32(<8 x float*><vector of ptrs>, i32 <alignment>, <8 x i1> <mask>, <8 x float><passthru>) Scatter: declare void @llvm.masked.scatter.v8i32(<8 x i32><vector value to be stored> , <8 x i32*><vector of ptrs> , i32 <alignment>, <8 x i1> <mask>) declare void @llvm.masked.scatter.v16i32(<16 x i32> <vector value to be stored> , <16 x i32*> <vector of ptrs>, i32 <alignment>, <16 x i1><mask> ) Vector of ptrs - a set of source/destination addresses, to load/store the value. Mask - switches on/off vector lanes to prevent memory access for switched-off lanes vector of ptrs, value and mask should have the same vector width. These are code examples where gather / scatter should be used and will allow function vectorization ;void foo1(int * restrict A, int * restrict B, int * restrict C) { ; for (int i=0; i<SIZE; i++) { ; A[i] = B[C[i]]; ; } ;} ;void foo3(int * restrict A, int * restrict B) { ; for (int i=0; i<SIZE; i++) { ; A[B[i]] = i+5; ; } ;} Tests will come in the following patches, with CodeGen and Vectorizer. http://reviews.llvm.org/D7433 llvm-svn: 228521
* Use ImmutableCallSite for statepoint verification.Philip Reames2015-02-031-17/+20
| | | | | | | | | | Patch by: Igor Laevsky "This change generalizes statepoint verification to use ImmutableCallSite instead of CallInst. This will allow to easily implement invoke statepoint verification (in a following change)." Differential Revision: http://reviews.llvm.org/D7308 llvm-svn: 228064
* Factor out statepoint verification into separate function. (NFC)Philip Reames2015-01-301-93/+102
| | | | | | | | | | Patch by: Igor Laevsky "Simple refactoring. This is done in preparation to support verification of invokable statepoints." Differential Revision: http://reviews.llvm.org/D7276 llvm-svn: 227640
* Intrinsics: introduce llvm_any_ty aka ValueType AnyRamkumar Ramachandra2015-01-221-1/+3
| | | | | | | | | | | | | | | Specifically, gc.result benefits from this greatly. Instead of: gc.result.int.* gc.result.float.* gc.result.ptr.* ... We now have a gc.result.* that can specialize to literally any type. Differential Revision: http://reviews.llvm.org/D7020 llvm-svn: 226857
* Make DIExpression::Verify() stricter by checking that the number ofAdrian Prantl2015-01-211-4/+12
| | | | | | elements and the ordering is sane and cleanup the accessors. llvm-svn: 226627
* [GC] Verify-pass void vararg functions in gc.statepointRamkumar Ramachandra2015-01-201-5/+13
| | | | | | | | | | With the appropriate Verifier changes, exactracting the result out of a statepoint wrapping a vararg function crashes. However, a void vararg function works fine: commit this first step. Differential Revision: http://reviews.llvm.org/D7071 llvm-svn: 226599
* IR: Remove MDNodeFwdDeclDuncan P. N. Exon Smith2015-01-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Standardize {pred,succ,use,user}_empty()Ramkumar Ramachandra2015-01-131-1/+1
| | | | | | | | | The functions {pred,succ,use,user}_{begin,end} exist, but many users have to check *_begin() with *_end() by hand to determine if the BasicBlock or User is empty. Fix this with a standard *_empty(), demonstrating a few usecases. llvm-svn: 225760
* Rename llvm.recoverframeallocation to llvm.framerecoverReid Kleckner2015-01-131-2/+2
| | | | | | | | This name is less descriptive, but it sort of puts things in the 'llvm.frame...' namespace, relating it to frameallocate and frameaddress. It also avoids using "allocate" and "allocation" together. llvm-svn: 225752
* Add the llvm.frameallocate and llvm.recoverframeallocation intrinsicsReid Kleckner2015-01-131-2/+27
| | | | | | | | | | | | | | | | | | | | | These intrinsics allow multiple functions to share a single stack allocation from one function's call frame. The function with the allocation may only perform one allocation, and it must be in the entry block. Functions accessing the allocation call llvm.recoverframeallocation with the function whose frame they are accessing and a frame pointer from an active call frame of that function. These intrinsics are very difficult to inline correctly, so the intention is that they be introduced rarely, or at least very late during EH preparation. Reviewers: echristo, andrew.w.kaylor Differential Revision: http://reviews.llvm.org/D6493 llvm-svn: 225746
* [GC] improve testing around gc.relocate and fix a testPhilip Reames2015-01-071-9/+32
| | | | | | | | | | | | | | | Patch by: Ramkumar Ramachandra <artagnon@gmail.com> "This patch started out as an exploration of gc.relocate, and an attempt to write a simple test in call-lowering. I then noticed that the arguments of gc.relocate were not checked fully, so I went in and fixed a few things. Finally, the most important outcome of this patch is that my new error handling code caught a bug in a callsite in stackmap-format." Differential Revision: http://reviews.llvm.org/D6824 llvm-svn: 225412
* [PM] Switch the new pass manager to use a reference-based API for IRChandler Carruth2015-01-051-4/+4
| | | | | | | | | | | | | | | | | | | | | units. This was debated back and forth a bunch, but using references is now clearly cleaner. Of all the code written using pointers thus far, in only one place did it really make more sense to have a pointer. In most cases, this just removes immediate dereferencing from the code. I think it is much better to get errors on null IR units earlier, potentially at compile time, than to delay it. Most notably, the legacy pass manager uses references for its routines and so as more and more code works with both, the use of pointers was likely to become really annoying. I noticed this when I ported the domtree analysis over and wrote the entire thing with references only to have it fail to compile. =/ It seemed better to switch now than to delay. We can, of course, revisit this is we learn that references are really problematic in the API. llvm-svn: 225145
* Masked Load/Store - Changed the order of parameters in intrinsics.Elena Demikhovsky2014-12-251-0/+7
| | | | | | | No functional changes. The documentation is coming. llvm-svn: 224829
* Use CastInst::castIsValid to simplify the verifier.Rafael Espindola2014-12-161-47/+9
| | | | | | Also delete a dead member variable. llvm-svn: 224356
* IR: Split Metadata from ValueDuncan P. N. Exon Smith2014-12-091-42/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Masked Load / Store Intrinsics - the CodeGen part.Elena Demikhovsky2014-12-041-0/+13
| | | | | | | | | | | | | | | | | | I'm recommiting the codegen part of the patch. The vectorizer part will be send to review again. Masked Vector Load and Store Intrinsics. Introduced new target-independent intrinsics in order to support masked vector loads and stores. The loop vectorizer optimizes loops containing conditional memory accesses by generating these intrinsics for existing targets AVX2 and AVX-512. The vectorizer asks the target about availability of masked vector loads and stores. Added SDNodes for masked operations and lowering patterns for X86 code generator. Examples: <16 x i32> @llvm.masked.load.v16i32(i8* %addr, <16 x i32> %passthru, i32 4 /* align */, <16 x i1> %mask) declare void @llvm.masked.store.v8f64(i8* %addr, <8 x double> %value, i32 4, <8 x i1> %mask) Scalarizer for other targets (not AVX2/AVX-512) will be done in a separate patch. http://reviews.llvm.org/D6191 llvm-svn: 223348
* A few more checks for gc.statepoints in the VerifierPhilip Reames2014-12-041-0/+11
| | | | | | | | | This is simply a grab bag of unrelated checks: - A statepoint call can't be marked readonly or readnone - We don't currently support inline asm or varadic target functions. Both could be supported, but don't currently work. - I forgot to check that the number of call arguments actually matched the wrapped callee in my previous change. Included here. llvm-svn: 223322
OpenPOWER on IntegriCloud