[flang-commits] [PATCH] D143636: [flang][hlfir] Ramp-up support of implicit interface mismatches

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Feb 9 03:11:31 PST 2023


jeanPerier created this revision.
jeanPerier added reviewers: clementval, vdonaldson.
jeanPerier added a project: Flang.
Herald added subscribers: bzcheeseman, sunshaoce, mehdi_amini, rriddle, jdoerfert.
Herald added a project: All.
jeanPerier requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added a subscriber: stephenneuendorffer.

There is a lot of Fortran code that takes advantage of F77 <https://reviews.llvm.org/F77> implicit
interface to pass arguments with a different type than those from
the subprogram definition (which is well defined if the storage
and passing convention are the same or compatible).

When the definition and calls are in different files, there is nothing
special to do: the actual arguments are already used to compute the
call interface.

The trouble for lowering comes when the definition is in the same
compilation unit (Semantics raises warning). Then, lowering will
be provided with the interface from the definition to prepare the
argument, and this leads to many ad-hoc handling (see
builder.convertWithSemantics) in the current lowering to cope
with the dummy/actual mismatches on a case by case basis. The
current lowering to FIR is not even complete for all mismatch cases that
can be found in the wild (see https://github.com/llvm/llvm-project/issues/60550),
it is crashing or hitting asserts for many of the added tests.

For HLFIR, instead of coping on a case by case basis, the call
interface will be recomputed according to the actual arguments when
calling an external procedure that can be called with an explicit
interface.

One extra case still has to be handled manually because it may happen
in calls with explicit interfaces: passing a character procedure
designator to a non character procedure dummy (and vice-versa) is widely
accepted even with explicit interfaces (and flang semantic accepts it).
Yet, this "mismatch" cannot be dealt with a simple fir.convert because
character dummy procedure are passed with a different passing
convention: an extra argument is hoisted for the result length (in FIR,
there is no extra argument yet, but the MLIR func argument is a
tuple<fir.boxproc, len>).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143636

Files:
  flang/include/flang/Optimizer/Dialect/FIROps.td
  flang/lib/Lower/CallInterface.cpp
  flang/lib/Lower/ConvertCall.cpp
  flang/lib/Optimizer/Dialect/FIROps.cpp
  flang/test/Lower/HLFIR/implicit-call-mismatch.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143636.496065.patch
Type: text/x-patch
Size: 23818 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230209/b708d2b5/attachment-0001.bin>


More information about the flang-commits mailing list