summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/IR/BasicBlockTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [STLExtras] Add size() for ranges, and remove distance()Vedant Kumar2018-05-161-3/+4
| | | | | | | | | | r332057 introduced distance() for ranges. Based on post-commit feedback, this renames distance() to size(). The new size() is also only enabled when the operation is O(1). Differential Revision: https://reviews.llvm.org/D46976 llvm-svn: 332551
* [STLExtras] Add distance() for ranges, pred_size(), and succ_size()Vedant Kumar2018-05-101-4/+3
| | | | | | | | | | | This commit adds a wrapper for std::distance() which works with ranges. As it would be a common case to write `distance(predecessors(BB))`, this also introduces `pred_size()` and `succ_size()` helpers to make that easier to write. Differential Revision: https://reviews.llvm.org/D46668 llvm-svn: 332057
* [ADT] Make filter_iterator support bidirectional iterationVedant Kumar2018-04-251-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it possible to reverse a filtered range. For example, here's a way to visit memory accesses in a BasicBlock in reverse order: auto MemInsts = reverse(make_filter_range(BB, [](Instruction &I) { return isa<StoreInst>(&I) || isa<LoadInst>(&I); })); for (auto &MI : MemInsts) ... To implement this functionality, I factored out forward iteration functionality into filter_iterator_base, and added a specialization of filter_iterator_impl which supports bidirectional iteration. Thanks to Tim Shen, Zachary Turner, and others for suggesting this design and providing feedback! This version of the patch supersedes the original (https://reviews.llvm.org/D45792). This was motivated by a problem we encountered in D45657: we'd like to visit the non-debug-info instructions in a BasicBlock in reverse order. Testing: check-llvm, check-clang Differential Revision: https://reviews.llvm.org/D45853 llvm-svn: 330875
* [IR/BasicBlockTest] Fix asan failure introduced in rL330316.Florian Hahn2018-04-191-7/+10
| | | | | | | The argument has to be deleted after the module containing the function gets deleted. llvm-svn: 330320
* [BasicBlock] Add instructionsWithoutDebug methods to skip debug insts.Florian Hahn2018-04-191-0/+39
| | | | | | | | | | Reviewers: aprantl, vsk, mattd, chandlerc Reviewed By: aprantl, vsk Differential Revision: https://reviews.llvm.org/D45657 llvm-svn: 330316
* IR: Fix BasicBlock::phis for empty blocksMatt Arsenault2017-12-291-0/+6
| | | | llvm-svn: 321567
* Remove unnecessary double-assignment triggering -Wsequence-point.Daniel Jasper2017-05-261-1/+1
| | | | llvm-svn: 303974
* [IR] Add an iterator and range accessor for the PHI nodes of a basicChandler Carruth2017-05-261-0/+75
block. This allows writing much more natural and readable range based for loops directly over the PHI nodes. It also takes advantage of the same tricks for terminating the sequence as the hand coded versions. I've replaced one example of this mostly to showcase the difference and I've added a unit test to make sure the facilities really work the way they're intended. I want to use this inside of SimpleLoopUnswitch but it seems generally nice. Differential Revision: https://reviews.llvm.org/D33533 llvm-svn: 303964
OpenPOWER on IntegriCloud