| Issue |
243319
|
| Summary |
[Polly] clang aborts in polly::ZoneAlgorithm::getScalarReachingDefinition with IMPLEMENTATION ERROR: Unhandled error state
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
thapgua
|
Compiler Explorer: https://godbolt.org/z/EaWc66jKh
`clang -O3 -mllvm -polly` aborts while compiling a function that contains a value made "known" by an `__builtin_unreachable()` guard plus a set of loop nests.
Clang version:
```
clang version 24.0.0git (https://github.com/llvm/llvm-project.git 7c3a9f29c6f08a329919de7623b96633f62cc898)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /cefs/90/90fa89cc9c22eb170bb1d397_clang-assertions-trunk-20261116/bin
Build config: +assertions
```
Reproducer: `clang crash.c -O3 -mllvm -polly`
```c
// crash.c
int expected, value, seed;
int a[12][12], b[12][12], c[12][12], d[12][12], e[12][12], f[12][12];
long g[12][12], h[12][12][12];
int i[12][12][12];
int j[12], k[12], l[12], m[12], n[12], o[12], p[19];
void checksum() {
int u, v, w;
seed = value;
if (expected != value) __builtin_unreachable();
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= a[u][v];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= b[u][v];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++)
for (w = 0; w < 12; w++) seed ^= h[u][v][w] + 1;
for (u = 0; u < 12; u++) seed ^= j[u];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= g[u][v] + 1;
for (u = 0; u < 12; u++) seed ^= k[u];
for (u = 0; u < 12; u++) seed ^= l[u];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++)
for (w = 0; w < 12; w++) seed ^= i[u][v][w];
for (u = 0; u < 12; u++) seed ^= m[u] ^ n[u];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= c[u][v];
for (u = 0; u < 12; u++) seed ^= o[u];
for (u = 0; u < 19; u++) seed ^= p[u];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= d[u][v];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= e[u][v];
for (u = 0; u < 12; u++)
for (v = 0; v < 12; v++) seed ^= f[u][v];
}
```
Stacktrace:
<details>
```
Assertion "!is_error()" failed at /root/llvm-project/polly/lib/External/isl/include/isl/isl-noexceptions.h:78
IMPLEMENTATION ERROR: Unhandled error state
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -mllvm -polly <source>
1. <eof> parser at end of file
2. Optimizer
3. Running pass "function<eager-inv>(drop-unnecessary-assumes,float2int,lower-constant-intrinsics,chr,polly,sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,jump-table-to-switch,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto;no-check-exit-count>,licm<allowspeculation>,simple-loop-unswitch<nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-idiom,indvars,extra-simple-loop-unswitch-passes,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-verify-fixpoint>,dfa-jump-threading,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;no-switch-to-lookup;keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-verify-fixpoint>,loop(loop-rotate<header-duplication;no-prepare-for-lto;check-exit-count>,loop-deletion,loop-interchange),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,drop-unnecessary-assumes<drop-deref>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg;aggregate-to-vector>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,mergeicmps,expand-memcmp,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;switch-to-arithmetic;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "<source>"
4. Running pass "polly" on function "checksum"
#0 0x0000000004f67298 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f67298)
#1 0x0000000004f644f4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f644f4)
#2 0x0000000004f64b2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4f64b2c)
#3 0x0000000004e9e178 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007ec77f245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007ec77f29ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
#6 0x00007ec77f24527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007ec77f2288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00000000062357da polly::singleton(isl::union_map, isl::space) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x62357da)
#9 0x0000000006271cd2 polly::ZoneAlgorithm::getScalarReachingDefinition(polly::ScopStmt*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6271cd2)
#10 0x0000000006271f2a polly::ZoneAlgorithm::computeUseToDefFlowDependency(polly::ScopStmt*, polly::ScopStmt*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6271f2a)
#11 0x0000000006272111 polly::ZoneAlgorithm::getDefToTarget(polly::ScopStmt*, polly::ScopStmt*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6272111)
#12 0x0000000006260e9d (anonymous namespace)::ForwardOpTreeImpl::forwardKnownLoad(polly::ScopStmt*, llvm::Instruction*, polly::ScopStmt*, llvm::Loop*, polly::ScopStmt*, llvm::Loop*) ForwardOpTree.cpp:0:0
#13 0x000000000625f5fa (anonymous namespace)::ForwardOpTreeImpl::forwardTree(polly::ScopStmt*, llvm::Value*, polly::ScopStmt*, llvm::Loop*) ForwardOpTree.cpp:0:0
#14 0x000000000625f24d (anonymous namespace)::ForwardOpTreeImpl::forwardTree(polly::ScopStmt*, llvm::Value*, polly::ScopStmt*, llvm::Loop*) ForwardOpTree.cpp:0:0
#15 0x000000000625f24d (anonymous namespace)::ForwardOpTreeImpl::forwardTree(polly::ScopStmt*, llvm::Value*, polly::ScopStmt*, llvm::Loop*) ForwardOpTree.cpp:0:0
#16 0x000000000625f24d (anonymous namespace)::ForwardOpTreeImpl::forwardTree(polly::ScopStmt*, llvm::Value*, polly::ScopStmt*, llvm::Loop*) ForwardOpTree.cpp:0:0
#17 0x0000000006262e34 polly::runForwardOpTree(polly::Scop&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6262e34)
#18 0x000000000621d6b8 polly::runPollyPass(llvm::Function&, llvm::AnalysisManager<llvm::Function>&, polly::PollyPassOptions) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x621d6b8)
#19 0x000000000621de4e polly::PollyFunctionPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x621de4e)
#20 0x00000000061a1b9e llvm::detail::PassModel<llvm::Function, polly::PollyFunctionPass, llvm::AnalysisManager<llvm::Function>>::runImpl(llvm::detail::PassConcept<llvm::Function, llvm::AnalysisManager<llvm::Function>>&, llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x61a1b9e)
#21 0x000000000486b401 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x486b401)
#22 0x0000000001c94c7e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::runImpl(llvm::detail::PassConcept<llvm::Function, llvm::AnalysisManager<llvm::Function>>&, llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1c94c7e)
#23 0x000000000486999c llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x486999c)
#24 0x0000000001c94d1e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::runImpl(llvm::detail::PassConcept<llvm::Module, llvm::AnalysisManager<llvm::Module>>&, llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1c94d1e)
#25 0x000000000486918e llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x486918e)
#26 0x000000000539162a (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#27 0x0000000005394887 (anonymous namespace)::EmitAssemblyHelper::emitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#28 0x000000000539514f clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x539514f)
#29 0x0000000005a64955 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5a64955)
#30 0x00000000090371ac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x90371ac)
#31 0x0000000005a64ce8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5a64ce8)
#32 0x0000000005d8fa98 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5d8fa98)
#33 0x0000000005d1c1fd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5d1c1fd)
#34 0x0000000005e66613 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e66613)
#35 0x000000000171c3a8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x171c3a8)
#36 0x00000000017132aa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#37 0x0000000001713433 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#38 0x0000000005ade379 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#39 0x0000000004e9e574 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e9e574)
#40 0x0000000005adeee5 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#41 0x0000000005a9bd02 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5a9bd02)
#42 0x0000000005a9efbc clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5a9efbc)
#43 0x0000000005aab4b5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5aab4b5)
#44 0x00000000017189fa clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x17189fa)
#45 0x000000000169e233 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x169e233)
#46 0x00007ec77f22a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#47 0x00007ec77f22a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#48 0x0000000001712c55 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1712c55)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
</details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs