[flang-commits] [PATCH] D141040: [flang] add hlfir.null to implement NULL()

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Thu Jan 5 01:54:52 PST 2023


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

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).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141040

Files:
  flang/include/flang/Optimizer/HLFIR/HLFIROps.td
  flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
  flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
  flang/test/HLFIR/null-codegen.fir
  flang/test/HLFIR/null.fir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141040.486502.patch
Type: text/x-patch
Size: 4061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230105/67165363/attachment-0001.bin>


More information about the flang-commits mailing list