<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/70805>70805</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang] HLFIR forall tests trigger assertion failures on macOS
</td>
</tr>
<tr>
<th>Labels</th>
<td>
flang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
luporl
</td>
</tr>
</table>
<pre>
Both `HLFIR/forall-index.fir` and `Lower/HLFIR/forall.f90` tests cause flang-new to abort execution after an assertion failure:
`Assertion failed: (op->use_empty() && "expected 'op' to have no uses"), function eraseOp, file PatternMatch.cpp, line 307.`
Below is the output of `Lower/HLFIR/forall.f90` failure:
```
FAIL: Flang :: Lower/HLFIR/forall.f90 (1 of 1)
******************** TEST 'Flang :: Lower/HLFIR/forall.f90' FAILED ********************
Exit Code: 2
Command Output (stderr):
--
RUN: at line 2: bbc --hlfir -o - /Users/leandro.lupori/git/flang-luporl/llvm-project/flang/test/Lower/HLFIR/forall.f90 | /Users/leandro.lupori/git/flang-luporl/buildr/bin/FileCheck /Users/leandro.lupori/git/flang-luporl/llvm-project/flang/test/Lower/HLFIR/forall.f90
+ bbc --hlfir -o - /Users/leandro.lupori/git/flang-luporl/llvm-project/flang/test/Lower/HLFIR/forall.f90
+ /Users/leandro.lupori/git/flang-luporl/buildr/bin/FileCheck /Users/leandro.lupori/git/flang-luporl/llvm-project/flang/test/Lower/HLFIR/forall.f90
Assertion failed: (op->use_empty() && "expected 'op' to have no uses"), function eraseOp, file PatternMatch.cpp, line 307.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: bbc --hlfir -o - /Users/leandro.lupori/git/flang-luporl/llvm-project/flang/test/Lower/HLFIR/forall.f90
#0 0x0000000102cbba54 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101f9fa54)
#1 0x0000000102cb9bf8 llvm::sys::RunSignalHandlers() (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101f9dbf8)
#2 0x0000000102cbc104 SignalHandler(int) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101fa0104)
#3 0x0000000184439a24 (/usr/lib/system/libsystem_platform.dylib+0x180465a24)
#4 0x000000018440acc0 (/usr/lib/system/libsystem_pthread.dylib+0x180436cc0)
#5 0x000000018431aa50 (/usr/lib/system/libsystem_c.dylib+0x180346a50)
#6 0x0000000184319d6c (/usr/lib/system/libsystem_c.dylib+0x180345d6c)
#7 0x0000000102f43a6c mlir::RewriterBase::eraseBlock(mlir::Block*) (.cold.1) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x102227a6c)
#8 0x0000000102ba82c4 mlir::RewriterBase::eraseOp(mlir::Operation*) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101e8c2c4)
#9 0x0000000100fa3fb8 hlfir::ForallIndexOp::canonicalize(hlfir::ForallIndexOp, mlir::PatternRewriter&) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x100287fb8)
#10 0x0000000102a60970 void llvm::function_ref<void ()>::callback_fn<mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>)::$_2>(long) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d44970)
#11 0x0000000102a5dccc mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d41ccc)
#12 0x0000000102a2da38 (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d11a38)
#13 0x0000000102a2aa68 mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d0ea68)
#14 0x00000001029fad14 (anonymous namespace)::Canonicalizer::runOnOperation() (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101cded14)
#15 0x0000000102a872c8 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d6b2c8)
#16 0x0000000102a87928 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d6b928)
#17 0x0000000102a89958 mlir::PassManager::run(mlir::Operation*) (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x101d6d958)
#18 0x0000000100d229dc main (/Users/leandro.lupori/git/flang-luporl/buildr/bin/bbc+0x1000069dc)
#19 0x0000000184091058
FileCheck error: '<stdin>' is empty.
FileCheck command line: /Users/leandro.lupori/git/flang-luporl/buildr/bin/FileCheck /Users/leandro.lupori/git/flang-luporl/llvm-project/flang/test/Lower/HLFIR/forall.f90
--
********************
********************
Failed Tests (1):
Flang :: Lower/HLFIR/forall.f90
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWV9P6zoS_zTui9XKcf40eehDKWQvEndBwNU-Isd2Wi-OHdnOAe6nX9lJoS7nD_cAe_dIe1QdWmcy8_vNjGecCbFWbBXnK5CfgPx0Rga302Ylh14bOWs0e1qdaLeDoEC_XdTn1wDXrTZEyrlQjD8uWmFAgSBRzItc6AduAK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