[all-commits] [llvm/llvm-project] 241cb2: [flang] add hlfir.null to implement NULL()

jeanPerier via All-commits all-commits at lists.llvm.org
Fri Jan 6 00:57:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 241cb29187569274bbf327478e1665ff76528878
      https://github.com/llvm/llvm-project/commit/241cb29187569274bbf327478e1665ff76528878
  Author: Jean Perier <jperier at nvidia.com>
  Date:   2023-01-06 (Fri, 06 Jan 2023)

  Changed paths:
    M flang/include/flang/Optimizer/HLFIR/HLFIROps.td
    M flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
    M flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
    A flang/test/HLFIR/null-codegen.fir
    A flang/test/HLFIR/null.fir

  Log Message:
  -----------
  [flang] add hlfir.null to implement NULL()

In HLFIR, the address of a Fortran entity in lowering must be defined
by an operation that has the FortranVariableOpInterface (it is a sanity
requirement to ensure that the mlir::Value propagated in certain places
of lowering can be reasoned about).
fir.zero_bits does not have this interface and it makes little sense to
add it since it can "zero initialize" more types than just addresses.

Creating an hlfir.declare for null addresses is a bit too much (what
would be the name), and it would be noisy in the IR.

Instead add a small hlfir.null operation whose codegen is simply a
replacement by fir.zero_bits.

It may also later help dealing with the NULL(MOLD) cases in a nicer
way (the current lowering of this uses special handling it).

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




More information about the All-commits mailing list