[flang-commits] [flang] [Flang][HLFIR] Lower PACK(array, .TRUE.) to hlfir.reshape (PR #213603)
Steve Scalpone via flang-commits
flang-commits at lists.llvm.org
Wed Aug 19 00:12:09 PDT 2026
sscalpone wrote:
@ejose02 @kiranktp I'm seeing 100s of crashes in our test suites tonight. I believe this commit may be the cause.
>From the fujitsu suite `0210/0210_0002.f90`:
```
call s1
call s2
print *,'pass'
end
subroutine s1
integer,parameter::k=2
real(k), dimension(3,3) :: c
real(k), dimension(6) :: d
real(k), dimension(9) :: e
c = reshape((/0,3,2,4,3,2,5,1,2/),(/3,3/))
d = pack(c,mask=c.ne.2)
e = pack(c,mask=.true.)
if(any(d/=(/0,3,4,3,5,1/))) print *,'err1'
if(any(e/=(/0,3,2,4,3,2,5,1,2/))) print *,'err2'
end
subroutine s2
integer,parameter::k=8
real(k), dimension(3,3) :: c
real(k), dimension(6) :: d
real(k), dimension(9) :: e
c = reshape((/0,3,2,4,3,2,5,1,2/),(/3,3/))
d = pack(c,mask=c.ne.2)
e = pack(c,mask=.true.)
if(any(d/=(/0,3,4,3,5,1/))) print *,'err1'
if(any(e/=(/0,3,2,4,3,2,5,1,2/))) print *,'err2'
end
```
```
flang 0210/0210_0002.f90
unsupported integer type
UNREACHABLE executed at flang/lib/Optimizer/Dialect/FIRType.cpp:524!
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: bin/flang-24 -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fno-color-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 -resource-dir lib/clang/24 -fintrinsic-modules-path lib/clang/24/finclude/flang/aarch64-unknown-linux-gnu -mframe-pointer=non-leaf-no-reserve -o /tmp/0210_0002-227272.o -x f95 0210/0210_0002.f90
#0 0x0000000006637738 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (bin/flang-24+0x6637738)
#1 0x00000000066349c8 llvm::sys::RunSignalHandlers() (bin/flang-24+0x66349c8)
#2 0x0000000006634b6c SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000eafba1ef5938 (linux-vdso.so.1+0x938)
#4 0x0000eafba1b27608 __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x0000eafba1adcb3c raise ./signal/../sysdeps/posix/raise.c:27:6
#6 0x0000eafba1ac7e00 abort ./stdlib/abort.c:81:7
#7 0x00000000065ad784 (bin/flang-24+0x65ad784)
#8 0x000000000a693858 fir::getTypeCode(mlir::Type, fir::KindMapping const&) (bin/flang-24+0xa693858)
#9 0x000000000a150200 EmboxCommonConversion<fir::EmboxOp>::getSizeAndTypeCode(mlir::Location, mlir::ConversionPatternRewriter&, mlir::Type, mlir::ValueRange) const CodeGen.cpp:0:0
#10 0x000000000a155150 std::tuple<fir::BaseBoxType, mlir::Value, mlir::Value> EmboxCommonConversion<fir::EmboxOp>::consDescriptorPrefix<fir::EmboxOp>(fir::EmboxOp, mlir::Type, mlir::ConversionPatternRewriter&, unsigned int, mlir::ValueRange, mlir::ValueRange, mlir::Value, mlir::Type) const CodeGen.cpp:0:0
#11 0x000000000a177ed0 EmboxOpConversion::matchAndRewrite(fir::EmboxOp, fir::EmboxOpAdaptor, mlir::ConversionPatternRewriter&) const CodeGen.cpp:0:0
#12 0x000000000a164bb0 llvm::LogicalResult mlir::ConversionPattern::dispatchTo1To1<fir::FIROpConversion<fir::EmboxOp>, fir::EmboxOp>(fir::FIROpConversion<fir::EmboxOp> const&, fir::EmboxOp, fir::EmboxOp::GenericAdaptor<llvm::ArrayRef<mlir::ValueRange>>, mlir::ConversionPatternRewriter&) (bin/flang-24+0xa164bb0)
#13 0x000000000a164cec fir::FIROpConversion<fir::EmboxOp>::matchAndRewrite(mlir::Operation*, llvm::ArrayRef<mlir::ValueRange>, mlir::ConversionPatternRewriter&) const CodeGen.cpp:0:0
#14 0x000000000e7f07c4 mlir::ConversionPattern::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (bin/flang-24+0xe7f07c4)
#15 0x000000000e842118 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&)>)::'lambda'()::operator()() const PatternApplicator.cpp:0:0
#16 0x000000000e84328c 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&)>) (bin/flang-24+0xe84328c)
#17 0x000000000e7ec3a4 (anonymous namespace)::OperationLegalizer::legalize(mlir::Operation*) DialectConversion.cpp:0:0
#18 0x000000000e7ec6dc mlir::OperationConverter::convert(mlir::Operation*, bool) (bin/flang-24+0xe7ec6dc)
#19 0x000000000e7f61d0 mlir::OperationConverter::applyConversion(llvm::ArrayRef<mlir::Operation*>) (bin/flang-24+0xe7f61d0)
#20 0x000000000e7f7548 applyConversion(llvm::ArrayRef<mlir::Operation*>, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig, (anonymous namespace)::OpConversionMode) DialectConversion.cpp:0:0
#21 0x000000000e7f77b4 mlir::applyFullConversion(mlir::Operation*, mlir::ConversionTarget const&, mlir::FrozenRewritePatternSet const&, mlir::ConversionConfig) (bin/flang-24+0xe7f77b4)
#22 0x000000000a15af3c (anonymous namespace)::FIRToLLVMLowering::runOnOperation() CodeGen.cpp:0:0
#23 0x000000000e95a20c void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::'lambda2'()>(long) Pass.cpp:0:0
#24 0x000000000e9540e0 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (bin/flang-24+0xe9540e0)
#25 0x000000000e954494 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (bin/flang-24+0xe954494)
#26 0x000000000e954ee4 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) (bin/flang-24+0xe954ee4)
#27 0x000000000e955c20 mlir::PassManager::run(mlir::Operation*) (bin/flang-24+0xe955c20)
#28 0x00000000066936b0 Fortran::frontend::CodeGenAction::generateLLVMIR() (bin/flang-24+0x66936b0)
#29 0x0000000006697e2c Fortran::frontend::CodeGenAction::executeAction() (bin/flang-24+0x6697e2c)
#30 0x000000000667d0a4 Fortran::frontend::FrontendAction::execute() (bin/flang-24+0x667d0a4)
#31 0x0000000006668fec Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (bin/flang-24+0x6668fec)
#32 0x0000000006686ad0 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (bin/flang-24+0x6686ad0)
#33 0x0000000005f5c29c fc1_main(llvm::ArrayRef<char const*>, char const*) (bin/flang-24+0x5f5c29c)
#34 0x0000000005f5bcb8 main (bin/flang-24+0x5f5bcb8)
#35 0x0000eafba1ac84c4 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#36 0x0000eafba1ac8598 call_init ./csu/../csu/libc-start.c:128:20
#37 0x0000eafba1ac8598 __libc_start_main ./csu/../csu/libc-start.c:347:5
#38 0x0000000005f59d4c _start (bin/flang-24+0x5f59d4c)
flang-24: error: unable to execute command: Aborted
flang-24: error: flang frontend command failed with exit code -2 (use -v to see invocation)
flang version 24.0.0git (https://github.com/llvm/llvm-project 9835f8acf3baf3b489500b3bfa42fc1b0c9d48d0)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: bin
Build config: +assertions
flang-24: note: diagnostic msg:
********************
```
https://github.com/llvm/llvm-project/pull/213603
More information about the flang-commits
mailing list