[all-commits] [llvm/llvm-project] 4943db: [flang] Support lowering of C_PTR and C_FUNPTR arg...

PeixinQiao via All-commits all-commits at lists.llvm.org
Mon Aug 29 07:31:04 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4943dbdf67bad8ddb6dbb6e31e4ce9a80ffd9097
      https://github.com/llvm/llvm-project/commit/4943dbdf67bad8ddb6dbb6e31e4ce9a80ffd9097
  Author: Peixin Qiao <qiaopeixin at huawei.com>
  Date:   2022-08-29 (Mon, 29 Aug 2022)

  Changed paths:
    M flang/include/flang/Evaluate/tools.h
    M flang/include/flang/Lower/CallInterface.h
    M flang/include/flang/Optimizer/Dialect/FIRType.h
    M flang/lib/Evaluate/tools.cpp
    M flang/lib/Lower/Bridge.cpp
    M flang/lib/Lower/CallInterface.cpp
    M flang/lib/Lower/ConvertExpr.cpp
    A flang/test/Lower/c-interoperability-c-pointer.f90

  Log Message:
  -----------
  [flang] Support lowering of C_PTR and C_FUNPTR argument with VALUE attribute

As Fortran 2018 18.3.2, C_PTR is interoperable with any C object pointer
type. C_FUNPTR is interoperable with any C function pointer type. As
18.3.6, a C pointer can correspond to a Fortran dummy argument of type
C_PTR with the VALUE attribute.

The interface for type(C_PTR)/type(C_FUNPTR) argument with value
attribute is different from the the usual derived type. For type(C_PTR)
or type(C_FUNPTR), the component is the address, and the interface is
a pointer even with VALUE attribute. For a usual derived type such as
the drived type with the component of integer 64, the interface is a i64
value when it has VALUE attribute on aarch64 linux.

To lower the type(C_PTR)/type(C_FUNPTR) argument with value attribute,
get the value of the component of the type(C_PTR)/type(C_FUNPTR), which
is the address, and then convert it to the pointer and pass it.

Reviewed By: Jean Perier

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




More information about the All-commits mailing list