[all-commits] [llvm/llvm-project] 2ab999: [flang] Add & use a better visit()

Peter Klausler via All-commits all-commits at lists.llvm.org
Fri Mar 25 13:15:37 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2ab9990c9eb79682a4d4b183dfbc7612d3e55328
      https://github.com/llvm/llvm-project/commit/2ab9990c9eb79682a4d4b183dfbc7612d3e55328
  Author: Peter Klausler <pklausler at nvidia.com>
  Date:   2022-03-25 (Fri, 25 Mar 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()

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




More information about the All-commits mailing list