[all-commits] [llvm/llvm-project] 29d857: [flang] Add stack reclaim pass to reclaim allocas ...

Valentin Clement (バレンタイン クレメン) via All-commits all-commits at lists.llvm.org
Fri Jun 14 10:22:20 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29d857f183fe6159c3265d6cee8c87419eb615ad
      https://github.com/llvm/llvm-project/commit/29d857f183fe6159c3265d6cee8c87419eb615ad
  Author: Valentin Clement (バレンタイン クレメン) <clementval at gmail.com>
  Date:   2024-06-14 (Fri, 14 Jun 2024)

  Changed paths:
    M flang/include/flang/Optimizer/Transforms/Passes.h
    M flang/include/flang/Optimizer/Transforms/Passes.td
    M flang/include/flang/Tools/CLOptions.inc
    M flang/lib/Optimizer/Transforms/CMakeLists.txt
    A flang/lib/Optimizer/Transforms/StackReclaim.cpp
    M flang/test/Driver/bbc-mlir-pass-pipeline.f90
    M flang/test/Driver/mlir-debug-pass-pipeline.f90
    M flang/test/Driver/mlir-pass-pipeline.f90
    M flang/test/Fir/basic-program.fir
    A flang/test/Transforms/stack-reclaime.fir

  Log Message:
  -----------
  [flang] Add stack reclaim pass to reclaim allocas in loop (#95309)

Some passes in the flang pipeline are creating `fir.alloca` operation
like `hlfir.concat`. When these allocas are located in a loop, the stack
can quickly be used too much leading to segfaults.

This behavior can be seen in
https://github.com/jacobwilliams/json-fortran/blob/master/src/tests/jf_test_36.F90

This patch insert a call to LLVM stacksave/stackrestore in the body of
the loop to reclaim the alloca in its scope.

This PR is an alternative implementation to #95173



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list