History log of /llvm-project/flang/lib/Lower/ConvertCall.cpp (Results 1 – 25 of 131)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6
# cd7e6539 03-Dec-2024 jeanPerier <jperier@nvidia.com>

[flang] optimize array function calls using hlfir.eval_in_mem (#118070)

This patch encapsulate array function call lowering into
hlfir.eval_in_mem and allows directly evaluating the call into the L

[flang] optimize array function calls using hlfir.eval_in_mem (#118070)

This patch encapsulate array function call lowering into
hlfir.eval_in_mem and allows directly evaluating the call into the LHS
when possible.

The conditions are: LHS is contiguous, not accessed inside the function,
it is not a whole allocatable, and the function results needs not to be
finalized. All these conditions are tested in the previous hlfir.eval_in_mem
optimization (#118069) that is leveraging the extension of getModRef to
handle function calls(#117164).

This yields a 25% speed-up on polyhedron channel2 benchmark (from 1min
to 45s measured on an X86-64 Zen 2).

show more ...


Revision tags: llvmorg-19.1.5, llvmorg-19.1.4
# 8bb21ae6 19-Nov-2024 Ivan R. Ivanov <ivanov.i.aa@m.titech.ac.jp>

[flang] Introduce custom loop nest generation for loops in workshare construct (#101445)

This alternative loop nest generation is used to generate an OpenMP loop nest instead of fir loops to facilit

[flang] Introduce custom loop nest generation for loops in workshare construct (#101445)

This alternative loop nest generation is used to generate an OpenMP loop nest instead of fir loops to facilitate parallelizing statements in an OpenMP `workshare` construct.

show more ...


Revision tags: llvmorg-19.1.3, llvmorg-19.1.2
# a78359c2 03-Oct-2024 jeanPerier <jperier@nvidia.com>

[flang] add procedure flags to fir.dispatch (#110970)

Currently, it is not possible to distinguish between BIND(C) from
non-BIND(C) type bound procedure call at the FIR level.
This will be a probl

[flang] add procedure flags to fir.dispatch (#110970)

Currently, it is not possible to distinguish between BIND(C) from
non-BIND(C) type bound procedure call at the FIR level.
This will be a problem when dealing with derived type BIND(C) function
where the ABI differ between BIND(C)/non-BIND(C) but the FIR signature
looks like the same at the FIR level.

Fix this by adding the Fortran procedure attributes to fir.distpatch,
and propagating it until the related fir.call is generated in
fir.dispatch codegen.

show more ...


# b91a25ef 03-Oct-2024 Yusuke MINATO <minato.yusuke@fujitsu.com>

[flang] add nsw to operations in subscripts (#110060)

This patch adds nsw to operations when lowering subscripts.

See also the discussion in the following discourse post.
https://discourse.llvm.

[flang] add nsw to operations in subscripts (#110060)

This patch adds nsw to operations when lowering subscripts.

See also the discussion in the following discourse post.
https://discourse.llvm.org/t/rfc-add-nsw-flags-to-arithmetic-integer-operations-using-the-option-fno-wrapv/77584/9

show more ...


Revision tags: llvmorg-19.1.1
# 3be8e3ad 25-Sep-2024 jeanPerier <jperier@nvidia.com>

[flang] translate pure and elemental attribute in FIR (#109954)

Follow-up from a previous patch that turned bind_c into an enum for
procedure attribute.

This patch carries the elemental and pure

[flang] translate pure and elemental attribute in FIR (#109954)

Follow-up from a previous patch that turned bind_c into an enum for
procedure attribute.

This patch carries the elemental and pure Fortran attribute into FIR so
that the optimizer can leverage that info in the future (I think debug
info may also need to know these aspects since DWARF has DW_AT_elemental
and DW_AT_pure nodes).

SIMPLE from F2023 will be translated once it is handled in the
front-end.

NON_RECURSIVE is only meaningful on func.func since we are not
guaranteed to know that aspect on the caller side (it is not part of
Fortran characteristics). There is a DW_AT_recursive DWARF node. I will
do it while dealing with func.func attributes.

show more ...


# 94c024ad 19-Sep-2024 jeanPerier <jperier@nvidia.com>

[flang][lowering] delay stack save/restor emission in elemental calls (#109142)

stack save/restore emitted for character elemental function result
allocation inside hlfir.elemental in lowering crea

[flang][lowering] delay stack save/restor emission in elemental calls (#109142)

stack save/restore emitted for character elemental function result
allocation inside hlfir.elemental in lowering created memory bugs
because result memory is actually still used after the stack restore
when lowering the elemental into a loop where the result element is
copied into the array result storage.

Instead of adding special handling for stack save/restore in lowering,
just avoid emitting those since the stack reclaim pass is able to emit
them in the generated loop. Not having those stack save/restore will
also help optimizations that want to elide the temporary allocation for
the element result when that is possible.

show more ...


Revision tags: llvmorg-19.1.0
# e6618aae 16-Sep-2024 jeanPerier <jperier@nvidia.com>

[flang] fix ignore_tkr(tk) with character dummy (#108168)

The test code with ignore_tkr(tk) on character dummy passed by
fir.boxchar<> was crashing the compiler in [an
assert](https://github.com/l

[flang] fix ignore_tkr(tk) with character dummy (#108168)

The test code with ignore_tkr(tk) on character dummy passed by
fir.boxchar<> was crashing the compiler in [an
assert](https://github.com/llvm/llvm-project/blob/2afe678f0a246387977a8ca694d4489e2c868991/flang/lib/Optimizer/Dialect/FIRType.cpp#L632)
in `changeElementType`.

It makes little sense to call changeElementType on a fir.boxchar since
this type is lossy (the shape is not part of it). Just skip it in the
code dealing with ignore(tk) when hitting this case

show more ...


# 5aaf384b 16-Sep-2024 Tom Eccles <tom.eccles@arm.com>

[flang][NFC] use llvm.intr.stacksave/restore instead of opaque calls (#108562)

The new LLVM stack save/restore intrinsic operations are more convenient
than function calls because they do not add f

[flang][NFC] use llvm.intr.stacksave/restore instead of opaque calls (#108562)

The new LLVM stack save/restore intrinsic operations are more convenient
than function calls because they do not add function declarations to the
module and therefore do not block the parallelisation of passes.
Furthermore they could be much more easily marked with memory effects
than function calls if that ever proved useful.

This builds on top of #107879.

Resolves #108016

show more ...


Revision tags: llvmorg-19.1.0-rc4
# 2051a7bc 23-Aug-2024 jeanPerier <jperier@nvidia.com>

[flang][NFC] turn fir.call is_bind_c into enum for procedure flags (#105691)

First patch to fix a BIND(C) ABI issue
(https://github.com/llvm/llvm-project/issues/102113). I need to keep
track of BI

[flang][NFC] turn fir.call is_bind_c into enum for procedure flags (#105691)

First patch to fix a BIND(C) ABI issue
(https://github.com/llvm/llvm-project/issues/102113). I need to keep
track of BIND(C) in more locations (fir.dispatch and func.func
operations), and I need to fix a few passes that are dropping the
attribute on the floor. Since I expect more procedure attributes that
cannot be reflected in mlir::FunctionType will be needed for ABI,
optimizations, or debug info, this NFC patch adds a new enum attribute
to keep track of procedure attributes in the IR.

This patch is not updating lowering to lower more attributes, this will
be done in a separate patch to keep the test changes low here.

Adding the attribute on fir.dispatch and func.func will also be done in
separate patches.

show more ...


Revision tags: llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init
# 462d0842 22-Jul-2024 jeanPerier <jperier@nvidia.com>

[flang] fix sequence association of polymorphic actual arguments (#99294)

When passing a polymorphic actual array argument to an non polymorphic
explicit or assumed shape argument, copy-in/copy-out

[flang] fix sequence association of polymorphic actual arguments (#99294)

When passing a polymorphic actual array argument to an non polymorphic
explicit or assumed shape argument, copy-in/copy-out may be required and
should be made according to the dummy dynamic type.

The code that was creating the descriptor to drive this copy-in/out was
not handling properly the case where the dummy and actual rank do not
match (possible according to sequence association rules), it tried to
make the copy-in/out according to the dummy argument shape (which we may
not even know if the dummy is assumed-size). Fix this by using the
actual shape when creating this new descriptor with the dummy argument
dynamic type.

show more ...


# a19e5aed 18-Jul-2024 jeanPerier <jperier@nvidia.com>

[flang] load SECOND result in genSecond (#99342)

Until genSecond, all intrinsic `genXXX` returning scalar intrinsic
(except NULL) were returning them as value.

The code calling genIntrinsicCall

[flang] load SECOND result in genSecond (#99342)

Until genSecond, all intrinsic `genXXX` returning scalar intrinsic
(except NULL) were returning them as value.

The code calling genIntrinsicCall is using that assumption when
generation the asExprOp because hflir.expr<> of scalar are badly
supported in tools (I should likely just forbid them all together), the
type is meant for "non trivial" values: arrays, character, and derived
type. For instance, the added tests crashed with error: `'arith.subf' op
operand #0 must be floating-point-like, but got '!hlfir.expr<f32>'`

Load the result in genSecond and add an assert after genIntrinsicCall to
better enforce this.

show more ...


# 727ecaf7 08-Jul-2024 jeanPerier <jperier@nvidia.com>

[flang] allow intrinsic module procedures to be implemented in Fortran (#97743)

Currently, all procedures from intrinsic modules that are not BIND(C)
are expected to be intercepted by the compiler

[flang] allow intrinsic module procedures to be implemented in Fortran (#97743)

Currently, all procedures from intrinsic modules that are not BIND(C)
are expected to be intercepted by the compiler in lowering and to have a
handler in IntrinsicCall.cpp.

As more "intrinsic" modules are being added (OpenMP, OpenACC, CUF, ...),
this requirement is preventing seamless implementation of intrinsic
modules in Fortran. Procedures from intrinsic modules are different from
generic intrinsics defined in section 16 of the standard. They are
declared in Fortran file seating in the intrinsic module directory and
inside the compiler they look like regular user call except for the
INTRINSIC attribute set on their module. So an easy implementation is
just to have the implementation done in Fortran and linked to the
runtime without any need for the compiler to necessarily understand and
handle these calls in special ways.

This patch splits the lookup and generation part of IntrinsicCall.cpp so
that it can be allowed to only intercept calls to procedure from
intrinsic module if they have a handler. Otherwise, the assumption is
that they should be implemented in Fortran.

Add explicit TODOs handler for the IEEE procedure that are known to not
yet been implemented and won't be implemented via Fortran code so that
this patch is an NFC for what is currently supported.

This patch also prevents doing two lookups in the intrinsic table (There
was one to get argument lowering rules, and another one to generate the
code).

show more ...


# fa08e97d 20-Jun-2024 jeanPerier <jperier@nvidia.com>

[flang] lower assumed-rank TARGET to intent(in) POINTER (#96082)

The only special thing to do is to use fir.rebox_assumed_rank when
reboxing the target to properly set the POINTER attribute inside

[flang] lower assumed-rank TARGET to intent(in) POINTER (#96082)

The only special thing to do is to use fir.rebox_assumed_rank when
reboxing the target to properly set the POINTER attribute inside the
descriptor.

show more ...


# e7d63eba 20-Jun-2024 jeanPerier <jperier@nvidia.com>

[flang] enable copy-in/out of assumed-rank arrays (#96080)

Just remove the TODO and add a test.

There is nothing special to do to deal with assumed-rank copy-in/out
after the previous copy-in/ou

[flang] enable copy-in/out of assumed-rank arrays (#96080)

Just remove the TODO and add a test.

There is nothing special to do to deal with assumed-rank copy-in/out
after the previous copy-in/out API change in
https://github.com/llvm/llvm-project/pull/95822.

show more ...


# 9f44d5d9 18-Jun-2024 jeanPerier <jperier@nvidia.com>

[flang] Simplify copy-in copy-out runtime API (#95822)

The runtime API for copy-in copy-out currently only has an entry only
for the copy-out. This entry has a "skipInit" boolean that is never set

[flang] Simplify copy-in copy-out runtime API (#95822)

The runtime API for copy-in copy-out currently only has an entry only
for the copy-out. This entry has a "skipInit" boolean that is never set
to false by lowering and it does not deal with the deallocation of the
temporary.

The generated code was a mix of inline code and runtime calls This is not a big deal,
but this is unneeded compiler and generated code complexity.
With assumed-rank, it is also more cumbersome to establish a
temporary descriptor.

Instead, this patch:
- Adds a CopyInAssignment API that deals with establishing the temporary
descriptor and does the copy.
- Removes unused arg to CopyOutAssign, and pushes
destruction/deallocation responsibility inside it.

Note that this runtime API are still not responsible for deciding the
need of copying-in and out. This is kept as a separate runtime call to
IsContiguous, which is easier to inline/replace by inline code with the
hope of removing the copy-in/out calls after user function inlining.
@vzakhari has already shown that always inlining all the copy part
increase Fortran compilation time due to loop optimization attempts for
loops that are known to have little optimization profitability (the
variable being copied from and to is not contiguous).

show more ...


# 77d8cfb3 17-Jun-2024 Alexander Shaposhnikov <6532716+alexander-shaposhnikov@users.noreply.github.com>

[Flang] Switch to common::visit more call sites (#90018)

Switch to common::visit more call sites.

Test plan: ninja check-all


Revision tags: llvmorg-18.1.8
# 453a0e4c 13-Jun-2024 jeanPerier <jperier@nvidia.com>

[flang] handle assume-rank descriptor updates in calls (#95229)

Deal with the cases where lower bounds, or attribute, or dynamic type
must be updated when passing an assumed-rank actual argument to

[flang] handle assume-rank descriptor updates in calls (#95229)

Deal with the cases where lower bounds, or attribute, or dynamic type
must be updated when passing an assumed-rank actual argument to an
assumed-rank dummy argument.

copy-in/copy-out and passing target assumed-rank to intent(in) pointers
will be handled in separate patch.

show more ...


Revision tags: llvmorg-18.1.7
# c232137d 31-May-2024 Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>

[flang][HLFIR] compute elemental function result length parameters (#93983)

Prepare the argument and map them to their corresponding dummy symbol in
order to lower the specification expression of t

[flang][HLFIR] compute elemental function result length parameters (#93983)

Prepare the argument and map them to their corresponding dummy symbol in
order to lower the specification expression of the function result.

Extract the preparation of arguments according to the interface to its
own function to be reused.

It seems there is no need to conditionally compute the length on the
input since all the information comes from the CharBoxValue or the
descriptor for cases where the number of element could be 0.

show more ...


# 9482af3d 31-May-2024 Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>

[flang] Carry over BIND(C) information to fir.call (#93981)

The BIND(C) attribute attached to a function can be lost when we do
indirect call. This information might be useful for codegen that have

[flang] Carry over BIND(C) information to fir.call (#93981)

The BIND(C) attribute attached to a function can be lost when we do
indirect call. This information might be useful for codegen that have
specific ABI. This patch carry over the BIND(C) information to the
fir.call operation.

show more ...


# f55622f0 30-May-2024 Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>

[flang] Lower non optional inquired argument in custom intrinsic lowering (#93592)

Handle lowering of non optional inquired argument in custom lowering.
Also fix an issue in the lowering of associa

[flang] Lower non optional inquired argument in custom intrinsic lowering (#93592)

Handle lowering of non optional inquired argument in custom lowering.
Also fix an issue in the lowering of associated optional argument where
a box was emboxed again which led to weird result.

show more ...


Revision tags: llvmorg-18.1.6
# 45daa4fd 17-May-2024 Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>

[flang][cuda] Move CUDA Fortran operations to a CUF dialect (#92317)

The number of operations dedicated to CUF grew and where all still in
FIR. In order to have a better organization, the CUF opera

[flang][cuda] Move CUDA Fortran operations to a CUF dialect (#92317)

The number of operations dedicated to CUF grew and where all still in
FIR. In order to have a better organization, the CUF operations,
attributes and code is moved into their specific dialect and files. CUF
dialect is tightly coupled with HLFIR/FIR and their types.

The CUF attributes are bundled into their own library since some
HLFIR/FIR operations depend on them and the CUF dialect depends on the
FIR types. Without having the attributes into a separate library there
would be a dependency cycle.

show more ...


# c7c5666a 14-May-2024 jeanPerier <jperier@nvidia.com>

[flang] Do not hoist all scalar sub-expressions from WHERE constructs (#91395)

The HLFIR pass lowering WHERE (hlfir.where op) was too aggressive in its
hoisting of scalar sub-expressions from LHS/R

[flang] Do not hoist all scalar sub-expressions from WHERE constructs (#91395)

The HLFIR pass lowering WHERE (hlfir.where op) was too aggressive in its
hoisting of scalar sub-expressions from LHS/RHS/MASKS outside of the
loops generated for the WHERE construct.
This violated F'2023 10.2.3.2 point 10 that stipulated that elemental
operations must be evaluated only for elements corresponding to true
values, because scalar operations are still elemental, and hoisting them
is invalid if they could have side effects (e.g, division by zero) and
if the MASK is always false (i.e., the loop body is never evaluated).

The difficulty is that 10.2.3.2 point 9 mandates that nonelemental
function must be evaluated before the loops. So it is not possible to
simply stop hoisting non hlfir.elemental operations.
Marking calls with an elemental/nonelemental attribute would not allow
the pass to be correct if inlining is run before and drops this
information, beside, extracting the argument tree that may have been
CSE-ed with the rest of the expression evaluation would be a bit
combursome.

Instead, lower nonelemental calls into a new hlfir.exactly_once
operation that will allow retaining the information that the operations
contained inside its region must be hoisted. This allows inlining to
operate before if desired in order to improve alias analysis.

The LowerHLFIROrderedAssignments pass is updated to only hoist the
operations contained inside hlfir.exactly_once bodies.

show more ...


# d6173167 02-May-2024 Daniel Chen <cdchen@ca.ibm.com>

[Flang] Get fir::SequenceType from hlfir::ExprType before getShape. (#90055)

This PR is to fix issue #88889 .
Because the type of an actual argument of an array expression of
character has type o

[Flang] Get fir::SequenceType from hlfir::ExprType before getShape. (#90055)

This PR is to fix issue #88889 .
Because the type of an actual argument of an array expression of
character has type of `hlfir::ExprType`, we need to transform it to
`fir::SequenceType` before calling `getBoxTypeWithNewShape`.
Calling `hlfir::ExprType::getShape` inside of `getBoxTypeWithNewShape`
will introduce a circular dependency on FIRDialect and HLFIRDialect
libraries.

show more ...


Revision tags: llvmorg-18.1.5
# fac349a1 28-Apr-2024 Christian Sigg <chsigg@users.noreply.github.com>

Reapply "[mlir] Mark `isa/dyn_cast/cast/...` member functions depreca… (#90406)

…ted. (#89998)" (#90250)

This partially reverts commit 7aedd7dc754c74a49fe84ed2640e269c25414087.

This change rem

Reapply "[mlir] Mark `isa/dyn_cast/cast/...` member functions depreca… (#90406)

…ted. (#89998)" (#90250)

This partially reverts commit 7aedd7dc754c74a49fe84ed2640e269c25414087.

This change removes calls to the deprecated member functions. It does
not mark the functions deprecated yet and does not disable the
deprecation warning in TypeSwitch. This seems to cause problems with
MSVC.

show more ...


# 7aedd7dc 26-Apr-2024 dyung <douglas.yung@sony.com>

Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)" (#90250)

This reverts commit 950b7ce0b88318f9099e9a7c9817d224ebdc6337.

This change is causing build failures on

Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)" (#90250)

This reverts commit 950b7ce0b88318f9099e9a7c9817d224ebdc6337.

This change is causing build failures on a bot
https://lab.llvm.org/buildbot/#/builders/216/builds/38157

show more ...


123456