diff options
author | Peter Klausler <pklausler@nvidia.com> | 2022-03-23 14:05:50 -0700 |
---|---|---|
committer | Peter Klausler <pklausler@nvidia.com> | 2022-03-25 13:15:20 -0700 |
commit | 2ab9990c9eb79682a4d4b183dfbc7612d3e55328 (patch) | |
tree | e1b50758c6f96949781fce6536d191c60ab64b30 /flang/lib/Semantics/pointer-assignment.cpp | |
parent | e25f4e4c4a6df1d9f84e9506d2391fb0019bc941 (diff) | |
download | llvm-2ab9990c9eb79682a4d4b183dfbc7612d3e55328.zip llvm-2ab9990c9eb79682a4d4b183dfbc7612d3e55328.tar.gz llvm-2ab9990c9eb79682a4d4b183dfbc7612d3e55328.tar.bz2 |
[flang] Add & use a better visit()
Adds flang/include/flang/Common/visit.h, which defines
a Fortran::common::visit() template function that is a drop-in
replacement for std::visit(). Modifies most use sites in
the front-end and runtime to use common::visit().
The C++ standard mandates that std::visit() have O(1) execution
time, which forces implementations to build dispatch tables.
This new common::visit() is O(log2 N) in the number of alternatives
in a variant<>, but that N tends to be small and so this change
produces a fairly significant improvement in compiler build
memory requirements, a 5-10% improvement in compiler build time,
and a small improvement in compiler execution time.
Building with -DFLANG_USE_STD_VISIT causes common::visit()
to be an alias for std::visit().
Calls to common::visit() with multiple variant arguments
are referred to std::visit(), pending further work.
Differential Revision: https://reviews.llvm.org/D122441
Diffstat (limited to 'flang/lib/Semantics/pointer-assignment.cpp')
-rw-r--r-- | flang/lib/Semantics/pointer-assignment.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/flang/lib/Semantics/pointer-assignment.cpp b/flang/lib/Semantics/pointer-assignment.cpp index 2b065253..d55fa16 100644 --- a/flang/lib/Semantics/pointer-assignment.cpp +++ b/flang/lib/Semantics/pointer-assignment.cpp @@ -117,7 +117,7 @@ template <typename T> bool PointerAssignmentChecker::Check(const T &) { template <typename T> bool PointerAssignmentChecker::Check(const evaluate::Expr<T> &x) { - return std::visit([&](const auto &x) { return Check(x); }, x.u); + return common::visit([&](const auto &x) { return Check(x); }, x.u); } bool PointerAssignmentChecker::Check(const SomeExpr &rhs) { @@ -128,7 +128,7 @@ bool PointerAssignmentChecker::Check(const SomeExpr &rhs) { Say("A coindexed object may not be a pointer target"_err_en_US); return false; } else { - return std::visit([&](const auto &x) { return Check(x); }, rhs.u); + return common::visit([&](const auto &x) { return Check(x); }, rhs.u); } } @@ -322,7 +322,7 @@ static bool CheckPointerBounds( const SomeExpr &lhs{assignment.lhs}; const SomeExpr &rhs{assignment.rhs}; bool isBoundsRemapping{false}; - std::size_t numBounds{std::visit( + std::size_t numBounds{common::visit( common::visitors{ [&](const evaluate::Assignment::BoundsSpec &bounds) { return bounds.size(); |