[all-commits] [llvm/llvm-project] cd03e9: [flang] Add & use a better visit() (take 2)
Peter Klausler via All-commits
all-commits at lists.llvm.org
Sat Apr 16 16:01:09 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cd03e96f00a8ab2489ae5af79375de2207f4e0ab
https://github.com/llvm/llvm-project/commit/cd03e96f00a8ab2489ae5af79375de2207f4e0ab
Author: Peter Klausler <pklausler at nvidia.com>
Date: 2022-04-16 (Sat, 16 Apr 2022)
Changed paths:
M flang/include/flang/Common/idioms.h
M flang/include/flang/Common/template.h
M flang/include/flang/Common/unwrap.h
A flang/include/flang/Common/visit.h
M flang/include/flang/Evaluate/expression.h
M flang/include/flang/Evaluate/fold-designator.h
M flang/include/flang/Evaluate/initial-image.h
M flang/include/flang/Evaluate/shape.h
M flang/include/flang/Evaluate/tools.h
M flang/include/flang/Evaluate/traverse.h
M flang/include/flang/Parser/parse-tree-visitor.h
M flang/include/flang/Parser/tools.h
M flang/include/flang/Semantics/expression.h
M flang/include/flang/Semantics/symbol.h
M flang/include/flang/Semantics/tools.h
M flang/lib/Evaluate/call.cpp
M flang/lib/Evaluate/characteristics.cpp
M flang/lib/Evaluate/check-expression.cpp
M flang/lib/Evaluate/expression.cpp
M flang/lib/Evaluate/fold-designator.cpp
M flang/lib/Evaluate/fold-implementation.h
M flang/lib/Evaluate/fold-integer.cpp
M flang/lib/Evaluate/fold-logical.cpp
M flang/lib/Evaluate/fold-real.cpp
M flang/lib/Evaluate/fold.cpp
M flang/lib/Evaluate/formatting.cpp
M flang/lib/Evaluate/shape.cpp
M flang/lib/Evaluate/tools.cpp
M flang/lib/Evaluate/type.cpp
M flang/lib/Evaluate/variable.cpp
M flang/lib/Parser/message.cpp
M flang/lib/Parser/parse-tree.cpp
M flang/lib/Parser/provenance.cpp
M flang/lib/Parser/tools.cpp
M flang/lib/Parser/unparse.cpp
M flang/lib/Semantics/canonicalize-do.cpp
M flang/lib/Semantics/check-allocate.cpp
M flang/lib/Semantics/check-call.cpp
M flang/lib/Semantics/check-case.cpp
M flang/lib/Semantics/check-data.cpp
M flang/lib/Semantics/check-deallocate.cpp
M flang/lib/Semantics/check-declarations.cpp
M flang/lib/Semantics/check-do-forall.cpp
M flang/lib/Semantics/check-io.cpp
M flang/lib/Semantics/check-nullify.cpp
M flang/lib/Semantics/check-omp-structure.cpp
M flang/lib/Semantics/check-select-rank.cpp
M flang/lib/Semantics/check-select-type.cpp
M flang/lib/Semantics/data-to-inits.cpp
M flang/lib/Semantics/expression.cpp
M flang/lib/Semantics/mod-file.cpp
M flang/lib/Semantics/pointer-assignment.cpp
M flang/lib/Semantics/program-tree.cpp
M flang/lib/Semantics/resolve-directives.cpp
M flang/lib/Semantics/resolve-names-utils.cpp
M flang/lib/Semantics/resolve-names.cpp
M flang/lib/Semantics/rewrite-parse-tree.cpp
M flang/lib/Semantics/runtime-type-info.cpp
M flang/lib/Semantics/symbol.cpp
M flang/lib/Semantics/tools.cpp
M flang/runtime/io-stmt.cpp
M flang/runtime/io-stmt.h
Log Message:
-----------
[flang] Add & use a better visit() (take 2)
Adds flang/include/flang/Common/log2-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.
This change is enabled only for GCC builds with GCC >= 9;
an earlier attempt (D122441) ran into bugs in some versions of
clang and was reverted rather than simply disabled; and it is
not well tested with MSVC. In non-GCC and older GCC builds,
common::visit() is simply an alias for std::visit().
More information about the All-commits
mailing list