[flang-commits] [PATCH] D159022: [flang] Remove needless "anyIntrinsicDefinedOps", fixing iterative expr analysis

Peter Klausler via Phabricator via flang-commits flang-commits at lists.llvm.org
Mon Aug 28 15:01:12 PDT 2023


klausler created this revision.
klausler added a reviewer: vdonaldson.
klausler added a project: Flang.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
klausler requested review of this revision.

The flag "anyIntrinsicDefinedOps" is always set nowadays, as there are intrinsic
modules that define operator(==) and (!=).  This disables the iterative
expression analysis mechanism, also unnecessarily, and it is possible to
overflow the stack when analyzing very deep expression trees like the ones
that show up in artificial stress tests.  Remove the flag.


https://reviews.llvm.org/D159022

Files:
  flang/include/flang/Semantics/semantics.h
  flang/lib/Semantics/expression.cpp
  flang/lib/Semantics/resolve-names.cpp


Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -3269,11 +3269,6 @@
   if (auto *symbol{FindInScope(GenericSpecInfo{x}.symbolName())}) {
     SetGenericSymbol(*symbol);
   }
-  if (const auto *opr{std::get_if<parser::DefinedOperator>(&x.u)}; opr &&
-      std::holds_alternative<parser::DefinedOperator::IntrinsicOperator>(
-          opr->u)) {
-    context().set_anyDefinedIntrinsicOperator(true);
-  }
   return false;
 }
 
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -3584,7 +3584,7 @@
     if (expr.typedExpr) {
       return expr.typedExpr->v;
     }
-    if (!wasIterativelyAnalyzing && !context_.anyDefinedIntrinsicOperator()) {
+    if (!wasIterativelyAnalyzing) {
       iterativelyAnalyzingSubexpressions_ = true;
       result = IterativelyAnalyzeSubexpressions(expr);
     }
Index: flang/include/flang/Semantics/semantics.h
===================================================================
--- flang/include/flang/Semantics/semantics.h
+++ flang/include/flang/Semantics/semantics.h
@@ -144,14 +144,6 @@
     return *this;
   }
 
-  bool anyDefinedIntrinsicOperator() const {
-    return anyDefinedIntrinsicOperator_;
-  }
-  SemanticsContext &set_anyDefinedIntrinsicOperator(bool yes = true) {
-    anyDefinedIntrinsicOperator_ = yes;
-    return *this;
-  }
-
   const DeclTypeSpec &MakeNumericType(TypeCategory, int kind = 0);
   const DeclTypeSpec &MakeLogicalType(int kind = 0);
 
@@ -286,7 +278,6 @@
   const Scope *ppcBuiltinsScope_{nullptr}; // module __ppc_intrinsics
   std::list<parser::Program> modFileParseTrees_;
   std::unique_ptr<CommonBlockMap> commonBlockMap_;
-  bool anyDefinedIntrinsicOperator_{false};
 };
 
 class Semantics {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159022.554064.patch
Type: text/x-patch
Size: 1962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230828/f5622d79/attachment-0001.bin>


More information about the flang-commits mailing list