hanchenye-llvm-project/llvm
Vedant Kumar 75fda2e0a5 [ADT] Make filter_iterator support bidirectional iteration
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
2018-04-25 21:50:09 +00:00
..
bindings [AggressiveInstCombine] Add aggressive inst combiner to the LLVM C API. 2018-04-24 00:39:29 +00:00
cmake Rename Attributes.gen, Intrinsics.gen to Attributes.inc, Intrinsics.inc 2018-04-25 17:07:46 +00:00
docs Revert r330755 "[lit] Report line number for failed RUN command" 2018-04-25 17:30:00 +00:00
examples Fix build breaks in examples due to moving stuff from Scalar.h to InstCombine.h 2018-04-24 00:58:57 +00:00
include [ADT] Make filter_iterator support bidirectional iteration 2018-04-25 21:50:09 +00:00
lib [CostModel][X86] Remove hard coded SDIV/UDIV vector costs 2018-04-25 20:59:16 +00:00
projects
resources
runtimes [CMake][runtimes] Process common options in runtimes build 2018-04-11 05:18:03 +00:00
test [AMDGPU] Waitcnt pass: add debug options 2018-04-25 19:21:26 +00:00
tools IWYU llvm-config.h for LLVM_VERSION_STRING 2018-04-25 18:34:00 +00:00
unittests [ADT] Make filter_iterator support bidirectional iteration 2018-04-25 21:50:09 +00:00
utils Revert r330755 "[lit] Report line number for failed RUN command" 2018-04-25 17:30:00 +00:00
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt Remove LLVM_INSTALL_CCTOOLS_SYMLINKS 2018-04-24 15:41:02 +00:00
CODE_OWNERS.TXT [CODE_OWNERS] Update my email address. 2018-04-23 19:09:49 +00:00
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

Low Level Virtual Machine (LLVM)
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.