[all-commits] [llvm/llvm-project] b617df: [flang] Avoid crashing from recursion on very tall...

Peter Klausler via All-commits all-commits at lists.llvm.org
Wed Feb 1 14:42:55 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b617df6e7cbc35230a4b7140cf66dabebe9700e7
      https://github.com/llvm/llvm-project/commit/b617df6e7cbc35230a4b7140cf66dabebe9700e7
  Author: Peter Klausler <pklausler at nvidia.com>
  Date:   2023-02-01 (Wed, 01 Feb 2023)

  Changed paths:
    M flang/include/flang/Parser/parse-tree-visitor.h
    M flang/include/flang/Semantics/expression.h
    M flang/lib/Semantics/expression.cpp
    A flang/test/Evaluate/big-expr-tree.F90

  Log Message:
  -----------
  [flang] Avoid crashing from recursion on very tall expression parse trees

In the parse tree visitation framework (Parser/parse-tree-visitor.h)
and in the semantic analyzer for expressions (Semantics/expression.cpp)
avoid crashing due to stack size limitations by using an iterative
traversal algorithm rather than straightforward recursive tree walking.
The iterative approach is the obvious one of building a work queue and
using it to (in the case of the parse tree visitor) call the visitor
object's Pre() and Post() routines on subexpressions in the same order
as they would have been called during a recursive traversal.

This change helps the compiler survive some artificial stress tests
and perhaps with future exposure to machine-generated source code.

Differential Revision: https://reviews.llvm.org/D142771




More information about the All-commits mailing list