summaryrefslogtreecommitdiff
path: root/flang/lib/Lower/ConvertType.cpp
AgeCommit message (Collapse)Author
2025-08-04[Flang] Fix crash when a derived type with private attribute is specified in ↵Carlos Seo
extends (#151051) While lowering to HLFIR, when a parent type is private, its name is mangled, so we need to get it from the parent symbol. Fixes #120922
2025-06-02[flang] Retrieve shape from selector when generating assoc sym type (#137117)Kareem Ergawy
This PR extends `genSymbolType` so that the type of an associating symbol carries the shape of the selector expression, if any. This is a fix for a bug that triggered when an associating symbol is used in a locality specifier. For example, given the following input: ```fortran associate(a => aa(4:)) do concurrent (i = 4:11) local(a) a(i) = 0 end do end associate ``` before the changes in the PR, flang would assert that we are casting between incompatible types. The issue happened since for the associating symbol (`a`), flang generated its type as `f32` rather than `!fir.array<8xf32>` as it should be in this case.
2025-04-04[flang] Remove runtime dependence on C++ support for types (#134164)Peter Klausler
Fortran::runtime::Descriptor::BytesFor() only works for Fortran intrinsic types for which a C++ type counterpart exists, so it crashes on some types that are legitimate Fortran types like REAL(2). Move some logic from Evaluate into a new header in flang/Common, then use it to avoid this needless dependence on C++.
2025-01-16[mlir][IR] Remove factory methods from `FloatType` (#123026)Matthias Springer
This commit removes convenience methods from `FloatType` to make it independent of concrete interface implementations. See discussion here: https://discourse.llvm.org/t/rethink-on-approach-to-low-precision-fp-types/82361 Note for LLVM integration: Replace `FloatType::getF32(` with `Float32Type::get(` etc.
2025-01-14[flang][AIX] filter out __builtin_c_devptr for generating packed type (#122812)Kelvin Li
2025-01-13[flang][AIX] BIND(C) derived type alignment for AIX (#121505)Kelvin Li
This patch is to handle the alignment requirement for the `bind(c)` derived type component that is real type and larger than 4 bytes. The alignment of such component is 4-byte.
2024-12-18[flang] Add UNSIGNED (#113504)Peter Klausler
Implement the UNSIGNED extension type and operations under control of a language feature flag (-funsigned). This is nearly identical to the UNSIGNED feature that has been available in Sun Fortran for years, and now implemented in GNU Fortran for gfortran 15, and proposed for ISO standardization in J3/24-116.txt. See the new documentation for details; but in short, this is C's unsigned type, with guaranteed modular arithmetic for +, -, and *, and the related transformational intrinsic functions SUM & al.
2024-10-03[flang] replace fir.complex usages with mlir complex (#110850)jeanPerier
Core patch of https://discourse.llvm.org/t/rfc-flang-replace-usages-of-fir-complex-by-mlir-complex-type/82292. After that, the last step is to remove fir.complex from FIR types.
2024-06-20[flang] lower assumed-ranks captured in internal procedures (#96106)jeanPerier
Note: the added test fails because it needs the `associateMutableBox` change from https://github.com/llvm/llvm-project/pull/96082. I will rebase this PR once the other is merged.
2024-06-17[Flang] Switch to common::visit more call sites (#90018)Alexander Shaposhnikov
Switch to common::visit more call sites. Test plan: ninja check-all
2024-03-19[flang] Enable polymorphic lowering by default (#83285)jeanPerier
Polymorphic entity lowering status is good. The main remaining TODO is to allow lowering of vector subscripted polymorphic entity, but this does not deserve blocking all application using polymorphism. Remove experimental option and enable lowering of polymorphic entity by default.
2024-02-01[flang][NFC] Cache derived type translation in lowering (#80179)jeanPerier
Derived type translation is proving expensive in modern fortran apps with many big derived types with dozens of components and parents. Extending the cache that prevent recursion is proving to have little cost on apps with small derived types and significant gain (can divide compile time by 2) on modern fortran apps. It is legal since the cache lifetime is less than the MLIRContext lifetime that owns the cached mlir::Type. Doing so also exposed that the current caching was incorrect, the type symbol is the same for kind parametrized derived types regardless of the kind parameters. Instances with different kinds should lower to different MLIR types. See added test. Using the type scopes fixes the problem.
2023-12-19[flang] Lower procedure pointer components (#75453)jeanPerier
Lower procedure pointer components, except in the context of structure constructor (left TODO). Procedure pointer components lowering share most of the lowering logic of procedure poionters with the following particularities: - They are components, so an hlfir.designate must be generated to retrieve the procedure pointer address from its derived type base. - They may have a PASS argument. While there is no dispatching as with type bound procedure, special care must be taken to retrieve the derived type component base in this case since semantics placed it in the argument list and not in the evaluate::ProcedureDesignator. These components also bring a new level of recursive MLIR types since a fir.type may now contain a component with an MLIR function type where one of the argument is the fir.type itself. This required moving the "derived type in construction" stackto the converter so that the object and function type lowering utilities share the same state (currently the function type utilty would end-up creating a new stack when lowering its arguments, leading to infinite loops). The BoxedProcedurePass also needed an update to deal with this recursive aspect.
2023-11-23[Flang] Add partial support for lowering procedure pointer assignment. (#70461)Daniel Chen
**Scope of the PR:** 1. Lowering global and local procedure pointer declaration statement with explicit or implicit interface. The explicit interface can be from an interface block, a module procedure or an internal procedure. 2. Lowering procedure pointer assignment, where the target procedure could be external, module or internal procedures. 3. Lowering reference to procedure pointers so that it works end to end. **PR notes:** 1. The first commit of the PR does not include testing. I would like to collect some comments first, which may alter the output. Once I confirm the implementation, I will add some testing as a follow up commit to this PR. 2. No special handling of the host-associated entities when an internal procedure is the target of a procedure pointer assignment in this PR. **Implementation notes:** 1. The implementation is using the HLFIR path. 2. Flang currently uses `getUntypedBoxProcType` to get the `fir::BoxProcType` for `ProcedureDesignator` when getting the address of a procedure in order to pass it as an actual argument. This PR inherits the same design decision for procedure pointer as the `fir::StoreOp` requires the same memory type. Note: this commit is actually resubmitting the original commit from PR #70461 that was reverted. See PR #73221.
2023-11-23Revert "[Flang] Add partial support for lowering procedure pointer ↵Muhammad Omair Javaid
assignment. (#70461)" This reverts commit e07fec10ac208c2868a24c5c0be88e45778b297e. This change appears to have broken following buildbots: https://lab.llvm.org/buildbot/#/builders/176 https://lab.llvm.org/buildbot/#/builders/179 https://lab.llvm.org/buildbot/#/builders/184 https://lab.llvm.org/buildbot/#/builders/197 https://lab.llvm.org/buildbot/#/builders/198 All bots fails in testsuite where following tests seems broken: (eg: https://lab.llvm.org/buildbot/#/builders/176/builds/7131) test-suite::gfortran-regression-compile-regression__proc_ptr_46_f90.test test-suite::gfortran-regression-compile-regression__proc_ptr_37_f90.test
2023-11-22[Flang] Add partial support for lowering procedure pointer assignment. (#70461)Daniel Chen
**Scope of the PR:** 1. Lowering global and local procedure pointer declaration statement with explicit or implicit interface. The explicit interface can be from an interface block, a module procedure or an internal procedure. 2. Lowering procedure pointer assignment, where the target procedure could be external, module or internal procedures. 3. Lowering reference to procedure pointers so that it works end to end. **PR notes:** 1. The first commit of the PR does not include testing. I would like to collect some comments first, which may alter the output. Once I confirm the implementation, I will add some testing as a follow up commit to this PR. 2. No special handling of the host-associated entities when an internal procedure is the target of a procedure pointer assignment in this PR. **Implementation notes:** 1. The implementation is using the HLFIR path. 2. Flang currently uses `getUntypedBoxProcType` to get the `fir::BoxProcType` for `ProcedureDesignator` when getting the address of a procedure in order to pass it as an actual argument. This PR inherits the same design decision for procedure pointer as the `fir::StoreOp` requires the same memory type.
2023-10-20[flang][hlfir] Make the parent type the first component (#69348)jeanPerier
Type extension is currently handled in FIR by inlining the parents components as the first member of the record type. This is not correct from a memory layout point of view since the storage size of the parent type may be bigger than the sum of the size of its component (due to alignment requirement). To avoid making FIR types target dependent and fix this issue, make the parent component a single component with the parent type at the beginning of the record type. This also simplifies addressing since parent component is now a "normal" component that can be designated with hlfir.designate. StructureComponent lowering however is a bit more complex since the symbols in the structure component may refer to subcomponents of parent types. Notes: 1. The fix is only done in HLFIR for now, a similar fix should be done in ConvertExpr.cpp to fix the path without HLFIR (I will likely still do it in a new patch since it would be an annoying bug to investigate for people testing flang without HLFIR). 2. The private component extra mangling is useless after this patch. I will remove it after 1. 3. The "parent component" TODO in constant CTOR is free to implement for HLFIR after this patch, but I would rather remove it and test it in a different patch.
2023-10-06[flang][nfc] replace fir.dispatch_table with more generic fir.type_info (#68309)jeanPerier
The goal is to progressively propagate all the derived type info that is currently in the runtime type info globals into a FIR operation that can be easily queried and used by FIR/HLFIR passes. When this will be complete, the last step will be to stop generating the runtime info global in lowering, but to do that later in or just before codegen to keep the FIR files readable (on the added type-info.f90 tests, the lowered runtime info globals takes a whooping 2.6 millions characters on 1600 lines of the FIR textual output. The fir.type_info that contains all the info required to generate those globals for such "trivial" types takes 1721 characters on 9 lines). So far this patch simply starts by replacing the fir.dispatch_table operation by the fir.type_info operation and to add the noinit/ nofinal/nodestroy flags to it. These flags will soon be used in HLFIR to better rewrite hlfir.assign with derived types.
2023-09-28[flang][lowering] Move PDT TODO before length param type lowering (#67650)jeanPerier
There is a crash before hitting the TODO when the length parameter kind depends on a KIND parameter. I do not want to fix it since I cannot test it because of the TODO, so I just moved to TODO up and added a comment.
2023-09-18[flang] Lower PRIVATE component names safely (#66076)jeanPerier
It is possible for a derived type extending a type with private components to define components with the same name as the private components. This was not properly handled by lowering where several fir.record type component names could end-up being the same, leading to bad generated code (only the first component was accessed via fir.field_index, leading to bad generated code). This patch handles the situation by adding the derived type mangled name to private component.
2023-08-29[flang] Check procedure pointer initializations; clean up ELEMENTALPeter Klausler
Implements compatibility checking for initializers in procedure pointer declarations. This work exposed some inconsistency in how ELEMENTAL interfaces were handled and checked, from both unrestricted intrinsic functions and others, and some refinements needed for function result compatbility checking; these have also been ironed out. Some new warnings are now emitted, and this affected a dozen or so tests. Differential Revision: https://reviews.llvm.org/D159026
2023-05-24[flang] Support for PowerPC vector typeKelvin Li
The following PowerPC vector type syntax is added: VECTOR ( element-type-spec ) where element-type-sec is integer-type-spec, real-type-sec or unsigned-type-spec. Two opaque types (__VECTOR_PAIR and __VECTOR_QUAD) are also added. A finite set of functionalities are implemented in order to support the new types: 1. declare objects 2. declare function result 3. declare type dummy arguments 4. intrinsic assignment between the new type objects (e.g. v1=v2) 5. reference functions that return the new types Submit on behalf of @tislam @danielcchen Authors: @tislam @danielcchen Differential Revision: https://reviews.llvm.org/D150876
2023-02-28[flang] Block constructV Donaldson
A block construct is an execution control construct that supports declaration scopes contained within a parent subprogram scope or another block scope. (blocks may be nested.) This is implemented by applying basic scope processing to the block level. Name uniquing/mangling is extended to support this. The term "block" is heavily overloaded in Fortran standards. Prior name uniquing used tag `B` for common block objects. Existing tag choices were modified to free up `B` for block construct entities, and `C` for common blocks, and resolve additional issues with other tags. The "old tag -> new tag" changes can be summarized as: -> B -- block construct -> new B -> C -- common block C -> YI -- intrinsic type descriptor; not currently generated CT -> Y -- nonintrinsic type descriptor; not currently generated G -> N -- namelist group L -> -- block data; not needed -> deleted Existing name uniquing components consist of a tag followed by a name from user source code, such as a module, subprogram, or variable name. Block constructs are different in that they may be anonymous. (Like other constructs, a block may have a `block-construct-name` that can be used in exit statements, but this name is optional.) So blocks are given a numeric compiler-generated preorder index starting with `B1`, `B2`, and so on, on a per-procedure basis. Name uniquing is also modified to include component names for all containing procedures rather than for just the immediate host. This fixes an existing name clash bug with same-named entities in same-named host subprograms contained in different-named containing subprograms, and variations of the bug involving modules and submodules. F18 clause 9.7.3.1 (Deallocation of allocatable variables) paragraph 1 has a requirement that an allocated, unsaved allocatable local variable must be deallocated on procedure exit. The following paragraph 2 states: When a BLOCK construct terminates, any unsaved allocated allocatable local variable of the construct is deallocated. Similarly, F18 clause 7.5.6.3 (When finalization occurs) paragraph 3 has a requirement that a nonpointer, nonallocatable object must be finalized on procedure exit. The following paragraph 4 states: A nonpointer nonallocatable local variable of a BLOCK construct is finalized immediately before it would become undefined due to termination of the BLOCK construct. These deallocation and finalization requirements, along with stack restoration requirements, require knowledge of block exits. In addition to normal block termination at an end-block-stmt, a block may be terminated by executing a branching statement that targets a statement outside of the block. This includes Single-target branch statements: - goto - exit - cycle - return Bounded multiple-target branch statements: - arithmetic goto - IO statement with END, EOR, or ERR specifiers Unbounded multiple-target branch statements: - call with alternate return specs - computed goto - assigned goto Lowering code is extended to determine if one of these branches exits one or more relevant blocks or other constructs, and adds a mechanism to insert any necessary deallocation, finalization, or stack restoration code at the source of the branch. For a single-target branch it suffices to generate the exit code just prior to taking the indicated branch. Each target of a multiple-target branch must be analyzed individually. Where necessary, the code must first branch to an intermediate basic block that contains exit code, followed by a branch to the original target statement. This patch implements an `activeConstructStack` construct exit mechanism that queries a new `activeConstruct` PFT bit to insert stack restoration code at block exits. It ties in to existing code in ConvertVariable.cpp routine `instantiateLocal` which has code for finalization, making block exit finalization on par with subprogram exit finalization. Deallocation is as yet unimplemented for subprograms or blocks. This may result in memory leaks for affected objects at either the subprogram or block level. Deallocation cases can be addressed uniformly for both scopes in a future patch, presumably with code insertion in routine `instantiateLocal`. The exit code mechanism is not limited to block construct exits. It is also available for use with other constructs. In particular, it is used to replace custom deallocation code for a select case construct character selector expression where applicable. This functionality is also added to select type and associate constructs. It is available for use with other constructs, such as select rank and image control constructs, if that turns out to be necessary. Overlapping nonfunctional changes include eliminating "FIR" from some routine names and eliminating obsolete spaces in comments.
2023-02-28[flang][hlfir] Support type descriptor for initialized character componentJean Perier
These compiler generated component descriptor include designators packaged as CLASS(*) for simplicity. HLFIR hit an assert in an std::get trying to recover an Expr<SomeChar> while translating the expression type. Use the dynamic type of the CLASS(*) expr in that case to recover the compiler length. Differential Revision: https://reviews.llvm.org/D144960
2023-02-08[flang][NFC] Centralize fir.class addition in ConvertTypeValentin Clement
fir.class type is always needed for polymorphic and unlimited polymorphic entities. Wrapping the element type with a fir.class type was done in ConvertType for some case and else where in the code for other. Centralize this in ConvertType when converting from expr or symbol. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D143490
2023-01-31[flang] derived-type finalizationValentin Clement
This patch implements the derived-type finalization for monomorphic and polymorphic derived-type. The finalization is done through a call to the `Destroy` runtime function so the allocatable component object are also finalized correctly when needed. It would be possible to finalize monomorphic derived-type with non finalizable component with a direct call to their finalize subroutine. 7.5.6.3 point 1: LHS nonallocatable object and LHS allocatable object finalization. Done with call to `Destroy` for monomorphic derived-type and through `Assign` for polymorphic entities. 7.5.6.3 point 2: Done within the deallocation calls. 7.5.6.3 point 3: A function context is added to the bridge to attach finalization that need to happen on function/subroutine exit. 7.5.6.3 point 4: BLOCK construct not yet implemented. 7.5.6.3 point 5/6: Finalization attach to the stmtCtx in a similar way than 9.7.3.2 point 4. 7.5.6.3 point 7: INTENT(OUT) finalization done with a call to `Destroy` runtime function call. This patch passes 9/10 tests in the proposed test-suite https://github.com/llvm/llvm-test-suite/pull/13 - The case with BLOCK construct will be implemented later when BLOCK are implemented upstream. - Automatic deallocation is not yet implemented. Finalization triggered by automatic deallocation is then not triggered. Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D142707
2023-01-17[flang][hlfir] Lower some character elemental referencesJean Perier
Lower character elemental user procedures with constant length, and bot dynamic and constant length ADJUSTL, ADJUSTR, and MERGE references (which leaves out MIN/MAX). Character elemental user procedures with dynamic length are a bit more involving and since it is an edge-case that is not currently supported, I will take this on later. Differential Revision: https://reviews.llvm.org/D141847
2023-01-12[flang] Lower component-ref to hlfir.designateJean Perier
Implement the visit of component refs in DesignatorBuilder. The ArrayRef code has to be updated a bit to cope with the case where the base is an array and the component is also an array. Improve the result type of array sections designators (only return a fir.box if the array section is not contiguous/has dynamic extent). This required exposing IsContiguous entry point for different front-end designator nodes (the implementation already existed, but was internal to check-expression.cpp). Differential Revision: https://reviews.llvm.org/D141470
2023-01-05[flang][NFC] share Constant<SomeDerived> loweringJean Perier
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. Differential Revision: https://reviews.llvm.org/D140986
2022-11-30[flang][NFC] add genType(FunctionRef<T>) entry points in loweringJean Perier
This will help lowering to HLFIR to not use the AsGenericExpr/AsExpr patterns that copies sub-expresssions into evaluate::SomeExpr so that they can be passed to helpers. Sub-expressions like FunctionRef can be heavy (hundreds of arguments, constant array expression arguments...). Differential Revision: https://reviews.llvm.org/D138997
2022-11-24[flang] Adapt descriptor codegen to support unlimited polymorphic entitiesValentin Clement
Code generation to create and populate the descriptor (element size and type code) is based on the boxed result type. This does not work well with unlimited polymorphic entities since the fir type does not represent what is actually emboxed or reboxed. In the case of emboxing, the input type will be used to populate the descriptor element size and type code. When reboxing an unlimited polymorphic to a unlimited polymorphic entities, the element size and type code is retrieve from the input box. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D138587
2022-11-17[flang] Create fir.dispatch_table and fir.dt_entry operationsValentin Clement
Create the fir.dispatch_table operation based on semantics information. The fir.dispatch_table will be used for static devirtualization as well as for fir.select_type conversion. Depends on D138129 Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D138131
2022-11-02[NFC][flang] Lowering options clean-up.Slava Zakharin
This change-set defines the LoweringOptions the same way other options are defined in Flang. Differential Revision: https://reviews.llvm.org/D137207
2022-10-05[flang] Keep current polymorphic implementation under a flagValentin Clement
It is useful for couple of test suite like NAG to keep failing with a TODO until the polymorphic entities is implemented all the way done to codegen. This pass adds a flag to LoweringOptions for experimental development. This flag is off by default and can be enable in `bbc` with `-polymorphic-type`. Options can be added in the driver and tco when needed. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135283
2022-10-04[flang] Lower polymorphic entities types in dummy argument and function resultValentin Clement
This patch updates lowering to produce the correct fir.class types for various polymorphic and unlimited polymoprhic entities cases. This is only the lowering. Some TODOs have been added to the CodeGen part to avoid errors since this part still need to be updated as well. The fir.class<*> representation for unlimited polymorphic entities mentioned in the document has been updated to fir.class<none> to avoid useless work in pretty parse/printer. This patch is part of the implementation of the poltymorphic entities. https://github.com/llvm/llvm-project/blob/main/flang/docs/PolymorphicEntities.md Depends on D134957 Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D134959
2022-07-17Remove redundant return statements (NFC)Kazu Hirata
Identified with readability-redundant-control-flow.
2022-07-04[flang] Add TODO for derived types with final procedureValentin Clement
Finalization is F2003 and although the runtime supports it already, lowering is not ensuring all the derived type are finalized properly when they should. This will require surveying the places where lowering needs to call it. Add a hard TODO for now. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D129069 Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-07-01[flang] Fix APFloat conversion casesValentin Clement
This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128935 Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
2022-06-20[flang][NFC] Unify todo messagesValentin Clement
This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D128186 Co-authored-by: Peter Steinfeld <psteinfeld@nvidia.com>
2022-06-10[flang][NFC] Move Todo.h from Lower to OptimizerValentin Clement
Remove a backwards dependence from Optimizer -> Lower by moving Todo.h to the optimizer and out of lowering. This patch is part of the upstreaming effort from fir-dev branch. Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D127292
2022-05-24[flang] Alternate entry points with unused argumentsV Donaldson
A dummy argument in an entry point of a subprogram with multiple entry points need not be defined in other entry points. It is only legal to reference such an argument when calling an entry point that does have a definition. An entry point without such a definition needs a local "substitute" definition sufficient to generate code. It is nonconformant to reference such a definition at runtime. Most such definitions and associated code will be deleted as dead code at compile time. However, that is not always possible, as in the following code. This code is conformant if all calls to entry point ss set m=3, and all calls to entry point ee set n=3. subroutine ss(a, b, m, d, k) ! no x, y, n integer :: a(m), b(a(m)), m, d(k) integer :: x(n), y(x(n)), n integer :: k 1 print*, m, k print*, a print*, b print*, d if (m == 3) return entry ee(x, y, n, d, k) ! no a, b, m print*, n, k print*, x print*, y print*, d if (n /= 3) goto 1 end integer :: xx(3), yy(5), zz(3) xx = 5 yy = 7 zz = 9 call ss(xx, yy, 3, zz, 3) call ss(xx, yy, 3, zz, 3) end Lowering currently generates fir::UndefOp's for all unused arguments. This is usually ok, but cases such as the one here incorrectly access unused UndefOp arguments for m and n from an entry point that doesn't have a proper definition. The problem is addressed by creating a more complete definition of an unused argument in most cases. This is implemented in large part by moving the definition of an unused argument from mapDummiesAndResults to mapSymbolAttributes. The code in mapSymbolAttributes then chooses one of three code generation options, depending on information available there. This patch deals with dummy procedures in alternate entries, and adds a TODO for procedure pointers (the PFTBuilder is modified to analyze procedure pointer symbol so that they are not silently ignored, and instead hits proper TODOs). BoxAnalyzer is also changed because assumed-sized arrays were wrongfully categorized as constant shape arrays. This had no impact, except when there were unused entry points. Co-authored-by: jeanPerier <jperier@nvidia.com> Differential Revision: https://reviews.llvm.org/D125867
2022-05-09[flang] Accept POINTER followed by INTERFACEPeter Klausler
As is already supported for dummy procedures, we need to also accept declarations of procedure pointers that consist of a POINTER attribute statement followed by an INTERFACE block. (The case of an INTERFACE block followed by a POINTER statement already works.) While cleaning this case up, adjust the utility predicate IsProcedurePointer() to recognize it (namely a SubprogramDetails symbol with Attr::POINTER) and delete IsProcName(). Extend tests, and add better comments to symbol.h to document the two ways in which procedure pointers are represented. Differential Revision: https://reviews.llvm.org/D125139
2022-03-16[flang] Lower IO input with vector subscriptsValentin Clement
This patch adds lowering for IO input with vector subscripts. It defines a VectorSubscriptBox class that allow representing and working with a lowered Designator containing vector subscripts while ensuring all the subscripts expression are only lowered once. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D121806 Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-10[flang] Lower basic derived typesValentin Clement
This patch lowers basic derived type to FIR. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D121383 Co-authored-by: V Donaldson <vdonaldson@nvidia.com> Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
2022-03-01[flang] Lower basic IO statementValentin Clement
This patch enables the lowering of the print, read and write IO statements. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld, schweitz Differential Revision: https://reviews.llvm.org/D120743 Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: V Donaldson <vdonaldson@nvidia.com> Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com>
2022-02-23[flang][NFC] Clean up ConvertTypeValentin Clement
This patch removes unused or obsolete code in the ConvertType.h and ConvertType.cpp files. These files were landed together with the initial flang upstreaming. This cleanup will help future upstreaming effort from fir-dev and keep only used code. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D120405
2022-02-23[flang] Lower real constantValentin Clement
This patch handles lowering of real constant. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D120354 Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-02-17[flang] Lower simple scalar assignmentValentin Clement
This patch hanlde lowering of simple scalar assignment. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D120058 Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-02-15[flang] Handle lowering of ranked arrayValentin Clement
This patch adds lowering of ranked array as function return. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D119835 Co-authored-by: Jean Perier <jperier@nvidia.com>
2022-02-15[flang] Enable complex type in function loweringValentin Clement
This patch enables complex type in lowering. It is tested on function return types. This patch is part of the upstreaming effort from fir-dev branch. Depends on D119698 Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D119700 Co-authored-by: Jean Perier <jperier@nvidia.com>