3494 Commits

Author SHA1 Message Date
Slava Zakharin
47025af639
[flang][hlfir] Alias analysis for host associated accesses. (#65919)
This patch adds `host_assoc` attribute for operations that implement
FortranVariableInterface (e.g. `hlfir.declare`). The attribute is used
by the alias analysis to make better conclusions about memory overlap.
For example, a dummy argument of an inner subroutine and a host's
variable used inside the inner subroutine cannot refer to the same
object (if the dummy argument does not satisify exceptions in F2018
15.5.2.13).
This closes a performance gap between HLFIR optimization pipeline
and FIR ArrayValueCopy for Polyhedron/nf.
2023-09-18 09:59:06 -07:00
Peter Klausler
9bbec0ad42
[flang] Fix SIZEOF() expression rewriting (#66241)
The rewriting of the extension intrinsic function SIZEOF was producing
results that would reference symbols that were not available in the
current scope, leading to crashes in lowering. The symbols could be
function result variables, for SIZEOF(func()), or bare derived type
component names, for SIZEOF(array(n)%component). Fixing this without
regressing on a current test case involved careful threading of some
state through the TypeAndShape characterization code and the
shape/bounds analyzer, and some clean-up was done along the way.
2023-09-18 09:20:50 -07:00
Peter Klausler
39f1860dcc
[flang] Fold NORM2() (#66240)
Fold references to the (relatively new) intrinsic function NORM2 at
compilation time when the argument(s) are all constants. (Getting this
done right involved some changes to the API of the accumulator function
objects used by the DoReduction<> template, which rippled through some
other reduction function folding code.)
2023-09-18 08:58:19 -07:00
Peter Klausler
f025e41174
[flang] Accept pointer-valued function results as ASSOCIATED() arguments (#66238)
The POINTER= and TARGET= arguments to the intrinsic function
ASSOCIATED() can be the results of references to functions that return
object pointers or procedure pointers. NULL() was working well but not
program-defined pointer-valued functions. Correct the validation of
ASSOCIATED() and extend the infrastructure used to detect and
characterize procedures and pointers.
2023-09-18 08:22:18 -07:00
Kiran Chandramohan
e2733a6767
[Flang][OpenMP] Add trivial conversion pattern for omp.ordered_region (#66085)
Fixes #65570
2023-09-18 16:05:17 +01:00
Sergio Afonso
fb4bdf361f
[Flang][OpenMP] Run Flang-specific OpenMP MLIR passes in bbc
This patch moves the group of OpenMP MLIR passes using after lowering of
Fortran to MLIR into a pipeline to be shared by `flang-new` and `bbc`.
Currently, the `bbc` tool does not produce the expected FIR for offloading-
enabled OpenMP codes due to not running these passes.

Unit tests exercising these passes are updated to check `bbc` output as well.
2023-09-18 14:10:04 +01:00
jeanPerier
99a54b839a
[flang] Lower PRIVATE component names safely (#66076)
It is possible for a derived type extending a type with private
components to define components with the same name as the private
components.

This was not properly handled by lowering where several fir.record type
component names could end-up being the same, leading to bad generated
code (only the first component was accessed via fir.field_index, leading
to bad generated code).

This patch handles the situation by adding the derived type mangled name
to private component.
2023-09-18 14:59:56 +02:00
Yusuke MINATO
4eafb5f57c
[flang][hlfir] Add hlfir.minval intrinsic (#66306)
Adds a new HLFIR operation for the MINVAL intrinsic according to the
design set out in flang/docs/HighLevelFIR.md.
2023-09-15 18:30:06 +09:00
Slava Zakharin
b7d02d7e12
[flang] Select proper library APIs for derived type io. (#66327)
This patch syncs the logic inside `getInputFunc` that selects
the library API and the logic in `createIoRuntimeCallForItem`
that creates the input arguments for the library call.
There were cases where we selected `InputDerivedType` API
and passed only two arguments, and also we selected `InputDescriptor`
and passed three arguments.
It turns out we also were incorrectly selecting `OutputDescriptor`
in `getOutputFunc` (`test4` case in the new LIT test),
which caused runtime issues for output of a derived type
with descriptor components (due to the missing non-type-bound table).
2023-09-14 07:58:26 -07:00
Slava Zakharin
8730fe95d8
[flang] Do not finalize main program variables. (#66326) 2023-09-14 07:58:01 -07:00
Sergio Afonso
29aa749087
[OpenMP][Flang][MLIR] Lowering of OpenMP requires directive from parse tree to MLIR
This patch implements the lowering of the OpenMP 'requires' directive
from Flang parse tree to MLIR attributes attached to the top-level
module.

Target-related 'requires' clauses are gathered and combined for each top-level
unit during semantics. Lastly, a single module-level `omp.requires` attribute
is attached to the MLIR module with that information at the end of the process.

The `atomic_default_mem_order` clause is not addressed by this patch, but
rather it will come as a separate patch and follow a different approach.

Depends on D147214, D150328, D150329 and D157983.

Differential Revision: https://reviews.llvm.org/D147218
2023-09-14 10:34:54 +01:00
Valentin Clement (バレンタイン クレメン)
b171849afe
[flang][openacc] Use OpenACC terminator instead of fir.unreachable after Stop stmt (#66325)
This follow an update made on OpenMP https://reviews.llvm.org/D129969
and was not possible on OpenACC until the unstructured construct was
supported.
2023-09-13 22:28:02 -07:00
Valentin Clement (バレンタイン クレメン)
16cf9c9af0
[flang][openacc] Support labeled DO loop after acc combined directive (#66296)
This patch adds support for labeled do loop after combined directive. It
relaxes the initial parser and canonicalize labeled do loop into the
OpenACCCombinedConstruct.
2023-09-13 20:50:42 -07:00
Valentin Clement (バレンタイン クレメン)
bc32346082
[flang][openacc] Support labeled DO loop after acc loop directive (#66294)
Make the `DoConstruct` in `OpenACCLoopConstruct` optional and move the
labeled do construct in in the canonicalization step.
2023-09-13 20:50:20 -07:00
Valentin Clement (バレンタイン クレメン)
b1341e2863
[flang][openacc] Fix unstructured code in OpenACC region ops (#66284)
For unstructured construct, the blocks are created in advance inside the
function body. This causes issues when the unstructured construct is
inside an OpenACC region operations. This patch adds the same fix than
OpenMP lowering and re-create the blocks inside the op region.

Initial OpenMP fix: 29f167abcf7d871d17dd3f38f361916de1a12470
2023-09-13 20:49:54 -07:00
Peter Klausler
f82ee15554
[flang] Don't check dummy vs. actual result rank for assumed-rank poi… (#66237)
…nters

When associating a function result pointer as an actual argument with a
dummy pointer that is assumed-rank, don't emit a bogus error.
2023-09-13 16:52:15 -07:00
Peter Klausler
daa5da063a
[flang] Don't blow up when combining mixed COMPLEX operations (#66235)
Expression processing applies some straightforward rewriting of mixed
complex/real and complex/integer operations to avoid having to promote
the real/integer operand to complex and then perform a complex
operation; for example, (a,b)+x becomes (a+x,b) rather than (a,b)+(x,0).
But this can blow up the expression representation when the complex
operand cannot be duplicated cheaply. So apply this technique only to
complex operands that are appropriate to duplicate.

Fixes https://github.com/llvm/llvm-project/issues/65142.
2023-09-13 16:34:23 -07:00
Peter Klausler
4fed595997
[flang] Correct semantic representation & handling of RANK(*) (#66234)
A RANK(*) case in a SELECT RANK construct selects the case of an
assumed-rank dummy argument whose effective actual argument is an
assumed-size array. In this case, the attributes of the selector are
those of a rank-1 assumed-size array, and the selector cannot be
allocatable or a pointer.

Ensure that the representation of a SELECT RANK construct's per-case
AssocEntityDetails can distinguish RANK(n), RANK(*), and RANK DEFAULT,
and clean up various code sites and tests where the distinctions matter.
2023-09-13 16:13:31 -07:00
Peter Klausler
d34f5dd07a
[flang] Accept ALLOCATED(ARRAY=assumedRank) (#66233)
The definitions of the ALLOCATED intrinsic in the intrinsics table did
not allow for an assumed-rank array.
2023-09-13 15:55:40 -07:00
Peter Klausler
8ddedbf2f8
[flang] Assume unknown target of procedure pointer assignment is a pr… (#66232)
…ocedure

When an previously unknown name appears as the target of an assignment
to a known procedure pointer, create an external symbol for it rather
than an implicitly-typed object symbol.
2023-09-13 15:47:31 -07:00
Peter Klausler
7e013d6034
[flang] Accept intrinsic functions in DATA statement variables (#66229)
Pure intrinsic functions are acceptable in constant expressions so long
as their arguments are constant expressions. Allow them to appear in
subscripts in DATA statement variables.

Fixes https://github.com/llvm/llvm-project/issues/65046.
2023-09-13 15:02:11 -07:00
Peter Klausler
c0f5015afb
[flang] Foil attempts to put automatic objects in COMMON (#66228)
We were catching automatic objects in modules and SAVE, but not in
COMMON blocks.

Fixes https://github.com/llvm/llvm-project/issues/65003.
2023-09-13 14:33:59 -07:00
Peter Klausler
d5cc372332
[flang] Fix crash under -fdebug-dump-all (#66224)
The -fdebug-dump-all flag invokes runtime type information generation
even for a program with fatal semantic errors. This could cause a crash
on a failed CHECK(), since the type information table generator assumes
a correct program. Make it more resilient for a known fatal case. (But
if we hit many more of these, we should look into not generating the
runtime type information tables under this flag.)
2023-09-13 14:04:58 -07:00
Hao Jin
f3fdc967a8
[flang] Fix the incorrect insertion point for alloca (#65999)
While creating a temporary alloca for a box in OpenMp region, the
insertion point should be the OpenMP region block instead of the
function entry block.
2023-09-13 00:11:50 -04:00
kkwli
602e509898
[flang] Cray pointer in module (#66119)
This patch is to add the support of declaring a Cray pointer in a
module.
2023-09-12 16:51:43 -04:00
Valentin Clement (バレンタイン クレメン)
c46d732fd7
[flang][openacc] Check atomic update lhs/rhs are scalar (#66113)
Add semantic check for `!$acc atomic update`. RHS and LHS of the update
assignment must be scalar.

Without this check the code was going all the way to MLIR and trigger a
verifier error. This gives better user error message.
2023-09-12 11:00:01 -07:00
Slava Zakharin
58d50b0cad
[flang][hlfir][openacc] Updated LIT tests checks. (#66099)
This patch updates the OpenACC LIT tests to invoke HLFIR lowering
in addition to FIR lowering. The tests checks were updated accordingly.
2023-09-12 10:26:01 -07:00
Yusuke MINATO
2318bc878a
[flang][hlfir] Add hlfir.maxval intrinsic (#65705)
Adds a new HLFIR operation for the MAXVAL intrinsic according to the
design set out in flang/docs/HighLevelFIR.md.
2023-09-12 17:21:40 +09:00
jeanPerier
5b6f3fcb48
[flang] Lower BIND(C) assumed length to CFI descriptor (#65950)
Outside of BIND(C), assumed length character scalar and explicit shape
are passed by address + an extra length argument (fir.boxchar in FIR).

The standard mandates that they be passed via CFI descriptor in BIND(C)
interface (fir.box in FIR). This patch fix the handling for this case.
2023-09-12 09:38:03 +02:00
Daniil Dudkin
8a6e54c9b3
[mlir][arith] Rename operations: maxfmaximumf, minfminimumf (#65800)
This patch is part of a larger initiative aimed at fixing floating-point `max` and `min` operations in MLIR: https://discourse.llvm.org/t/rfc-fix-floating-point-max-and-min-operations-in-mlir/72671.

This commit addresses Task 1.2 of the mentioned RFC. By renaming these operations, we align their names with LLVM intrinsics that have corresponding semantics.
2023-09-11 22:02:19 -07:00
Valentin Clement (バレンタイン クレメン)
973ca4e4a2
[flang] Call finalization on empty type (#66010)
According to 7.5.6.3 point 3, finalization occurs when

> A nonpointer, nonallocatable object that is not a dummy argument or
function result is finalized immediately before it would become
undefined due to execution of a RETURN or END statement (19.6.6, item
(3)).

We were not calling the finalization on empty derived-type. There is no
such restriction so this patch updates the code so the finalization is
called for empty type as well.
2023-09-11 14:34:21 -07:00
Razvan Lupusoru
e070ea47a9
[flang][openacc] Enable lowering support for OpenACC atomic operations (#65776)
Since the OpenACC atomics specification is a subset of OpenMP atomics,
the same lowering implementation can be used. This change extracts out
the necessary pieces from the OpenMP lowering and puts them in a shared
spot. The shared spot is a header file so that each implementation can
template specialize directly.

After putting the OpenMP implementation in a common spot, the following
changes were needed to make it work for OpenACC:
* Ensure parsing works correctly by avoiding hardcoded offsets.
* Templatize based on atomic type.
* The checking whether it is OpenMP or OpenACC is done by checking for
OmpAtomicClauseList (OpenACC does not implement this so we just
templatize with void). It was preferable to check this instead of atomic
type because in some cases, like atomic capture, the read/write/update
implementations are called - and we want compile time evaluation of
these conditional parts.
* The memory order and hint are used only for OpenMP.
* Generate acc dialect operations instead of omp dialect operations.
2023-09-11 13:58:10 -07:00
Valentin Clement (バレンタイン クレメン)
8bc676c2ec
[flang][openacc] Lower acc cache directive (#65673)
The cache directive is attached directly to the acc.loop operation when
the directive appears in the loop. When it appears before a loop, the
OpenACCCacheConstruct is saved and attached when the acc.loop is
created.

Directive that cannot be attached to a loop are silently discarded. 

Depends on #65521
2023-09-11 13:38:21 -07:00
Sergio Afonso
edc2fb0733
[Flang][OpenMP][Sema] Support propagation of REQUIRES information across program units
Re-land commit 3787fd942f3927345320cc97a479f13e44355805

This patch adds support for storing OpenMP REQUIRES information in the
semantics symbols for programs/subprograms and modules/submodules, and
populates them during directive resolution. A pass is added to name resolution
that makes sure this information is also propagated across top-level programs,
functions and subprograms.

Storing REQUIRES information inside of semantics symbols will also allow
supporting the propagation of this information across Fortran modules. This
will come as a separate patch.

The `bool DirectiveAttributeVisitor::Pre(const parser::SpecificationPart &x)`
method is removed since it resulted in specification parts being visited twice.

This is patch 3/5 of a series splitting D149337 to simplify review.

Differential Revision: https://reviews.llvm.org/D157983
2023-09-11 15:01:57 +01:00
Sergio Afonso
4b9259b947
Revert "[Flang][OpenMP][Sema] Support propagation of REQUIRES information across program units"
Changes in this commit make some gfortran tests crash the compiler. It is
likely trying to dereference undefined symbol pointers.

This reverts commit 3787fd942f3927345320cc97a479f13e44355805.
2023-09-11 13:01:29 +01:00
jeanPerier
8b13775d6a
[flang] Improve length information in character transformational (#65771)
Intrinsic resolution currently does not resolve constant length
information for character transformational (with "sameChar") where the
argument has constant length but is not a variable or a constant
expression.

It is not required to fold those expressions (only inquiry on constant
expression or variable with constant length is required to be a constant
expression).

But constant length information for character is valuable for lowering,
so I think this is a nice and easy to have.
2023-09-11 12:52:11 +02:00
Sergio Afonso
3787fd942f
[Flang][OpenMP][Sema] Support propagation of REQUIRES information across program units
This patch adds support for storing OpenMP REQUIRES information in the
semantics symbols for programs/subprograms and modules/submodules, and
populates them during directive resolution. A pass is added to name resolution
that makes sure this information is also propagated across top-level programs,
functions and subprograms.

Storing REQUIRES information inside of semantics symbols will also allow
supporting the propagation of this information across Fortran modules. This
will come as a separate patch.

The `bool DirectiveAttributeVisitor::Pre(const parser::SpecificationPart &x)`
method is removed since it resulted in specification parts being visited twice.

This is patch 3/5 of a series splitting D149337 to simplify review.

Differential Revision: https://reviews.llvm.org/D157983
2023-09-11 11:48:07 +01:00
Kiran Chandramohan
0677a9d559
[Flang][OpenMP] Minor changes in reduction to work with HLFIR (#65775)
Changes are to work correctly in the presence of hlfir.declare, and
hlfir.assign (instead of fir.store).
2023-09-11 10:30:01 +01:00
Valentin Clement (バレンタイン クレメン)
db20592ffe
[flang][openacc] Add check for acc cache directive (#65807)
OpenACC 3.3 - 2.10 The cache directive may appear at the top of (inside
of) a loop.

This patch adds a semantic check to ensure the cache directive is inside
a loop.
2023-09-08 14:50:47 -07:00
Ethan Luis McDonough
9ac5b1f1b2
[flang][openmp] Semantic check for OpenMPExecutableAllocate
Executable allocate directives require that list items show up in the corresponding allocate statement.  This patch is dependent on revision D150428 and applies the semantic check introduced there to allocate directives associated with allocate statements.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D150483
2023-09-08 13:03:04 -05:00
Slava Zakharin
39b6c82c5d
[flang][hlfir] Better recognize non-overlapping array sections. (#65707)
This is a copy of the corresponding ArrayValueCopy analysis
for non-overlapping array slices. It is required to achieve
the same performance for Polyhedron/nf, though, additional
changes are needed in the alias analysis for disambiguating
host associated accesses.
2023-09-08 09:01:37 -07:00
Slava Zakharin
7beb65ae2d
[flang] Fixed LoopVersioning for array slices. (#65703)
The first test case added in the LIT test demonstrates the problem.
Even though we did not consider the inner loop as a candidate for
the transformation due to the array_coor with a slice, we decided to
version the outer loop for the same function argument.
During the cloning of the outer loop we dropped the slicing completely
producing invalid code.

I restructured the code so that we record all arg uses that cannot be
transformed (regardless of the reason), and then fixup the usage
information across the loop nests. I also noticed that we may generate
redundant contiguity checks for the inner loops, so I fixed it
since it was easy with the new way of keeping the usage data.
2023-09-08 09:01:10 -07:00
jeanPerier
6ffea74f7c
[flang] Use BIND name, if any, when consolidating common blocks (#65613)
This patch changes how common blocks are aggregated and named in
lowering in order to:

* fix one obvious issue where BIND(C) and non BIND(C) with the same
Fortran name were "merged"

* go further and deal with a derivative where the BIND(C) C name matches
the assembly name of a Fortran common block. This is a bit unspecified
IMHO, but gfortran, ifort, and nvfortran "merge" the common block
without complaints as a linker would have done. This required getting
rid of all the common block mangling early in FIR (\_QC) instead of
leaving that to the phase that emits LLVM from FIR because BIND(C)
common blocks did not have mangled names. Care has to be taken to deal
with the underscoring option of flang-new.

See added flang/test/Lower/HLFIR/common-block-bindc-conflicts.f90 for an
illustration.
2023-09-08 10:43:55 +02:00
Raghu Maddhipatla
6d1c183c6f [Flang] [OpenMP] [Semantics] Add missing semantic check for MAP clause.
Added support for following semantic check for MAP clause.
  - A list item cannot appear in both a map clause and a data-sharing attribute clause on the same target construct.

Reviewed By: NimishMishra

Differential Revision: https://reviews.llvm.org/D158807
2023-09-07 15:42:25 -05:00
Slava Zakharin
f8843efbb2
[flang][hlfir] Lower Cray pointee references. (#65563)
A Cray pointee reference must be done using the characteristics
(bounds, type params) of the original pointee declaration, but
using the actual address value of the associated Cray pointer.
There might be multiple Cray pointees associated with the same
Cray pointer.

The proposed solution is to lower each Cray pointee into a POINTER
variable with a descriptor. The descriptor is initialized at the point
of declaration of the pointee, though its base_addr is set to null.
Before each reference of the Cray pointee its descriptor's base_addr
is updated to the current value of the Cray pointer.

The update of the base_addr is done using PointerAssociateScalar
runtime call, which just updates the base_addr of the descriptor.
This is a temporary solution just to make Cray pointers work
to the same extent they work with FIR lowering.
2023-09-07 11:41:22 -07:00
kiranchandramohan
99789344d3
[Flang][OpenMP] Seek over an HLFIR declare to check for threadprivate (#65507)
To check whether we have already generated a threadprivate operation, we
have to seek over the HLFIR declare in the HLFIR flow.
2023-09-07 12:15:47 +01:00
Tom Eccles
43d729dda4 [flang][HLFIR] add more memory effects interfaces
Anything that produces a hlfir.expr should have an allocation side
effect so that it is not removed by CSE (which would result in two
hlfir.destroy operations for the same expression). Similarly for
hlfir.associate, which has hlfir.end_associate.

Also adds read effects on arguments which are pointer-like or boxes.

I see no regressions from this change when running llvm-testsuite with
optimization enabled, or from SPEC2017 rate benchmarks.

To test this, I have added MLIR's pass for testing side effect
interfaces to fir-opt.

Differential Revision: https://reviews.llvm.org/D158662
2023-09-06 10:29:57 +00:00
jeanPerier
d26c78b2ad
[flang] handle indirect module variable use in internal procedure (#65324)
When a module variable is referenced inside an internal procedure, but
the use statement for the module is inside the host, semantics may not
create any symbols with HostAssocDetails directly under the internal
procedure scope.
So pft::getScopeVariableList, that is called in the bridge when lowering
the internal procedure scope, failed to instantiate the module
variables. This lead to "symbol is not mapped to any IR value" compile
time errors.

This patch fixes the issue by adding the variables to the list of
"captured" global variables from the host program, so that they are
instantiated as part of the `internalProcedureBindings` in the bridge.

The rational of doing it that way instead of changing
`getScopeVariableList` is that `getScopeVariableList` would have to
import all the module variables used inside the host since it cannot
know which ones are referenced inside the internal procedure from the
semantics::Scope information. The fix in this patch only instantiates
the module variables from the host that are actually referenced inside
the internal procedure.
2023-09-06 09:07:45 +02:00
Slava Zakharin
de8939ffca
[flang] Reset lbounds for allocatable function results. (#65286)
With HLFIR the lbounds for the ALLOCATABLE result are taken from the
mutable box created for the result, so the non-default lbounds might be
propagated further causing incorrect result, e.g.:
```
program p
  real, allocatable :: p5(:)
  allocate(p5, source=real_init())
  print *, lbound(p5, 1) ! must print 1, but prints 7
contains
  function real_init()
    real, allocatable :: real_init(:)
    allocate(real_init(7:8))
  end function real_init
end program p
```

With FIR lowering the box passed for `source` has explicit lower bound 1
at the call site, but the runtime box initialized by `real_init` call
still has lower bound 7. I am not sure if the runtime box initialized by
`real_init` will ever be accessed in a debugger via Fortran variable
names, but I think that having the right runtime bounds that can be
accessible via examining registers/stack might be good in general. So I
decided to update the runtime bounds at the point of return.

This change fixes the test above for HLFIR.

Reviewed By: jeanPerier

Differential Revision: https://reviews.llvm.org/D156187
2023-09-05 10:26:16 -07:00
Slava Zakharin
09361b1974 [flang][hlfir] Allow expanding realloc assignments with scalar RHS.
F18 10.2.1.3 p. 3 states:
If the variable is an unallocated allocatable array, expr shall have the same rank.

So if LHS is an array and RHS is a scalar, then LHS must be allocated and
the assignment is performed according to F18 10.2.1.3 p. 5:
If expr is a scalar and the variable is an array,
the expr is treated as if it were an array of the same shape as the
variable with every element of the array equal to the scalar value of expr.

This resolves performance regression in CPU2006/437.leslie3d caused
by extra Assign runtime calls for ALLOCATABLE local arrays.
Note that the extra calls do not add overhead themselves.
The problem is that the descriptor for ALLOCATABLE is passed
to Assign runtime function, and this messes up the points-to
analysis.

Example:
```
      ALLOCATABLE DUDX(:),DUDY(:),DUDZ(:)
...
      ALLOCATE( QS(IMAX-1),FSK(IMAX-1,0:KMAX,ND),
     >      QDIFFZ(IMAX-1), RMU(IMAX-1), EKCOEF(IMAX-1),
     >      DUDX(IMAX-1),DUDY(IMAX-1),DUDZ(IMAX-1),
...
      DUDZ=0D0
...
               DO I = I1, I2
                  DUDZ(I) =
     >                  DZI * ABD * ((U(I,J,KBD) - U(I,J,KCD)) +
     >                       8.0D0 * (U(I,J, KK) - U(I,J,KBD))) * R6I
```

When we are not lowering `DUDZ=0D0` to Assign call, the `base_addr` of
`DUDZ`'s descriptor is a result of `malloc`, and LLVM is able to figure out
that the accesses through this `base_addr` cannot overlap with accesses of,
for exmaple, module (global) variable DZI. This enables CSE and LICM
for the loop, eventually, resulting in clean vectorization.

When `DUDZ`'s descriptor "escapes" to Assign runtime function,
there are no guarantees about where `base_addr` can point to.
I do not think this can be resolved by using any existing LLVM function/argument
attributes. Maybe we will be able to communicate the no-aliasing information
to LLVM using `Full Restrict Support` representation.

For the purpose of enabling HLFIR by default, I am just aligning the IR
with what we have with FIR lowering.

Reviewed By: tblah

Differential Revision: https://reviews.llvm.org/D159391
2023-09-04 14:55:09 -07:00