summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Verifier.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Verifier: Check operands of MDType subclasses and MDCompileUnitDuncan P. N. Exon Smith2015-03-271-0/+80
| | | | | | | | | | | | | | | | | Add verify checks for `MDType` subclasses and for `MDCompileUnit`. These new checks don't yet incorporate everything from `Verify()`, but at least they sanity check the operands. Also downcast accessors as possible. A lot of these accessors can't be downcast as far as we'd like because of arrays of typed objects (stored in a generic `MDTuple`) and `MDString`-based type references. Eventually I'll port over `DIRef<>` and `DITypedArray<>` from `DebugInfo.h` to clean those up as well. Updated bitrotted testcases separately in r233415 and r233443 to reduce churn on the off-chance this needs to be reverted. llvm-svn: 233446
* Verifier: Check fields of MDVariable subclassesDuncan P. N. Exon Smith2015-03-271-0/+38
| | | | | | | | | | | | | | | | Check fields from `MDLocalVariable` and `MDGlobalVariable` and change the accessors to downcast to the right types. `getType()` still returns `Metadata*` since it could be an `MDString`-based reference. Since local variables require non-null scopes, I also updated `LLParser` to require a `scope:` field. A number of testcases had grown bitrot and started failing with this patch; I committed them separately in r233349. If I just broke your out-of-tree testcases, you're probably hitting similar problems (so have a look there). llvm-svn: 233389
* Require a GC strategy be specified for functions which use gc.statepointPhilip Reames2015-03-271-0/+4
| | | | | | This was discussed a while back and I left it optional for migration. Since it's been far more than the 'week or two' that was discussed, time to actually make this manditory. llvm-svn: 233357
* WinEH: Create a parent frame alloca for HandlerType xdata tablesDavid Majnemer2015-03-271-0/+7
| | | | | | | | We don't have any logic to emit those tables yet, so the SDAG lowering of this intrinsic is just a stub. We can see the intrinsic in the prepared IR, though. llvm-svn: 233354
* Verifier: Check accessors of MDLocationDuncan P. N. Exon Smith2015-03-261-2/+3
| | | | | | | | | | | | | | | | | | | | Check accessors of `MDLocation`, and change them to `cast<>` down to the right types. Also add type-safe factory functions. All the callers that handle broken code need to use the new versions of the accessors (`getRawScope()` instead of `getScope()`) that still return `Metadata*`. This is also necessary for things like `MDNodeKeyImpl<MDLocation>` (in LLVMContextImpl.h) that need to unique the nodes when their operands might still be forward references of the wrong type. In the `Value` hierarchy, consumers that handle broken code use `getOperand()` directly. However, debug info nodes have a ton of operands, and their order (even their existence) isn't stable yet. It's safer and more maintainable to add an explicit "raw" accessor on the class itself. llvm-svn: 233322
* WinEH: Create an unwind help alloca for __CxxFrameHandler3 xdata tablesReid Kleckner2015-03-251-0/+7
| | | | | | | | We don't have any logic to emit those tables yet, so the sdag lowering of this intrinsic is just a stub. We can see the intrinsic in the prepared IR, though. llvm-svn: 233209
* Verifier: Start recursing into !dbg attachmentsDuncan P. N. Exon Smith2015-03-241-4/+2
| | | | | | | | | | The main verifier already recurses through the other entry points, so we might as well descend here too. This temporarily duplicates some work already done in `verifyDebugInfo()`, but eventually I'll be removing the other side. llvm-svn: 233095
* Verifier: !llvm.dbg.cu must point at compile unitsDuncan P. N. Exon Smith2015-03-241-0/+11
| | | | | | Duplicate this check from `verifyDebugInfo()`. llvm-svn: 233094
* Verifier: Check that !dbg attachments have the right typeDuncan P. N. Exon Smith2015-03-201-0/+7
| | | | | | | | | | | | | | | A WIP patch makes `DIDescriptor` accessors more strict, which in turn causes the `DebugInfoFinder` to crash on wrongly typed `!dbg` attachments. Catch that error up front in `Verifier::visitInstruction()`. Also remove a test that we "handle" invalid `!dbg` attachments, added back in r99938. We don't want to handle those anymore. Note: I'm *not* recursing and verifying the debug info graph reachable from this node; that work is already done by `verifyDebugInfo()`. llvm-svn: 232834
* Verifier: Remove the separate DebugInfoVerifier classDuncan P. N. Exon Smith2015-03-201-28/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove the separate `DebugInfoVerifier` class, as a partial step toward better integrating debug info verification with the `Verifier`. Right now, verification of debug info is kind of a mess. - There are `DIDescriptor::Verify()` checks live in `DebugInfo.cpp`. These return `bool`, and there's no way to see (except by opening a debugger) why they fail. - We rely on `DebugInfoFinder` to traverse the debug info graph and dig up nodes. However, the regular `Verifier` visits many of these nodes when it calls into debug info intrinsic operands. Visiting twice and running different checks is kind of absurd. - Moreover, `DebugInfoFinder` asserts on failed type resolution -- the verifier should never assert! By integrating the two verifiers, I'm aiming at solving these problems (work to be done, obviously). Verification can be localized to the `Verifier`; we can use a naive `MDNode` operand traversal to find all the nodes; we can verify type references instead of asserting on failure. There are `assert()`s sprinkled throughout the optimizer and dwarf backend on `DIDescriptor::Verify()` checks. This is a hangover from when the debug info verifier was off, so I plan to remove them as I go (once I confirm that the checks are done at verification time). Note: to keep the behaviour of only running the debug info verifier when -verify succeeds, I've added an `EverBroken` flag. Once the `DebugInfoFinder` assertions are gone and the two traversals have been merged, I expect to be able to remove this. llvm-svn: 232790
* Verifier: Remove the separate -verify-di passDuncan P. N. Exon Smith2015-03-191-32/+2
| | | | | | | | | | | | | | Remove `DebugInfoVerifierLegacyPass` and the `-verify-di` pass. Instead, call into the `DebugInfoVerifier` from inside `VerifierLegacyPass::finalizeModule()`. This better matches the logic in `verifyModule()` (used by the new PassManager), avoids requiring two separate passes to verify the IR, and makes the API for "add a pass to verify the IR" simple. Note: the `-verify-debug-info` flag still works (for now, at least; eventually it might make sense to just remove it). llvm-svn: 232772
* 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
OpenPOWER on IntegriCloud