| Issue |
182436
|
| Summary |
[Flang] Compiling program with reshape function fails when using -fstack-arrays and -O1
|
| Labels |
flang
|
| Assignees |
|
| Reporter |
3776-u2
|
Using Flang version 23.0.0 on AArch64, the attached program crashes during compilation when both -fstack-arrays and -O1 are used. The compilation succeeds if either option is removed.
sample.f90
```fortran
subroutine tt(cc)
character*(*),optional,pointer::cc(:)
print *, reshape(cc,(/1/))
end subroutine tt
```
```
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang sample.f90 -fstack-arrays -O1
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0. Program arguments: /work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -fstack-arrays -resource-dir /work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/lib/clang/23 -mframe-pointer=non-leaf-no-reserve -O1 -o /tmp/sample-ac2fb7.o -x f95 sample.f90
#0 0x0000ffffa3dc11a0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libLLVM.so.23.0git+0x638a1a0)
#1 0x0000ffffa3dbe770 llvm::sys::RunSignalHandlers() (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libLLVM.so.23.0git+0x6387770)
#2 0x0000ffffa3dbe8c8 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000ffffb53f97f0 (linux-vdso.so.1+0x7f0)
#4 0x00000000073f5c14 (anonymous namespace)::AllocaOpConversion::matchAndRewrite(fir::AllocaOp, fir::AllocaOpAdaptor, mlir::ConversionPatternRewriter&) const CodeGen.cpp:0:0
#5 0x00000000073f5184 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1<fir::FIROpConversion<fir::AllocaOp>, fir::AllocaOp>(fir::FIROpConversion<fir::AllocaOp> const&, fir::AllocaOp, fir::AllocaOp::GenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x73f5184)
#6 0x00000000073f52b0 fir::FIROpConversion<fir::AllocaOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const CodeGen.cpp:0:0
#7 0x0000ffffb0430130 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x780d130)
#8 0x0000ffffb01191f0 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<llvm::LogicalResult (mlir::Pattern const&)>) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x74f61f0)
#9 0x0000ffffb042ccc0 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#10 0x0000ffffb0435058 mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x7812058)
#11 0x0000ffffb0436e7c applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#12 0x0000ffffb04370a0 mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x78140a0)
#13 0x00000000073e4ff4 (anonymous namespace)::FIRToLLVMLowering::runOnOperation() CodeGen.cpp:0:0
#14 0x0000ffffb00dd910 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x74ba910)
#15 0x0000ffffb00ddaf0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x74baaf0)
#16 0x0000ffffb00de004 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x74bb004)
#17 0x0000ffffb00dec04 mlir::PassManager::run(mlir::Operation*) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/../lib/libMLIR.so.23.0git+0x74bbc04)
#18 0x00000000063baf80 Fortran::frontend::CodeGenAction::generateLLVMIR() (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x63baf80)
#19 0x00000000063be23c Fortran::frontend::CodeGenAction::executeAction() (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x63be23c)
#20 0x00000000063a3d14 Fortran::frontend::FrontendAction::execute() (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x63a3d14)
#21 0x000000000639333c Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x639333c)
#22 0x00000000063ad134 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x63ad134)
#23 0x000000000638b9c0 fc1_main(llvm::ArrayRef<char const*>, char const*) (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x638b9c0)
#24 0x000000000638b1d0 main (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x638b1d0)
#25 0x0000ffff9d5a7540 __libc_start_call_main (/lib64/libc.so.6+0x27540)
#26 0x0000ffff9d5a7618 __libc_start_main@GLIBC_2.17 (/lib64/libc.so.6+0x27618)
#27 0x0000000006389234 _start (/work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin/flang+0x6389234)
flang-23: error: unable to execute command: Segmentation fault (core dumped)
flang-23: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 23.0.0git (https://github.com/llvm/llvm-project.git a563e6bb7ed485e0ab88717bb4a8c5e8522d9792)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /work/groups/ssoft/compiler/llvm/aarch64/main-20260209-a563e6bb7ed4/bin
Build config: +assertions
flang-23: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-23: note: diagnostic msg: /tmp/sample-440c3e
flang-23: note: diagnostic msg: /tmp/sample-440c3e.sh
flang-23: note: diagnostic msg:
********************
$
```
```
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang sample.f90 -fstack-arrays -c
$ /work/groups/ssoft/compiler/llvm/aarch64/main-latest/bin/flang sample.f90 -O1 -c
$
```
```
$ ifx --version
ifx (IFX) 2024.2.1 20240711
Copyright (C) 1985-2024 Intel Corporation. All rights reserved.
$ ifx sample.f90 -c
$
```
```
$ gfortran --version
GNU Fortran (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ gfortran sample.f90 -fstack-arrays -O1 -c
$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs