[all-commits] [llvm/llvm-project] 2bbf94: [flang][hlfir] Reset lower bounds to one when buff...
khaki3 via All-commits
all-commits at lists.llvm.org
Tue Jun 9 08:56:50 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2bbf94d210f73d2e1fd52a4179cd89834198675d
https://github.com/llvm/llvm-project/commit/2bbf94d210f73d2e1fd52a4179cd89834198675d
Author: khaki3 <47756807+khaki3 at users.noreply.github.com>
Date: 2026-06-09 (Tue, 09 Jun 2026)
Changed paths:
M flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
M flang/test/HLFIR/assign-bufferize.fir
M flang/test/HLFIR/associate-codegen.fir
M flang/test/HLFIR/bufferize01.fir
M flang/test/HLFIR/extents-of-shape-of.f90
M flang/test/HLFIR/mul_transpose.f90
M flang/test/HLFIR/shapeof-lowering.fir
Log Message:
-----------
[flang][hlfir] Reset lower bounds to one when bufferizing hlfir.as_expr move (#202406)
Example:
```fortran
module m
type t
integer, allocatable :: a(:)
end type
contains
function pf()
integer, allocatable :: pf(:)
allocate(pf(-5:-3)); pf = [1,2,3]
end function
end module
program p
use m
type(t) :: z
z = t(pf())
print *, lbound(z%a,1) ! must be 1
end program
```
In this code, the allocatable function result `pf()` is used in the
structure constructor `t(...)`. As an expression its lower bound is 1,
but lowering wraps the result descriptor in `hlfir.as_expr ... move`,
and bufferization forwarded that descriptor as-is — so its lower bound
`-5` leaked into the reallocated component, printing `-5`.
Fix: when bufferizing `hlfir.as_expr` with `move`, rebox a descriptor
that may carry non-default lower bounds back to lower bound 1
(descriptor only, no data copy).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list