[all-commits] [llvm/llvm-project] ea3874: [flang] Lowering passing variables to OPTIONAL VALUE

Valentin Clement (バレンタイン クレメン) via All-commits all-commits at lists.llvm.org
Thu Jun 23 04:45:55 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ea3874437274e5d37e51819dd0109a66b087c251
      https://github.com/llvm/llvm-project/commit/ea3874437274e5d37e51819dd0109a66b087c251
  Author: Valentin Clement <clementval at gmail.com>
  Date:   2022-06-23 (Thu, 23 Jun 2022)

  Changed paths:
    M flang/lib/Lower/ConvertExpr.cpp
    M flang/test/Lower/call-by-value-attr.f90
    A flang/test/Lower/optional-value-caller.f90

  Log Message:
  -----------
  [flang] Lowering passing variables to OPTIONAL VALUE

The case where the dummy argument is OPTIONAL was missing in the
handling of VALUE numerical and logical dummies (passBy::BaseAddressValueAttribute).
This caused segfaults while unconditionally copying actual arguments that were legally
absent at runtime.

Takes this bug as an opportunity to share the code that lowers arguments
that must be passed by BaseAddress, BaseAddressValueAttribute, BoxChar,
and CharBoxValueAttribute.
It has to deal with the exact same issues (being able to make contiguous
copies of the actual argument, potentially conditionally at runtime,
and potentially requiring a copy-back).
The VALUE case is the same as the non value case, except there is never
a copy-back and there is always a copy-in for variables. This two
differences are easily controlled by a byValue flag.

This as the benefit of implementing CHARACTER, VALUE for free that was
previously a hard TODO.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: kiranchandramohan

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

Co-authored-by: Jean Perier <jperier at nvidia.com>




More information about the All-commits mailing list