summaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/check-nullify.cpp
diff options
context:
space:
mode:
authorPeter Klausler <pklausler@nvidia.com>2022-03-23 14:05:50 -0700
committerPeter Klausler <pklausler@nvidia.com>2022-04-16 16:00:48 -0700
commitcd03e96f00a8ab2489ae5af79375de2207f4e0ab (patch)
tree7ec29e507ad4ede017fbdbf35fdcabeb0ecb373d /flang/lib/Semantics/check-nullify.cpp
parentc6fdb1de47bd5f26868838c37fa9e8cc1ac484bf (diff)
[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().
Diffstat (limited to 'flang/lib/Semantics/check-nullify.cpp')
-rw-r--r--flang/lib/Semantics/check-nullify.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/flang/lib/Semantics/check-nullify.cpp b/flang/lib/Semantics/check-nullify.cpp
index 9ee45541fd5c..6b3c8d4daf0f 100644
--- a/flang/lib/Semantics/check-nullify.cpp
+++ b/flang/lib/Semantics/check-nullify.cpp
@@ -23,7 +23,7 @@ void NullifyChecker::Leave(const parser::NullifyStmt &nullifyStmt) {
parser::ContextualMessages messages{
*context_.location(), &context_.messages()};
for (const parser::PointerObject &pointerObject : nullifyStmt.v) {
- std::visit(
+ common::visit(
common::visitors{
[&](const parser::Name &name) {
const Symbol *symbol{name.symbol};