[flang-commits] [PATCH] D140986: [flang][NFC] share Constant<SomeDerived> lowering

Jean Perier via Phabricator via flang-commits flang-commits at lists.llvm.org
Wed Jan 4 06:39:31 PST 2023


jeanPerier created this revision.
jeanPerier added reviewers: PeteSteinfeld, vdonaldson.
jeanPerier added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
Herald added a project: All.
jeanPerier requested review of this revision.

A previous patch (https://reviews.llvm.org/D136955) already refactored
intrinsic constant lowering to place in its own file and allow using it from
both the current lowering and the new lowering to HLFIR.

This patch does the same for derived types. The core function
"genStructComponentInInitializer" is moved from ConvertExpr.cpp and
renamed "genInlinedStructureCtorLitImpl" into ConvertConstant.cpp
without significant logic change.

Then, genScalarLit, genArrayLit (and genInlinedArrayLit/genOutlinedArrayLit)
are updated to support derived types.

The core aspect of derived type constant lowering that differs between
the current lowering and the HLFIR update is the way
addresses/initial target descriptors are built when part of a derived
type constant. This part happens in ConvertVariable.cpp (since the
address of a variable is taken in an initializer and is left TODO).

The mangling of derived type global literal constant is fixed: it did not embed
the derived type name and could cause "conflicts" between unrelated
derived types containing the same data. However, the hash remains
unstable between two compilation of the same file. This is not a
correctness issue and would require a lot of work to hash the derived
type constant data without hashing some irrelevant (but not out of bound)
data in the compile time data structure that holds derived type
constants (Constant<SomeDerived>). This may have to be revisited later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140986

Files:
  flang/include/flang/Lower/ConvertConstant.h
  flang/include/flang/Lower/ConvertType.h
  flang/include/flang/Lower/Mangler.h
  flang/lib/Lower/ConvertConstant.cpp
  flang/lib/Lower/ConvertExpr.cpp
  flang/lib/Lower/ConvertExprToHLFIR.cpp
  flang/lib/Lower/ConvertType.cpp
  flang/lib/Lower/ConvertVariable.cpp
  flang/lib/Lower/Mangler.cpp
  flang/test/Lower/HLFIR/constant-derived.f90
  flang/test/Lower/constant-literal-mangling.f90

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140986.486269.patch
Type: text/x-patch
Size: 46827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20230104/f2d455ab/attachment-0001.bin>


More information about the flang-commits mailing list