Skip to content

Commit

Permalink
[flang] Remove needless "anyIntrinsicDefinedOps", fixing iterative ex…
Browse files Browse the repository at this point in the history
…pr analysis

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.

Differential Revision: https://reviews.llvm.org/D159022
  • Loading branch information
klausler committed Aug 29, 2023
1 parent de0df63 commit 2a30a6d
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 15 deletions.
9 changes: 0 additions & 9 deletions flang/include/flang/Semantics/semantics.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,6 @@ class SemanticsContext {
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);

Expand Down Expand Up @@ -286,7 +278,6 @@ class SemanticsContext {
const Scope *ppcBuiltinsScope_{nullptr}; // module __ppc_intrinsics
std::list<parser::Program> modFileParseTrees_;
std::unique_ptr<CommonBlockMap> commonBlockMap_;
bool anyDefinedIntrinsicOperator_{false};
};

class Semantics {
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Semantics/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3584,7 +3584,7 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::Expr &expr) {
if (expr.typedExpr) {
return expr.typedExpr->v;
}
if (!wasIterativelyAnalyzing && !context_.anyDefinedIntrinsicOperator()) {
if (!wasIterativelyAnalyzing) {
iterativelyAnalyzingSubexpressions_ = true;
result = IterativelyAnalyzeSubexpressions(expr);
}
Expand Down
5 changes: 0 additions & 5 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3269,11 +3269,6 @@ bool InterfaceVisitor::Pre(const parser::GenericSpec &x) {
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;
}

Expand Down

0 comments on commit 2a30a6d

Please sign in to comment.