| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[flang][NFC] Strip trailing whitespace from tests (2 of N) Only the fortran source files in flang/test have been modified. The other files in the directory will be cleaned up in subsequent commits | 9 个月前 | |
[flang][fir] Add conversion of fir.iterate_while to scf.while. (#152439) This commmit is a supplement for https://github.com/llvm/llvm-project/pull/140374. RFC:https://discourse.llvm.org/t/rfc-add-fir-affine-optimization-fir-pass-pipeline/86190/6 | 1 年前 | |
[flang] Adding lowering of TEAMs features to PRIF in MIF Dialect (#165573) Support for multi-image features has begun to be integrated into LLVM with the MIF dialect. In this PR, you will find lowering and operations related to the TEAM features ( SYNC TEAM, GET_TEAM, FORM TEAM, CHANGE TEAM, TEAM_NUMBER). Note regarding the operation for CHANGE TEAM : This operation is partial because it does not support the associated list of coarrays because the allocation of a coarray and the lowering of PRIF's prif_alias_{create|destroy} procedures are not yet supported in Flang. This will be integrated later. Any feedback is welcome. | 9 个月前 | |
[acc][flang] Define hasUnknownDimensions in MappableType (#165794) The MappableType interface currently defines a generateAccBounds method which examines a variable and generates acc.bounds operations that encode its dimensions. The implementation can extract bounds information in various ways: either from the MLIR type itself or by analyzing the IR to find dimension information from defining operations. However, we need to distinguish between cases where dimensional information is not directly available from the type itself. This new hasUnknownDimensions API returns true when the MLIR type does not encode dimensional information and there is no associated descriptor or metadata that would make this information extractable from the visible ssa value the represents the variable. The expected use case is calling generateAccBounds only when this returns true, as it indicates that bounds must be extracted from the IR (by walking back from current variable to its defining spots or its descriptor). This supports cases such as raw references to arrays with non-constant bounds (e.g., explicit-shape arrays in Fortran where bounds are passed as arguments). This functionality could also be leveraged for CIR VLA support in the future. For FIR types: - Box types return false (descriptor encodes dimensions) - Reference types check if the pointee has dynamic size using fir::hasDynamicSize() | 9 个月前 | |
[Flang][OpenMP] Fix mapping of character type with LEN > 1 specified (#154172) Currently, there's a number of issues with mapping characters with LEN's specified (strings effectively). They're represented as a char type in FIR with a len parameter, and then later on they're expanded into an array of characters when we're translating to the LLVM dialect. However, we don't generate a bounds for these at lowering. The fix in this PR for this is to generate a bounds from the LEN parameter and attatch it to the map on lowering from FIR to the LLVM dialect when we encounter this type. | 11 个月前 | |
[flang] update fir.coordinate_of to carry the fields (#127231) This patch updates fir.coordinate_op to carry the field index as attributes instead of relying on getting it from the fir.field_index operations defining its operands. The rational is that FIR currently has a few operations that require DAGs to be preserved in order to be able to do code generation. This is the case of fir.coordinate_op, which requires its fir.field operand producer to be visible. This makes IR transformation harder/brittle, so I want to update FIR to get rid if this. Codegen/printer/parser of fir.coordinate_of and many tests need to be updated after this change. | 1 年前 | |
[flang] Do not produce result for void runtime call (#123155) Runtime function call to a void function are producing a ssa value because the FunctionType result is set to NoneType with is later translated to a empty struct. This is not an issue when going to LLVM IR but it breaks when lowering a gpu module to PTX. This patch update the RTModel to correctly set the FunctionType result type to nothing. This is one runtime call before this patch at the LLVM IR dialect step. %45 = llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> !llvm.struct<()> After the patch the call would be correctly formed llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> () Without the patch it would lead to error like: ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 10; error : Output parameter cannot be an incomplete array. ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 125; error : Call has wrong number of parameters The change is pretty much mechanical. | 1 年前 | |
[flang] update fir.coordinate_of to carry the fields (#127231) This patch updates fir.coordinate_op to carry the field index as attributes instead of relying on getting it from the fir.field_index operations defining its operands. The rational is that FIR currently has a few operations that require DAGs to be preserved in order to be able to do code generation. This is the case of fir.coordinate_op, which requires its fir.field operand producer to be visible. This makes IR transformation harder/brittle, so I want to update FIR to get rid if this. Codegen/printer/parser of fir.coordinate_of and many tests need to be updated after this change. | 1 年前 | |
[flang] update fir.coordinate_of to carry the fields (#127231) This patch updates fir.coordinate_op to carry the field index as attributes instead of relying on getting it from the fir.field_index operations defining its operands. The rational is that FIR currently has a few operations that require DAGs to be preserved in order to be able to do code generation. This is the case of fir.coordinate_op, which requires its fir.field operand producer to be visible. This makes IR transformation harder/brittle, so I want to update FIR to get rid if this. Codegen/printer/parser of fir.coordinate_of and many tests need to be updated after this change. | 1 年前 | |
[flang][driver] Make flang-new -fc1 accept MLIR files This relatively small change will allow Flang's frontend driver, flang-new -fc1, to consume and parse MLIR files. Semantically (i.e. from user's perspective) this is identical to reading LLVM IR files. Two file extensions are associated with MLIR files: .fir and .mlir. Note that reading MLIR files makes only sense when running one of the code-generation actions, i.e. when using one of the following action flags: -S, -emit-obj, -emit-llvm, -emit-llvm-bc. The majority of tests that required tco to run are updated to also run with flang-new -fc1. A few tests are updated to use fir-opt instead of tco (that's the preferred choice when testing a particular MLIR pass). basic-program.fir is not updated as that test is intended to verify the behaviour of tco specifically. Differential Revision: https://reviews.llvm.org/D126890 | 4 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
[flang][fir] Support promoting fir.do_loop with results to affine.for. (#137790) Co-authored-by: yanming <ming.yan@terapines.com> | 1 年前 | |
[flang] handle allocation of zero-sized objects (#149165) This PR handles the allocation of zero-sized objects for different implementations. One byte is allocated for the zero-sized objects. | 1 年前 | |
[flang][NFC] Characterize allocation based on MemAlloc effect instead of pattern matching (#166806) Flang alias analysis used to find allocation site by pattern matching allocation ops in mainly FIR dialect. This MR extends the characterization to instead characterize based on whether the result of an op has MemAlloc effect. | 9 个月前 | |
[flang] Allow user to define free via BIND(C) (#78428) A user defining and using free/malloc via BIND(C) would previously cause flang to crash when generating LLVM IR with error "redefinition of symbol named 'free'". This was caused by flang codegen not expecting to find a mlir::func::FuncOp definition of these function and emitting a new mlir::LLVM::FuncOp that later conflicted when translating the mlir::func::FuncOp. | 2 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
[flang] Canonicalize fir.array_coor by pulling in embox/rebox. (#92858) In a simple case like this: program test integer :: u(120, 2) u(1:120,1:2) = u(1:120,1:2) + 2 end program Flang is creating a copy loop with fir.array_coor using a result of fir.embox inserted before the loop. This results in split address computations before and inside the loop, which can be seen as many more arithmetic operations than required after converting FIR to LLVM dialect. Even though LLVM SROA/mem2reg are able to optimize the temporary descriptor, and then LICM is able to hoist the invariant computations, we seem to get better mix of LLVM dialect operations after FIR-to-LLVM codegen. This may also slightly reduce the compilation time taken by LLVM to optimize the generate LLVM IR. This may also slightly reduce the time spent by FIR AliasAnalysis to reach the memory reference source. | 2 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] replace fir.complex usages with mlir complex (#110850) 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. | 1 年前 | |
[flang] Avoid unnecessary temporaries in ArrayValueCopy. Assume no conflict between pointer arrays and arrays without the target attribute, if the fact of an array not having the target attribute can be reliably computed. This change speeds up SPEC CPU2017/527.cam from 2.5k seconds to 880 seconds on Icelake, and makes further performance investigation easier. Differential Revision: https://reviews.llvm.org/D142273 | 3 年前 | |
[flang] de-duplicate CFGConversion pass (#89783) See RFC at https://discourse.llvm.org/t/rfc-add-an-interface-for-top-level-container-operations I previously did the same for the AbstractResult pass https://github.com/llvm/llvm-project/pull/88867 | 2 年前 | |
[flang] Do not produce result for void runtime call (#123155) Runtime function call to a void function are producing a ssa value because the FunctionType result is set to NoneType with is later translated to a empty struct. This is not an issue when going to LLVM IR but it breaks when lowering a gpu module to PTX. This patch update the RTModel to correctly set the FunctionType result type to nothing. This is one runtime call before this patch at the LLVM IR dialect step. %45 = llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> !llvm.struct<()> After the patch the call would be correctly formed llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> () Without the patch it would lead to error like: ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 10; error : Output parameter cannot be an incomplete array. ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 125; error : Call has wrong number of parameters The change is pretty much mechanical. | 1 年前 | |
[flang] Do not produce result for void runtime call (#123155) Runtime function call to a void function are producing a ssa value because the FunctionType result is set to NoneType with is later translated to a empty struct. This is not an issue when going to LLVM IR but it breaks when lowering a gpu module to PTX. This patch update the RTModel to correctly set the FunctionType result type to nothing. This is one runtime call before this patch at the LLVM IR dialect step. %45 = llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> !llvm.struct<()> After the patch the call would be correctly formed llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> () Without the patch it would lead to error like: ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 10; error : Output parameter cannot be an incomplete array. ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 125; error : Call has wrong number of parameters The change is pretty much mechanical. | 1 年前 | |
[flang][nfc] replace fir.dispatch_table with more generic fir.type_info (#68309) 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. | 2 年前 | |
[flang] update fir.coordinate_of to carry the fields (#127231) This patch updates fir.coordinate_op to carry the field index as attributes instead of relying on getting it from the fir.field_index operations defining its operands. The rational is that FIR currently has a few operations that require DAGs to be preserved in order to be able to do code generation. This is the case of fir.coordinate_op, which requires its fir.field operand producer to be visible. This makes IR transformation harder/brittle, so I want to update FIR to get rid if this. Codegen/printer/parser of fir.coordinate_of and many tests need to be updated after this change. | 1 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] handle allocation of zero-sized objects (#149165) This PR handles the allocation of zero-sized objects for different implementations. One byte is allocated for the zero-sized objects. | 1 年前 | |
[flang][FIR] add fir.assumed_size_extent to abstract assumed-size extent encoding (#164452) The purpose of this patch is to allow converting FIR array representation to memref when possible without hitting memref verifier issue. The issue was that FIR arrays may be assumed size, in which case the last dimension will not be known at runtime. Flang uses -1 to encode this to fulfill Fortran 2023 standard requirements in 18.5.3 point 5 about CFI_desc_t. When arrays are converted to memeref, if this -1 reaches memeref operations, it triggers verifier errors (even if the conversion happened in code that guards the code to be entered at runtime if the array is assumed-size because folders/verifiers do not take into account reachability). This follows-up on discussions in #163505 merge requests | 10 个月前 | |
[flang][FIR] add fir.assumed_size_extent to abstract assumed-size extent encoding (#164452) The purpose of this patch is to allow converting FIR array representation to memref when possible without hitting memref verifier issue. The issue was that FIR arrays may be assumed size, in which case the last dimension will not be known at runtime. Flang uses -1 to encode this to fulfill Fortran 2023 standard requirements in 18.5.3 point 5 about CFI_desc_t. When arrays are converted to memeref, if this -1 reaches memeref operations, it triggers verifier errors (even if the conversion happened in code that guards the code to be entered at runtime if the array is assumed-size because folders/verifiers do not take into account reachability). This follows-up on discussions in #163505 merge requests | 10 个月前 | |
[flang][FIR] add fir.assumed_size_extent to abstract assumed-size extent encoding (#164452) The purpose of this patch is to allow converting FIR array representation to memref when possible without hitting memref verifier issue. The issue was that FIR arrays may be assumed size, in which case the last dimension will not be known at runtime. Flang uses -1 to encode this to fulfill Fortran 2023 standard requirements in 18.5.3 point 5 about CFI_desc_t. When arrays are converted to memeref, if this -1 reaches memeref operations, it triggers verifier errors (even if the conversion happened in code that guards the code to be entered at runtime if the array is assumed-size because folders/verifiers do not take into account reachability). This follows-up on discussions in #163505 merge requests | 10 个月前 | |
[Flang][mlir] - Translation of delayed privatization for deferred target-tasks (#155348) This PR adds support for translation of the private clause on deferred target tasks - that is omp.target operations with the nowait clause. An offloading call for a deferred target-task is not blocking - the offloading (target-generating) host task continues its execution after issuing the offloading call. Therefore, the key problem we need to solve is to ensure that the data needed for private variables to be initialized in the target task persists even after the host task has completed. We do this in a new pass called PrepareForOMPOffloadPrivatizationPass. For a privatized variable that needs its host counterpart for initialization (such as the shape of the data from the descriptor when an allocatable is privatized or the value of the data when an allocatable is firstprivatized), - the pass allocates memory on the heap. - it then initializes this memory by using the init and copy (for firstprivate) regions of the corresponding omp::PrivateClauseOp. - Finally the memory allocated on the heap is freed using the dealloc region of the same omp::PrivateClauseOp instance. This step is not straightforward though, because we cannot simply free the memory that's going to be used by another thread without any synchronization. So, for deallocation, we create a omp.task after the omp.target and synchronize the two with a dummy dependency (using the depend clause). In this newly created omp.task we do the deallocation. | 10 个月前 | |
[Flang] - Handle BoxCharType in fir.box_offset op (#141713) To map fir.boxchar types reliably onto an offload target, such as a GPU, the omp.map.info operation is used to map the underlying data pointer (fir.ref<fir.char<k, ?>>) wrapped by the fir.boxchar MLIR value. The omp.map.info operation needs a pointer to the underlying data pointer. Given a reference to a descriptor (fir.box), the fir.box_offset is used to obtain the address of the underlying data pointer. This PR extends fir.box_offset to provide the same functionality for fir.boxchar as well. | 1 年前 | |
[Flang] - Handle BoxCharType in fir.box_offset op (#141713) To map fir.boxchar types reliably onto an offload target, such as a GPU, the omp.map.info operation is used to map the underlying data pointer (fir.ref<fir.char<k, ?>>) wrapped by the fir.boxchar MLIR value. The omp.map.info operation needs a pointer to the underlying data pointer. Given a reference to a descriptor (fir.box), the fir.box_offset is used to obtain the address of the underlying data pointer. This PR extends fir.box_offset to provide the same functionality for fir.boxchar as well. | 1 年前 | |
[flang] Added fir.is_contiguous_box and fir.box_total_elements ops. (#131047) These are helper operations to aid with expanding of fir.pack_array. | 1 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang][FIR] enable fir.box_addr codegen inside fir.global (#157120) FIR lowering of the fir.box type inside fir.global is special (it is an actual descriptor struct value instead of being a descriptor in memory) and causes builtin.unrealized_conversion_cast to be inserted under the hood by MLIR dialect conversion framework after each operation producing a fir.box is translated. These builtin.unrealized_conversion_cast must be removed before the code generation of operation of using the fir.box in order to get the right "by value" code generation required in global initial value definitions. | 11 个月前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
[flang] fir.emboxchar codegen with static length fir.char types The verifier of fir.emboxchar accepts fir.char<kind, constant> types, but its codegen failed because of a missing cast. It is convenient and safe to not require making the cast in FIR, so add it in codegen. Differential Revision: https://reviews.llvm.org/D139514 | 3 年前 | |
| 1 年前 | ||
[mlir][OpenMP][flang] make private variable allocation implicit in omp.private (#124019) The intention of this work is to give MLIR->LLVMIR conversion freedom to control how the private variable is allocated so that it can be allocated on the stack in ordinary cases or as part of a structure used to give closure context for tasks which might outlive the current stack frame. See RFC: https://discourse.llvm.org/t/rfc-openmp-supporting-delayed-task-execution-with-firstprivate-variables/83084 For example, a privatizer for an integer used to look like mlir omp.private {type = private} @x.privatizer : !fir.ref<i32> alloc { ^bb0(%arg0: !fir.ref<i32>): %0 = ... allocate proper memory for the private clone ... omp.yield(%0 : !fir.ref<i32>) } After this change, allocation become implicit in the operation: mlir omp.private {type = private} @x.privatizer : i32 For more complex types that require initialization after allocation, an init region can be used: mlir omp.private {type = private} @x.privatizer : !some.type init { ^bb0(%arg0: !some.pointer<!some.type>, %arg1: !some.pointer<!some.type>): // initialize %arg1, using %arg0 as a mold for allocations omp.yield(%arg1 : !some.pointer<!some.type>) } dealloc { ^bb0(%arg0: !some.pointer<!some.type>): ... deallocate memory allocated by the init region ... omp.yield } This patch lays the groundwork for delayed task execution but is not enough on its own. After this patch all gfortran tests which previously passed still pass. There are the following changes to the Fujitsu test suite: - 0380_0009 and 0435_0009 are fixed - 0688_0041 now fails at runtime. This patch is testing firstprivate variables with tasks. Previously we got lucky with the undefined behavior and won the race. After these changes we no longer get lucky. This patch lays the groundwork for a proper fix for this issue. In flang the lowering re-uses the existing lowering used for reduction init and dealloc regions. In flang, before this patch we hit a TODO with the same wording when generating the copy region for firstprivate polymorphic variables. After this patch the box-like fir.class is passed by reference into the copy region, leading to a different path that didn't hit that old TODO but the generated code still didn't work so I added a new TODO in DataSharingProcessor. | 1 年前 | |
[AArch64] fix trampoline implementation: use X15 (#126743) AAPCS64 reserves any of X9-X15 for a compiler to choose to use for this purpose, and says not to use X16 or X18 like GCC (and the previous implementation) chose to use. The X18 register may need to get used by the kernel in some circumstances, as specified by the platform ABI, so it is generally an unwise choice. Simply choosing a different register fixes the problem of this being broken on any platform that actually follows the platform ABI (which is all of them except EABI, if I am reading this linux kernel bug correctly https://lkml2.uits.iu.edu/hypermail/linux/kernel/2001.2/01502.html). As a side benefit, also generate slightly better code and avoids needing the compiler-rt to be present. I did that by following the XCore implementation instead of PPC (although in hindsight, following the RISCV might have been slightly more readable). That X18 is wrong to use for this purpose has been known for many years (e.g. https://www.mail-archive.com/gcc@gcc.gnu.org/msg76934.html) and also known that fixing this to use one of the correct registers is not an ABI break, since this only appears inside of a translation unit. Some of the other temporary registers (e.g. X9) are already reserved inside llvm for internal use as a generic temporary register in the prologue before saving registers, while X15 was already used in rare cases as a scratch register in the prologue as well, so I felt that seemed the most logical choice to choose here. | 1 年前 | |
[mlir][flang] Added Weighted[Region]BranchOpInterface's. (#142079) The new interfaces provide getters and setters for the weight information about the branches of BranchOpInterface and RegionBranchOpInterface operations. These interfaces are done the same way as LLVM dialect's BranchWeightOpInterface. The plan is to produce this information in Flang, e.g. mark most probably "cold" code as such and allow LLVM to order basic blocks accordingly. An example of such a code is copy loops generated for arrays repacking - we can mark it as "cold" assuming that the copy will not happen dynamically. If the copy actually happens the overhead of the copy is probably high enough so that we may not care about the little overhead of jumping to the "cold" code and fetching it. | 1 年前 | |
[mlir][Pass] Include anchor op in -pass-pipeline In D134622 the printed form of a pass manager is changed to include the name of the op that the pass manager is anchored on. This updates the -pass-pipeline argument format to include the anchor op as well, so that the printed form of a pipeline can be directly passed to -pass-pipeline. In most cases this requires updating -pass-pipeline='pipeline' to -pass-pipeline='builtin.module(pipeline)'. This also fixes an outdated assert that prevented running a PassManager anchored on 'any'. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D134900 | 3 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
[flang] Cleanup code and add test from fir-dev This patch clean up some code for upstreaming and add couple of missing tests that were left in fir-dev. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128258 Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> | 4 年前 | |
[flang] Avoid generating duplicate symbol in comdat (#114472) In case where a fir.global might be duplicated in an inner module (gpu.module), the conversion pattern will be applied on the module and the gpu module version of the global and try to generate multiple comdat with the same symbol name. This is what we have in the implementation of CUDA Fortran. Just check for the presence of the ComdatSelectorOp before creating a new one. | 1 年前 | |
[flang] Add 32-bit AIX target specific in order to build 32-bit flang-rt (#136051) | 1 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] replace fir.complex usages with mlir complex (#110850) 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. | 1 年前 | |
[flang][FIR] remove fir.complex type and its fir.real element type (#111025) Final patch of https://discourse.llvm.org/t/rfc-flang-replace-usages-of-fir-complex-by-mlir-complex-type/82292 Since fir.real was only still used as fir.complex element type, this patch removes it at the same time. | 1 年前 | |
[flang] translate derived type array init to attribute if possible (#140268) This patch relies on #140235 and #139724 to speed-up compilations of files with derived type array global with initial value. Currently, such derived type global init was lowered to an llvm.mlir.insertvalue chain in the LLVM IR dialect because there was no way to represent such value via attributes. This chain was later folded in LLVM dialect to LLVM IR using LLVM IR (not dialect) folding. This insert chain generation and folding is very expensive for big arrays. For instance, this patch brings down the compilation of FM_lib fmsave.f95 from 50s to 0.5s. | 1 年前 | |
[flang] Canonicalize redundant pointer converts. (#121864) This patch adds a canonicalization pattern for optimizing redundant "pointer" fir.converts. Such converts prevent the StackArrays pass to recognize fir.freemem for the corresponding fir.allocmem, e.g.: %69 = fir.allocmem !fir.array<2xi32> %71:2 = hlfir.declare %69(%70) {uniq_name = ".tmp.arrayctor"} : (!fir.heap<!fir.array<2xi32>>, !fir.shape<1>) -> (!fir.heap<!fir.array<2xi32>>, !fir.heap<!fir.array<2xi32>>) %95 = fir.convert %71#1 : (!fir.heap<!fir.array<2xi32>>) -> !fir.ref<!fir.array<2xi32>> %100 = fir.convert %95 : (!fir.ref<!fir.array<2xi32>>) -> !fir.heap<!fir.array<2xi32>> fir.freemem %100 : !fir.heap<!fir.array<2xi32>> I found this in tonto, but the change does not affect performance at all. Anyway, it looks like a reasonable thing to do, and it makes easier to compare the performance profiles with other compilers'. | 1 年前 | |
| 1 年前 | ||
[flang][nfc] replace fir.dispatch_table with more generic fir.type_info (#68309) 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. | 2 年前 | |
[Flang][OpenMP][Dialect] Swap to using MLIR dialect enum to encode map flags (#164043) This PR shifts from using the LLVM OpenMP enumerator bit flags to an OpenMP dialect specific enumerator. This allows us to better represent map types that wouldn't be of interest to the LLVM backend and runtime in the dialect. Primarily things like ref_ptr/ref_ptee/ref_ptr_ptee/atach_none/attach_always/attach_auto which are of interest to the compiler for certrain transformations (primarily in the FIR transformation passes dealing with mapping), but the runtime has no need to know about them. It also means if another OpenMP implementation comes along they won't need to stick to the same bit flag system LLVM chose/do leg work to address it. | 10 个月前 | |
[flang] Use correct int extension flags for C-ABI calls on aarch64 (#137105) The AArch64 procedure call standard does not mandate that the callee extends the return value. Clang does not add signext to functions returning i8 or i16 on linux aarch64, but flang does. This means that runtime routines returning i8's will have signext on the callsite/declaration, but not on the implementation, and the call site will assume the return value has already been sign extended when it has not. This showed up in a test case calling MINVAL on an array of INTEGER*1. Adjust our integer extension flags to match clang and aarch64pcs on linux. The behavior on Darwin should be preserved. This is listed on the apple developer guide as a divergence from aarch64pcs. | 1 年前 | |
[Flang][OpenMP] Additional global address space modifications for device (#119585) A prior PR added a portion of the global address space modifications required for declare target to, this PR seeks to add a small amount more leftover from that PR. The intent is to allow for more correct IR that the backends (in particular AMDGPU) can treat more aptly for optimisations and code correctness 1/3 required PRs to enable declare target to mapping, should look at PR 3/3 to check for full green passes (this one will fail a number due to some dependencies). Co-authored-by: Raghu Maddhipatla raghu.maddhipatla@amd.com | 11 个月前 | |
[RFC][flang] Replace special symbols in uniqued global names. (#104859) This change addresses more "issues" as the one resolved in #71338. Some targets (e.g. NVPTX) do not accept global names containing .. In particular, the global variables created to represent the runtime information of derived types use . in their names. A derived type's descriptor object may be used in the device code, e.g. to initialize a descriptor of a variable of this type. Thus, the runtime type info objects may need to be compiled for the device. Moreover, at least the derived types' descriptor objects may need to be registered (think of omp declare target) for the host-device association so that the addendum pointer can be properly mapped to the device for descriptors using a derived type's descriptor as their addendum pointer. The registration implies knowing the name of the global variable in the device image so that proper host code can be created. So it is better to name the globals the same way for the host and the device. CompilerGeneratedNamesConversion pass renames all uniqued globals such that the special symbols (currently .) are replaced with X. The pass is supposed to be run for the host and the device. An option is added to FIR-to-LLVM conversion pass to indicate whether the new pass has been run before or not. This setting affects how the codegen computes the names of the derived types' descriptors for FIR derived types. fir::NameUniquer now allows X to be part of a name, because the name deconstruction may be applied to the mangled names after CompilerGeneratedNamesConversion pass. | 2 年前 | |
[flang] replace fir.complex usages with mlir complex (#110850) 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. | 1 年前 | |
[flang] Add more diagnostics to fir.coordinate_of Add more diagnostics to fir.coordinate_of to provide better checking that the IR is sane. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128255 Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> | 4 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] use DataLayout instead of GEP to compute element size (#140235) Now that the datalayout is part of codegen, use that to generate type size constants in codegen instead of generating GEP. | 1 年前 | |
[flang] Add lowering of volatile references (#132486) [RFC on discourse](https://discourse.llvm.org/t/rfc-volatile-representation-in-flang/85404/1) Flang currently lacks support for volatile variables. For some cases, the compiler produces TODO error messages and others are ignored. Some of our tests are like the example from _C.4 Clause 8 notes: The VOLATILE attribute (8.5.20)_ and require volatile variables. Prior commits: c9ec1bc753b0 [flang] Handle volatility in lowering and codegen (#135311) e42f8609858f [flang][nfc] Support volatility in Fir ops (#134858) b2711e1526f9 [flang][nfc] Support volatile on ref, box, and class types (#134386) | 1 年前 | |
| 1 年前 | ||
| 1 年前 | ||
[flang][debug] Make common blocks data extraction more robust. (#168752) Our current implementation for extracting information about common block required traversal of FIR which was not ideal but previously there was no other way to obtain that information. The [hl]fir.declare was extended in commit https://github.com/llvm/llvm-project/pull/155325 to include storage and storage_offset. This commit adds these operands in fircg.ext_declare and then use them in AddDebugInfoPass to create debug data for common blocks. | 9 个月前 | |
[flang] Added storage specification for [hl]fir.declare. (#155325) As proposed in https://discourse.llvm.org/t/rfc-flang-representation-for-objects-inside-physical-storage/88026, this patch adds a storage Value operand and a storage_offset Integer attribute for [hl]fir.declare operations. The storage operand indicates the raw address of the physical storage a variable belongs to. This is the beginning address of the physical storage. The storage_offset specifies a byte offset within the physical storage where the variable object starts. | 1 年前 | |
[flang][debug] Track dummy argument positions explicitly. (#167489) CHARACTER dummy arguments were treated as local variables in debug info. This happened because our method to get the argument number was not robust. It relied on DeclareOp having a direct reference to arguments which was not the case for character arguments. This is fixed by storing source-level argument positions in DeclareOp. Fixes #112886 | 9 个月前 | |
[flang][do concurrent] Re-model reduce to match reductions are modelled in OpenMP and OpenACC (#145837) This PR proposes re-modelling reduce specifiers to match OpenMP and OpenACC. In particular, this PR includes the following: * A new fir op: fir.delcare_reduction which is identical to OpenMP's omp.declare_reduction op. * Updating the reduce clause on fir.do_concurrent.loop to use the new op. * Re-uses the ReductionProcessor component to emit reductions for do concurrent just like we do for OpenMP. To do this, the ReductionProcessor had to be refactored to be more generalized. * Upates mapping do concurrent to fir.loop ... unordered nests using the new reduction model. Unfortunately, this is a big PR that would be difficult to divide up in smaller parts because the bottom of the changes are the fir table-gen changes to do concurrent. However, doing these MLIR changes cascades to the other parts that have to be modified to not break things. This PR goes in the same direction we went for private/local speicifiers. Now the do concurrent and OpenMP (and OpenACC) dialects are modelled in essentially the same way which makes mapping between them more trivial, hopefully. PR stack: - https://github.com/llvm/llvm-project/pull/145837 (this one) - https://github.com/llvm/llvm-project/pull/146025 - https://github.com/llvm/llvm-project/pull/146028 - https://github.com/llvm/llvm-project/pull/146033 | 1 年前 | |
[reland][flang] Initial debug info support for local variables (#92304) This is same as #90905 with an added fix. The issue was that we generated variable info even when user asked for line-tables-only. This caused llvm dwarf generation code to fail an assertion as it expected an empty variable list. Fixed by not generating debug info for variables when user wants only line table. I also updated a test check for this case. | 2 年前 | |
[flang] Added fir.dummy_scope operation to preserve dummy arguments association. (#90642) The new operation is just an abstract attribute that is attached to [hl]fir.declare operations of dummy arguments of a subroutine. Dummy arguments of the same subroutine refer to the same fir.dummy_scope, so they can be recognized as such during FIR AliasAnalysis. Note that the fir.dummy_scope must be specific to the runtime instantiation of a subroutine, so any MLIR inlining/cloning should duplicate and unique it vs using the same fir.dummy_scope for different runtime instantiations. This is why I made it an operation rather than an attribute. The new operation uses a write effect on DebuggingResource, same as [hl]fir.declare, to avoid optimizing it away. | 2 年前 | |
[flang] use DataLayout instead of GEP to compute element size (#140235) Now that the datalayout is part of codegen, use that to generate type size constants in codegen instead of generating GEP. | 1 年前 | |
[flang] use DataLayout instead of GEP to compute element size (#140235) Now that the datalayout is part of codegen, use that to generate type size constants in codegen instead of generating GEP. | 1 年前 | |
[flang] Fix bug in character casting. Add missing sext/trunc in code gen. This patch is part of the upstreaming effort from fir-dev branch. It also ensures all descriptors created inline complies with LBOUND requirement that the lower bound is 1 when the related dimension extent is zero. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128047 Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Jean Perier <jperier@nvidia.com> | 4 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
[Flang][MLIR][OpenMP] Remove the early outlining interface (#78450) After the removal of the OpenMP early outlining MLIR pass in #67319, the EarlyOutliningInterface stopped doing any useful work. It used to be necessary to tie the name of the function from which a target region was outlined to that new function, so it would be used when translating to LLVM IR in place of the outlined function's name. This is not necessary anymore, so this patch removes all references to this interface and uses of the omp.outline_parent_name discardable attribute in tests. | 2 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] Support arith::FastMathFlagsAttr for fir::CallOp. The main purpose of this patch is to propagate fastmath attribute to SimplifyIntrinsicsPass, so that the inline code can inherit the call operation's attributes. Even though I added translation of fastmath from fir::CallOp to LLVM::CallOp, there are no fastmath attributes in LLVM IR. It looks like the translation drops it. This will need additional commits. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D137602 | 3 年前 | |
[flang] Add FIR tests missing from fir-dev This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128331 Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com> | 4 年前 | |
| 1 年前 | ||
[flang][FIR] remove fir.complex type and its fir.real element type (#111025) Final patch of https://discourse.llvm.org/t/rfc-flang-replace-usages-of-fir-complex-by-mlir-complex-type/82292 Since fir.real was only still used as fir.complex element type, this patch removes it at the same time. | 1 年前 | |
[Flang][MLIR] Alter Fir.GlobalOp to print and lower external attributes Fir.GlobalOp's currently do not respect attributes that are applied to them, this change will do two things: - Allow lowering of arbitrary attributes applied to Fir.GlobalOp's to LLVMGlobalOp's during CodeGen - Allow printing and parsing of arbitrarily applied attributes This allows applying other dialects attributes (or other fir attributes) to fir.GlobalOps on the fly and have them exist in the resulting LLVM dialect IR or FIR IR. Reviewer: jeanPerier Differential Revision: https://reviews.llvm.org/D148352 | 3 年前 | |
[flang] Normalize logical values during type conversions. Flang was missing value normalization for logical<->integer conversions which is required by Flang specification. The shrinking logical<->logical conversions were also incorrectly truncating the input. This change performs value normalization for all logical<->integer conversions and logical<->logical conversions between different kinds. Note that value normalization is not strictly required for logical(kind=k1)->logical(kind=k2) conversions when k1 < k2. Differential Revision: https://reviews.llvm.org/D147019 | 3 年前 | |
[flang][driver] Make flang-new -fc1 accept MLIR files This relatively small change will allow Flang's frontend driver, flang-new -fc1, to consume and parse MLIR files. Semantically (i.e. from user's perspective) this is identical to reading LLVM IR files. Two file extensions are associated with MLIR files: .fir and .mlir. Note that reading MLIR files makes only sense when running one of the code-generation actions, i.e. when using one of the following action flags: -S, -emit-obj, -emit-llvm, -emit-llvm-bc. The majority of tests that required tco to run are updated to also run with flang-new -fc1. A few tests are updated to use fir-opt instead of tco (that's the preferred choice when testing a particular MLIR pass). basic-program.fir is not updated as that test is intended to verify the behaviour of tco specifically. Differential Revision: https://reviews.llvm.org/D126890 | 4 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang]Fix build failure in tests After submitting the DataLayout fix, some tests fail when they didn't before. This has to do with the target essentially being ignored when these tests were run earlier, as the --target x86-unknown-linux-gnu only has to be correctly formed to be accepted. Now the target triple is actually being used to get the targetmachine earlier - before MLIR is generated - so the test that has a valid target but not available on the platform fails. Fix is to require x86 registered target when running those tests. Reviewed By: awarzynski Differential Revision: https://reviews.llvm.org/D137335 | 3 年前 | |
[flang][nfc] Support volatile on ref, box, and class types (#134386) Part one of merging #132486. Add support for representing volatility in the type system for reference, box, and class types. Don't do anything with volatile just yet, only support and test their representation and utility functions. The naming convention is a little goofy - fir::isa_volatile_type and fir::updateTypeWithVolatility use different capitalization, but I put them near similar functions and tried to match the surrounding conventions and [the docs](https://github.com/llvm/llvm-project/blob/main/flang/docs/C%2B%2Bstyle.md#naming) best I could. | 1 年前 | |
[flang] Added storage specification for [hl]fir.declare. (#155325) As proposed in https://discourse.llvm.org/t/rfc-flang-representation-for-objects-inside-physical-storage/88026, this patch adds a storage Value operand and a storage_offset Integer attribute for [hl]fir.declare operations. The storage operand indicates the raw address of the physical storage a variable belongs to. This is the beginning address of the physical storage. The storage_offset specifies a byte offset within the physical storage where the variable object starts. | 1 年前 | |
[flang] Added fir.is_contiguous_box and fir.box_total_elements ops. (#131047) These are helper operations to aid with expanding of fir.pack_array. | 1 年前 | |
[flang][fir] add fir.is_assumed_size codegen (#93953) Lower to IsAssumedSize runtime call in --fir-assumed-rank-op pass. | 2 年前 | |
[flang] Erase fir.local ops before lowering fir to llvm (#143687) fir.local ops are not supposed to have any uses at this point (i.e. during lowering to LLVM). In case of serialization, the fir.do_concurrent users are expected to have been lowered to fir.do_loop nests. In case of parallelization, the fir.do_concurrent users are expected to have been lowered to the target parallel model (e.g. OpenMP). This hopefully resolved a build issue introduced by https://github.com/llvm/llvm-project/pull/142567 (see for example: https://lab.llvm.org/buildbot/#/builders/199/builds/4009). | 1 年前 | |
[flang] Normalize logical values during type conversions. Flang was missing value normalization for logical<->integer conversions which is required by Flang specification. The shrinking logical<->logical conversions were also incorrectly truncating the input. This change performs value normalization for all logical<->integer conversions and logical<->logical conversions between different kinds. Note that value normalization is not strictly required for logical(kind=k1)->logical(kind=k2) conversions when k1 < k2. Differential Revision: https://reviews.llvm.org/D147019 | 3 年前 | |
| 1 年前 | ||
| 1 年前 | ||
[flang] Add reduction semantics to fir.do_loop (#93934) Derived from #92480. This PR introduces reduction semantics into loops for DO CONCURRENT REDUCE. The fir.do_loop operation now invisibly has the operandSegmentsizes attribute and takes variable-length reduction operands with their operations given as fir.reduce_attr. For the sake of compatibility, fir.do_loop's builder has additional arguments at the end. The iter_args operand should be placed in front of the declaration of result types, so the new operand for reduction variables (reduce) is put in the middle of arguments. | 2 年前 | |
[mlir][flang] Make use of the new GEPArg builder of GEP Op to simplify code This is the follow up on https://reviews.llvm.org/D130730 which goes through upstream code and removes creating constant values in favour of using the constant indices in GEP directly. This leads to less and more readable code and more compact IR as well. Differential Revision: https://reviews.llvm.org/D130731 | 4 年前 | |
[flang] handle alloca outside of entry blocks in MemoryAllocation (#98457) This patch generalizes the MemoryAllocation pass (alloca -> heap) to handle fir.alloca regardless of their postion in the IR. Currently, it only dealt with fir.alloca in function entry blocks. The logic is placed in a utility that can be used to replace alloca in an operation on demand to whatever kind of allocation the utility user wants via callbacks (allocmem, or custom runtime calls to instrument the code...). To do so, a concept of ownership, that was already implied a bit and used in passes like stack-reclaim, is formalized. Any operation with the LoopLikeInterface, AutomaticAllocationScope, or IsolatedFromAbove owns the alloca directly nested inside its regions, and they must not be used after the operation. The pass then looks for the exit points of region with such interface, and use that to insert deallocation. If dominance is not proved, the pass fallbacks to storing the new address into a C pointer variable created in the entry of the owning region which allows inserting deallocation as needed, included near the alloca itself to avoid leaks when the alloca is executed multiple times due to block CFGs loops. This should fix https://github.com/llvm/llvm-project/issues/88344. In a next step, I will try to refactor lowering a bit to introduce lifetime operation for alloca so that the deallocation points can be inserted as soon as possible. | 2 年前 | |
Revert "[flang] disable memory-allocation-opt.fir test on windows" (#83822) Reverts llvm/llvm-project#83535 Bug fixed by https://github.com/llvm/llvm-project/pull/83768 | 2 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
[flang][NFC] Strip trailing whitespace from tests (2 of N) Only the fortran source files in flang/test have been modified. The other files in the directory will be cleaned up in subsequent commits | 9 个月前 | |
[flang][codegen] Update FIR codegen to use mlir.llvm opaque pointers (#69692) !llvm.ptr<T> typed pointers are depreciated in MLIR LLVM dialects. Flang codegen still generated them and relied on mlir.llvm codegen to LLVM to turn them into opaque pointers. This patch update FIR codegen to directly emit and work with LLVM opaque pointers. Addresses https://github.com/llvm/llvm-project/issues/69303 - All places generating GEPs need to add an extra type argument with the base type (the T that was previously in the llvm.ptr<T> of the base). - llvm.alloca must also be provided the object type. In the process, I doscovered that we were shamelessly copying all the attribute from fir.alloca to the llvm.alloca, which makes no sense for the operand segments. The updated code that cannot take an attribute dictionnary in the llvm.alloca builder with opaque pointers only propagate the "pinned" and "bindc_name" attributes to help debugging the generated IR. - Updating all the places that rely on getting the llvm object type from lowered llvm.ptr<T> arguments to get it from a type conversion of the original fir types. - Updating all the places that were generating llvm.ptr<T> types to generate the opaque llvm.ptr type. - Updating all the codegen tests checking generated MLIR llvm dialect. Many tests are testing directly LLVM IR, and this change is a no-op for those (which is expected). | 2 年前 | |
[flang][NFC] Characterize allocation based on MemAlloc effect instead of pattern matching (#166806) Flang alias analysis used to find allocation site by pattern matching allocation ops in mainly FIR dialect. This MR extends the characterization to instead characterize based on whether the result of an op has MemAlloc effect. | 9 个月前 | |
[flang][OpenMP] Add OutlineableOpenMPOpInterface to omp.teams (#131109) Given the following input: fortran program rep_loopbind implicit none integer :: i real :: priv_val !$omp teams private(priv_val) !$omp distribute do i=1,1000 end do !$omp end teams end program the AllocaOpConversion pattern in FIRToLLVMLowering would **move** the private allocations that belong to the teams directive (i.e. the allocations needed for the private copies of priv_val and the loop's iteration variable) from the the omp.teams op to the outside scope. This is not correct since these allocations should be eventually emitted inside the outlined region for the teams directive. Without this fix, these allocation would be emitted in the parent function (or the parent scope whatever it is). | 1 年前 | |
[OpenMP] Introduce omp.target_allocmem and omp.target_freemem omp dialect ops. (#145464) This PR introduces two new ops in omp dialect, omp.target_allocmem and omp.target_freemem. omp.target_allocmem: Allocates heap memory on device. Will be lowered to omp_target_alloc call in llvm. omp.target_freemem: Deallocates heap memory on device. Will be lowered to omp+target_free call in llvm. Example: %1 = omp.target_allocmem %device : i32, i64 omp.target_freemem %device, %1 : i32, i64 The work in this PR is C-P/inspired from @ivanradanov commit from coexecute implementation: [Add fir omp target alloc and free ops](https://github.com/ivanradanov/llvm-project/commit/be860ac8baf24b8405e6f396c75d7f0d26375de5) [Lower omp_target_{alloc,free} to llvm](https://github.com/ivanradanov/llvm-project/commit/6e2d584dc93ff99bb89adc28c7afbc2b21c46d39) | 1 年前 | |
[flang][extension] support concatenation with absent optional (#112678) Fix #112593 by adding support in lowering to concatenation with an absent optional _assumed length_ dummy argument because: 1. Most compilers seem to support it (most likely by accident). 2. This actually makes the compiler codegen simpler. Codegen was going out of its way to poke the LLVM optimizer bear by producing an undef argument for the length. I insist on the fact that no compiler support this with _explicit length_ optional arguments and the executable will segfault and I would discourage users from using that "feature" because runtime checks for bad optional dereference will kick when used (For instance, "nagfor -C=present" will produce an executable that abort with an error message . Flang does not have such runtime check option so far). Hence, I am not updating the Extensions.md document because this is not something I think we should advertise. | 1 年前 | |
[flang][NFC] Characterize allocation based on MemAlloc effect instead of pattern matching (#166806) Flang alias analysis used to find allocation site by pattern matching allocation ops in mainly FIR dialect. This MR extends the characterization to instead characterize based on whether the result of an op has MemAlloc effect. | 9 个月前 | |
[flang][driver] Make flang-new -fc1 accept MLIR files This relatively small change will allow Flang's frontend driver, flang-new -fc1, to consume and parse MLIR files. Semantically (i.e. from user's perspective) this is identical to reading LLVM IR files. Two file extensions are associated with MLIR files: .fir and .mlir. Note that reading MLIR files makes only sense when running one of the code-generation actions, i.e. when using one of the following action flags: -S, -emit-obj, -emit-llvm, -emit-llvm-bc. The majority of tests that required tco to run are updated to also run with flang-new -fc1. A few tests are updated to use fir-opt instead of tco (that's the preferred choice when testing a particular MLIR pass). basic-program.fir is not updated as that test is intended to verify the behaviour of tco specifically. Differential Revision: https://reviews.llvm.org/D126890 | 4 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] Add FIR tests missing from fir-dev This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: jeanPerier, PeteSteinfeld Differential Revision: https://reviews.llvm.org/D128331 Co-authored-by: Jean Perier <jperier@nvidia.com> Co-authored-by: Eric Schweitz <eschweitz@nvidia.com> Co-authored-by: Kiran Chandramohan <kiran.chandramohan@arm.com> | 4 年前 | |
[MLIR][LLVMIR] Use TargetFolder when creating globals (#126745) The LLVM dialect lowers globals using IRBuilder, relying on it creating constant expressions where possible. As we remove support for more constant expressions (per https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179), this can cause issues for cases where the constant expression is no longer supported, and the operation cannot be constant folded without DataLayout being available. In particular, I ran into this issue with flang and the removal of mul constant expressions. Address this by using TargetFolder when creating globals, which will perform DL-aware constant folding. I think it would make sense to also do this in general, but I'm starting with globals where not doing this can result in translation failures. Ideally, globals with these problematic expressions would never be generated in the first place, but there has been little movement on fixing this (https://github.com/llvm/llvm-project/issues/96047). | 1 年前 | |
[flang][codegen] Update FIR codegen to use mlir.llvm opaque pointers (#69692) !llvm.ptr<T> typed pointers are depreciated in MLIR LLVM dialects. Flang codegen still generated them and relied on mlir.llvm codegen to LLVM to turn them into opaque pointers. This patch update FIR codegen to directly emit and work with LLVM opaque pointers. Addresses https://github.com/llvm/llvm-project/issues/69303 - All places generating GEPs need to add an extra type argument with the base type (the T that was previously in the llvm.ptr<T> of the base). - llvm.alloca must also be provided the object type. In the process, I doscovered that we were shamelessly copying all the attribute from fir.alloca to the llvm.alloca, which makes no sense for the operand segments. The updated code that cannot take an attribute dictionnary in the llvm.alloca builder with opaque pointers only propagate the "pinned" and "bindc_name" attributes to help debugging the generated IR. - Updating all the places that rely on getting the llvm object type from lowered llvm.ptr<T> arguments to get it from a type conversion of the original fir types. - Updating all the places that were generating llvm.ptr<T> types to generate the opaque llvm.ptr type. - Updating all the codegen tests checking generated MLIR llvm dialect. Many tests are testing directly LLVM IR, and this change is a no-op for those (which is expected). | 2 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[flang] Do not produce result for void runtime call (#123155) Runtime function call to a void function are producing a ssa value because the FunctionType result is set to NoneType with is later translated to a empty struct. This is not an issue when going to LLVM IR but it breaks when lowering a gpu module to PTX. This patch update the RTModel to correctly set the FunctionType result type to nothing. This is one runtime call before this patch at the LLVM IR dialect step. %45 = llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> !llvm.struct<()> After the patch the call would be correctly formed llvm.call @_FortranAAssign(%arg0, %1, %44, %4) : (!llvm.ptr, !llvm.ptr, !llvm.ptr, i32) -> () Without the patch it would lead to error like: ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 10; error : Output parameter cannot be an incomplete array. ptxas /tmp/mlir-cuda_device_mod-nvptx64-nvidia-cuda-sm_60-e804b6.ptx, line 125; error : Call has wrong number of parameters The change is pretty much mechanical. | 1 年前 | |
[flang] Add struct passing target rewrite hooks and partial X86-64 impl (#74829) In the context of C/Fortran interoperability (BIND(C)), it is possible to give the VALUE attribute to a BIND(C) derived type dummy, which according to Fortran 2018 18.3.6 - 2. (4) implies that it must be passed like the equivalent C structure value. The way C structure value are passed is ABI dependent. LLVM does not implement the C struct ABI passing for LLVM aggregate type arguments. It is up to the front-end, like clang is doing, to split the struct into registers or pass the struct on the stack (llvm "byval") as required by the target ABI. So the logic for C struct passing sits in clang. Using it from flang requires setting up a lot of clang context and to bridge FIR/MLIR representation to clang AST representation for function signatures (in both directions). It is a non trivial task. See https://stackoverflow.com/questions/39438033/passing-structs-by-value-in-llvm-ir/75002581#75002581. Since BIND(C) struct are rather limited as opposed to generic C struct (e.g. no bit fields). It is easier to provide a limited implementation of it for the case that matter to Fortran. This patch: - Updates the generic target rewrite pass to keep track of both the new argument type and attributes. The motivation for this is to be able to tell if a previously marshalled argument is passed in memory (it is a C pointer), or if it is being passed on the stack (has the byval llvm attributes). - Adds an entry point in the target specific codegen to marshal struct arguments, and use it in the generic target rewrite pass. - Implements limited support for the X86-64 case. So far, the support allows telling if a struct must be passed in register or on the stack, and to deal with the stack case. The register case is left TODO in this patch. The X86-64 ABI implemented is the System V ABI for AMD64 version 1.0 | 2 年前 | |
[flang][codegen] Update FIR codegen to use mlir.llvm opaque pointers (#69692) !llvm.ptr<T> typed pointers are depreciated in MLIR LLVM dialects. Flang codegen still generated them and relied on mlir.llvm codegen to LLVM to turn them into opaque pointers. This patch update FIR codegen to directly emit and work with LLVM opaque pointers. Addresses https://github.com/llvm/llvm-project/issues/69303 - All places generating GEPs need to add an extra type argument with the base type (the T that was previously in the llvm.ptr<T> of the base). - llvm.alloca must also be provided the object type. In the process, I doscovered that we were shamelessly copying all the attribute from fir.alloca to the llvm.alloca, which makes no sense for the operand segments. The updated code that cannot take an attribute dictionnary in the llvm.alloca builder with opaque pointers only propagate the "pinned" and "bindc_name" attributes to help debugging the generated IR. - Updating all the places that rely on getting the llvm object type from lowered llvm.ptr<T> arguments to get it from a type conversion of the original fir types. - Updating all the places that were generating llvm.ptr<T> types to generate the opaque llvm.ptr type. - Updating all the codegen tests checking generated MLIR llvm dialect. Many tests are testing directly LLVM IR, and this change is a no-op for those (which is expected). | 2 年前 | |
[flang] Rename hypotf on MSVC platforms The single precision hypot intrinsic is lowered to a call to the libm hypotf function. However, the MSVC runtime lacks a hypotf function and instead uses _hypotf (*). This patch tries to find and rewrite calls to hypotf if we're on a MSVC platform. Calls to libm functions can be introduced even after lowering (**). Therefore, we try to do the rewriting at the very end of FIR to LLVM lowering. Fixes https://github.com/llvm/llvm-project/issues/57563 (*) More specifically, MSVC's headers define hypotf as an inline function that just calls _hypotf. This works fine for clang, since it will include those headers, but flang only links with the CRT so we don't get a free ride. (**) https://github.com/llvm/llvm-project/blob/56f94ede2af9a327e59fe84dbf8cbbb7bb1dfa79/flang/lib/Optimizer/CodeGen/CodeGen.cpp#L3391 Differential Revision: https://reviews.llvm.org/D135853 | 3 年前 | |
| 1 年前 | ||
| 1 年前 | ||
[flang][test] Fix filecheck annotation typos (#92387) | 1 年前 | |
[flang] fix AArch64 PCS for struct following pointer (#127802) Pointers are already handled as taking up a register in the ABI handling, but the handling for structs was not taking this into account. This patch changes the struct handling to acknowledge that pointer arguments take up an integer register. Fixes #123075 | 1 年前 | |
[flang] handle passing bind(c) derived type by value for ppc64le and powerpc64-aix (#128780) | 1 年前 | |
[flang] handle passing bind(c) derived type by value for ppc64le and powerpc64-aix (#128780) | 1 年前 | |
[flang] handle passing bind(c) derived type by value for ppc64le and powerpc64-aix (#128780) | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
| 11 个月前 | ||
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] do not rely on existing fir.convert in TargetRewrite (#157413) TargetRewrite is doing a shallow rewrite of function signatures. It is only rewriting function definitions (FuncOp), calls (CallOp) and AddressOfOp. It is not trying to visit each operations that may have an operand with a function type. It therefore needs function signature casts around the operations it is rewriting. Currently, these casts were not inserted after AddressOfOp rewrites because lowering tends to always insert function cast after generating AddressOfOp to the void type so the pass relied on implicitly updating this cast operand type to get the required cast. This is brittle because there is no guarantee such convert must be here and canonicalization and passes may remove them. Insert a cast after on the result of rewritten operations. If it is redundant, it will be canonicalized away later. | 11 个月前 | |
[flang] replace fir.complex usages with mlir complex (#110850) 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. | 1 年前 | |
[flang] replace fir.complex usages with mlir complex (#110850) 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. | 1 年前 | |
[flang][fir] fix ABI bug 116844 (#118121) Fix issue #116844. The issue came from a look-up on the func.func for the sret attribute when lowering fir.call with character arguments. This was broken because the func.func may or may not have been rewritten when dealing with the fir.call, but the lookup assumed it had not been rewritten yet. If the func.func was rewritten and the result moved to a sret argument, the call was lowered as if the character was meant to be the result, leading to bad call code and an assert. It turns out that the whole logic is actually useless since fir.boxchar are never lowered as sret arguments, instead, lowering directly breaks the character result into the first two fir.ref<>, i64 arguments. So, the sret case was actually never used, except in this bug. Hence, instead of fixing the logic (probably by looking for argument attributes on the call itself), just remove this logic that brings unnecessary complexity. | 1 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
| 11 个月前 | ||
[flang] Add 32-bit AIX target specific in order to build 32-bit flang-rt (#136051) | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] Propagate fast-math flags in target-rewrite (#135723) TargetRewritePass was dropping fast-math flags. Add the flags to the new call ops and update tests. | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] also set llvm ABI argument attributes on direct calls (#130736) So far, flang was not setting argument attributes on direct calls assuming that putting them on the function operation was enough. It was clarified in https://github.com/llvm/llvm-project/commit/38565da5259729898c2a552d54b72f3314241734 that they must be set on both call and functions, even for direct calls. Crashes have been observed because of the lack of the attribute when compiling abs(x) at O2 and above on X86-64 for complex(16). | 1 年前 | |
[flang] Use correct int extension flags for C-ABI calls on aarch64 (#137105) The AArch64 procedure call standard does not mandate that the callee extends the return value. Clang does not add signext to functions returning i8 or i16 on linux aarch64, but flang does. This means that runtime routines returning i8's will have signext on the callsite/declaration, but not on the implementation, and the call site will assume the return value has already been sign extended when it has not. This showed up in a test case calling MINVAL on an array of INTEGER*1. Adjust our integer extension flags to match clang and aarch64pcs on linux. The behavior on Darwin should be preserved. This is listed on the apple developer guide as a divergence from aarch64pcs. | 1 年前 | |
[flang] Add option to skip struct argument rewrite in target-rewrite (#75939) Be consistent with complex and character rewrite so that the pass can be run selectively. | 2 年前 | |
[flang] Propagate fast-math flags in target-rewrite (#135723) TargetRewritePass was dropping fast-math flags. Add the flags to the new call ops and update tests. | 1 年前 | |
[Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (#78289) This patch forwards the target CPU and features information from the Flang frontend to MLIR func.func operation attributes, which are later used to populate the target_cpu and target_features llvm.func attributes. This is achieved in two stages: 1. Introduce the fir.target_cpu and fir.target_features module attributes with information from the target machine immediately after the initial creation of the MLIR module in the lowering bridge. 2. Update the target rewrite flang pass to get this information from the module and pass it along to all func.func MLIR operations, respectively as attributes named target_cpu and target_features. These attributes will be automatically picked up during Func to LLVM dialect lowering and used to initialize the corresponding llvm.func named attributes. The target rewrite and FIR to LLVM lowering passes are updated with the ability to override these module attributes, and the CodeGenSpecifics optimizer class is augmented to make this information available to target-specific MLIR transformations. This completes a full flow by which target CPU and features make it all the way from compiler options to LLVM IR function attributes. | 2 年前 | |
[Flang][Lower] Attach target_cpu and target_features attributes to MLIR functions (#78289) This patch forwards the target CPU and features information from the Flang frontend to MLIR func.func operation attributes, which are later used to populate the target_cpu and target_features llvm.func attributes. This is achieved in two stages: 1. Introduce the fir.target_cpu and fir.target_features module attributes with information from the target machine immediately after the initial creation of the MLIR module in the lowering bridge. 2. Update the target rewrite flang pass to get this information from the module and pass it along to all func.func MLIR operations, respectively as attributes named target_cpu and target_features. These attributes will be automatically picked up during Func to LLVM dialect lowering and used to initialize the corresponding llvm.func named attributes. The target rewrite and FIR to LLVM lowering passes are updated with the ability to override these module attributes, and the CodeGenSpecifics optimizer class is augmented to make this information available to target-specific MLIR transformations. This completes a full flow by which target CPU and features make it all the way from compiler options to LLVM IR function attributes. | 2 年前 | |
[mlir] Remove special case parsing/printing of func operations This was leftover from when the standard dialect was destroyed, and when FuncOp moved to the func dialect. Now that these transitions have settled a bit we can drop these. Most updates were handled using a simple regex: replace ^( *)func with $1func.func Differential Revision: https://reviews.llvm.org/D124146 | 4 年前 | |
| 11 个月前 | ||
[flang] Unwrap sequence types when checking for descriptor members (#136039) The TBAA generation gives conservative TBAA metadata when handling an access of a record type with a descriptor member, since the access may be a regular data access OR another descriptor. Array members were being incorrectly identified as non-descriptor-members, and were giving incorrect TBAA metadata which led to bugs showing up in the optimizer when LLVM encountered mismatching TBAA. fir::isRecordWithDescriptorMember now unwraps sequence types before checking for descriptor members. | 1 年前 | |
Reland "[flang] Added noalias attribute to function arguments. (#140803)" This helps to disambiguate accesses in the caller and the callee after LLVM inlining in some apps. I did not see any performance changes, but this is one step towards enabling other optimizations in the apps that I am looking at. The definition of llvm.noalias says: ... indicates that memory locations accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value. This guarantee only holds for memory locations that are modified, by any means, during the execution of the function. I believe this exactly matches Fortran rules for the dummy arguments that are modified during their subprogram execution. I also set llvm.noalias and llvm.nocapture on the !fir.box<> arguments, because the corresponding descriptors cannot be captured and cannot alias anything (not based on them) during the execution of the subprogram. | 1 年前 | |
[Flang] Turn on alias analysis for locally allocated objects (#143489) Previously, a bug in the MemCptOpt LLVM IR pass caused issues with adding alias tags for locally allocated objects for Fortran code. However, the bug has now been fixed (https://github.com/llvm/llvm-project/pull/129537 ), and we can safely enable alias tags for these objects. This change should improve the accuracy of the alias analysis. More accurate alias analysis assumes that Cray pointers do not alias with other variables. This assumption is common among other compilers. If the code violates this assumption, it can lead to incorrect results (see: https://github.com/llvm/llvm-project/issues/141928) | 1 年前 | |
[flang][fir] always use memcpy for fir.box (#113949) @jeanPerier explained the importance of converting box loads and stores into memcpys instead of aggregate loads and stores, and I'll do my best to explain it here. * [(godbolt link) Example comparing opt transformations on memcpys vs aggregate load/stores](https://godbolt.org/z/be7xM83cG) * LLVM can more effectively reason about memcpys compared to aggregate load/stores. * This came up when others were discussing array descriptors for assumed-rank arrays passed to bind(c) subroutines, with the implication that the array descriptors are known to have lower bounds of 1 and that they are not pointer/allocatable types. * [(godbolt link) Clang also uses memcpys so we should probably follow them, assuming the clang developers are generatign what they know Opt will handle more effectively.](https://godbolt.org/z/YT4x7387W) * This currently may not help much without the nocapture attribute being propagated to function calls, but [it looks like someone may do this soon (discourse link)](https://discourse.llvm.org/t/applying-the-nocapture-attribute-to-reference-passed-arguments-in-fortran-subroutines/81401/23) or I can do this in a follow-up patch. Note on test flang/test/Fir/embox-char.fir: it looks like the original test was auto-generated. I wasn't too sure which parts were especially important to test, so I regenerated the test. If we want the updated version to look more like the old version, I'll make those changes. | 1 年前 | |
[MLIR][DLTI] Pretty parsing and printing for DLTI attrs (#113365) Unifies parsing and printing for DLTI attributes. Introduces a format of #dlti.attr<key1 = val1, ..., keyN = valN> syntax for all queryable DLTI attributes similar to that of the DictionaryAttr, while retaining support for specifying key-value pairs with #dlti.dl_entry (whether to retain this is TBD). As the new format does away with most of the boilerplate, it is much easier to parse for humans. This makes an especially big difference for nested attributes. Updates the DLTI-using tests and includes fixes for misc error checking/ error messages. | 1 年前 | |
[MLIR][DLTI] Pretty parsing and printing for DLTI attrs (#113365) Unifies parsing and printing for DLTI attributes. Introduces a format of #dlti.attr<key1 = val1, ..., keyN = valN> syntax for all queryable DLTI attributes similar to that of the DictionaryAttr, while retaining support for specifying key-value pairs with #dlti.dl_entry (whether to retain this is TBD). As the new format does away with most of the boilerplate, it is much easier to parse for humans. This makes an especially big difference for nested attributes. Updates the DLTI-using tests and includes fixes for misc error checking/ error messages. | 1 年前 | |
[MLIR][LLVMIR] Use TargetFolder when creating globals (#126745) The LLVM dialect lowers globals using IRBuilder, relying on it creating constant expressions where possible. As we remove support for more constant expressions (per https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179), this can cause issues for cases where the constant expression is no longer supported, and the operation cannot be constant folded without DataLayout being available. In particular, I ran into this issue with flang and the removal of mul constant expressions. Address this by using TargetFolder when creating globals, which will perform DL-aware constant folding. I think it would make sense to also do this in general, but I'm starting with globals where not doing this can result in translation failures. Ideally, globals with these problematic expressions would never be generated in the first place, but there has been little movement on fixing this (https://github.com/llvm/llvm-project/issues/96047). | 1 年前 | |
[flang][FIR] remove fir.complex type and its fir.real element type (#111025) Final patch of https://discourse.llvm.org/t/rfc-flang-replace-usages-of-fir-complex-by-mlir-complex-type/82292 Since fir.real was only still used as fir.complex element type, this patch removes it at the same time. | 1 年前 | |
[flang] replace fir.complex usages with mlir complex (#110850) 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. | 1 年前 | |
[flang] Implement !DIR$ VECTOR ALWAYS (#93830) This patch implements support for the VECTOR ALWAYS directive, which forces vectorization to occurr when possible regardless of a decision by the cost model. This is done by adding an attribute to the branch into the loop in LLVM to indicate that the loop should always be vectorized. This patch only implements this directive on plan structured do loops without labels. Support for unstructured loops and array expressions is planned for future patches. | 2 年前 | |
[flang] Add loop annotation attributes to the loop backedge (#126082) Flang currently adds loop metadata to a conditional branch in the loop preheader, while clang adds it to the loop latch's branch instruction. Langref says: > Currently, loop metadata is implemented as metadata attached to the branch instruction in the loop latch block. > > https://llvm.org/docs/LangRef.html#llvm-loop I misread langref a couple times, but I think this is the appropriate branch op for the LoopAnnotationAttr. In a couple examples I found that the metadata was lost entirely during canonicalization. This patch makes the codegen look more like clang's and the annotations persist through codegen. * current clang: https://godbolt.org/z/8WhbcrnG3 * current flang: https://godbolt.org/z/TrPboqqcn | 1 年前 | |
[flang] Hide strict volatility checks behind flag (#138183) Enabling volatility lowering by default revealed some issues in lowering and op verification. For example, given volatile variable of a nested type, accessing structure members of a structure member would result in a volatility mismatch when the inner structure member is designated (and thus a verification error at compile time). In other cases, I found correct codegen when the checks were disabled, also related to allocatable types and how we handle volatile references of boxes. This hides the strict verification of fir and hlfir ops behind a flag so I can iteratively improve lowering of volatile variables without causing compile-time failures, keeping the strict verification on when running tests. | 1 年前 | |
[flang] Hide strict volatility checks behind flag (#138183) Enabling volatility lowering by default revealed some issues in lowering and op verification. For example, given volatile variable of a nested type, accessing structure members of a structure member would result in a volatility mismatch when the inner structure member is designated (and thus a verification error at compile time). In other cases, I found correct codegen when the checks were disabled, also related to allocatable types and how we handle volatile references of boxes. This hides the strict verification of fir and hlfir ops behind a flag so I can iteratively improve lowering of volatile variables without causing compile-time failures, keeping the strict verification on when running tests. | 1 年前 | |
[flang][driver] Make flang-new -fc1 accept MLIR files This relatively small change will allow Flang's frontend driver, flang-new -fc1, to consume and parse MLIR files. Semantically (i.e. from user's perspective) this is identical to reading LLVM IR files. Two file extensions are associated with MLIR files: .fir and .mlir. Note that reading MLIR files makes only sense when running one of the code-generation actions, i.e. when using one of the following action flags: -S, -emit-obj, -emit-llvm, -emit-llvm-bc. The majority of tests that required tco to run are updated to also run with flang-new -fc1. A few tests are updated to use fir-opt instead of tco (that's the preferred choice when testing a particular MLIR pass). basic-program.fir is not updated as that test is intended to verify the behaviour of tco specifically. Differential Revision: https://reviews.llvm.org/D126890 | 4 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 9 个月前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 9 个月前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 4 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 2 年前 | ||
| 4 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 10 个月前 | ||
| 10 个月前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 11 个月前 | ||
| 4 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 4 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 11 个月前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 4 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 3 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 4 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 4 年前 | ||
| 9 个月前 | ||
| 2 年前 | ||
| 9 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 9 个月前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 4 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 3 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 4 年前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 2 年前 | ||
| 4 年前 | ||
| 11 个月前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 4 年前 |