Issue 203193
Summary [SLPVectorizer] Assertion `UnscheduledDeps >= 0 && "Expected valid number of unscheduled deps"' failed.
Labels llvm:SLPVectorizer, crash-on-valid, generated by fuzzer
Assignees
Reporter XChy
    Reproducer: https://godbolt.org/z/P1qTzKxPf
Testcase:
```c
#include <stdint.h>
int16_t g0, g29, g28, g23, g20, g18, g17, g15, g13, g4, g3, g1;
static int16_t g5;
_Bool g7, g24, g25;
int64_t g31;
void *f21(int16_t, int32_t, int16_t);
void f22(int16_t, int64_t);
void f17()
{
    int8_t v0;
    _Bool c2, c3, c4;
    int32_t bb5;
lbl_entry:
    bb5 = __builtin_parity(g13);
    uint32_t __ov_tmp_g13;
    __builtin_add_overflow(0, bb5, &__ov_tmp_g13);
    g13 = __ov_tmp_g13;
    if (g25) goto lbl_bf2;
    if (c4) goto lbl_b5;
    goto lbl_bf4;
lbl_bf2:
    c4 = g31;
    c2 = g3;
    g25 = 0;
    if (c2) goto lbl_br15;
    goto lbl_entry;
lbl_bf4:
    g5 = 0;
lbl_b5:
    g25 = g5 != g1;
    c3 = 0 <= 0;
lbl_bf7:
lbl_br13:
    if (c3) goto lbl_br30;
    if (g24) goto lbl_br70;
lbl_br15:
    g5 = g1;
lbl_sw22:
 if (c2) g5 = 0;
    goto lbl_br13;
lbl_br30:
    g1 = g5;
    if (c4) goto lbl_bf7;
    g5 = -g0;
    f21(0, 0, 0);
    g29 = v0;
    g3 = 80 & g5;
    v0 = g1 = g28 - 2;
    __builtin_add_overflow(g28, g28, &g5);
 c3 = 0;
lbl_br70:
    g0 = g3 + g5;
    goto lbl_sw22;
}
void *f21(int16_t, int32_t, int16_t)
{
    int64_t v3 = g20 = g4;
    f22(0, 0);
    if (g7) __builtin_unreachable();
    g28 = g13 = g0;
    g18 = g31 = v3 / g23 * g23;
}
void f22(int16_t, int64_t)
{
    g15 = g17 * 3;
 g4 = -g4 & g3;
    g17 = g18 * g18;
    g24 = 0;
}
```

Dump at -Os:
```
clang: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5234: int llvm::slpvectorizer::BoUpSLP::ScheduleData::incrementUnscheduledDeps(int): Assertion `UnscheduledDeps >= 0 && "Expected valid number of unscheduled deps"' failed.
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 -Os <source>
1.	<eof> parser at end of file
2.	Optimizer
3.	Running pass "function<eager-inv>(drop-unnecessary-assumes,float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto;check-exit-count>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,drop-unnecessary-assumes,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<O2>,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 "slp-vectorizer" on function "f17"
 #0 0x0000000004396368 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4396368)
 #1 0x00000000043931a4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43931a4)
 #2 0x00000000043937c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x43937c4)
 #3 0x00000000042cf378 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x000070ebb8645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x000070ebb869eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x000070ebb864527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x000070ebb86288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x000070ebb862881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x000070ebb863b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x00000000062177e4 auto void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const::'lambda'(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>*, bool)::operator()<llvm::slpvectorizer::BoUpSLP::ScheduleData>(llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>*, bool) const SLPVectorizer.cpp:0:0
#11 0x000000000621c8f0 void llvm::slpvectorizer::BoUpSLP::BlockScheduling::schedule<llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>>(llvm::slpvectorizer::BoUpSLP const&, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SetVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, 0u>, llvm::DenseSet<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::DenseMapInfo<llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, void>>, 0u>&)::'lambda'(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>)::operator()(llvm::slpvectorizer::BoUpSLP::ScheduleEntity*, llvm::ArrayRef<llvm::slpvectorizer::BoUpSLP::ScheduleBundle*>) const SLPVectorizer.cpp:0:0
#12 0x000000000621e4fc llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&)::'lambda8'(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&)::operator()(bool, llvm::slpvectorizer::BoUpSLP::ScheduleBundle&) const SLPVectorizer.cpp:0:0
#13 0x00000000062219fa llvm::slpvectorizer::BoUpSLP::BlockScheduling::tryScheduleBundle(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP*, (anonymous namespace)::InstructionsState const&, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) SLPVectorizer.cpp:0:0
#14 0x000000000622452d llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x622452d)
#15 0x0000000006227826 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6227826)
#16 0x0000000006226a25 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6226a25)
#17 0x0000000006226aa3 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6226aa3)
#18 0x0000000006226aa3 llvm::slpvectorizer::BoUpSLP::buildTreeRec(llvm::ArrayRef<llvm::Value*>, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6226aa3)
#19 0x000000000625bf5f llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x625bf5f)
#20 0x00000000062619b9 bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (.constprop.0) SLPVectorizer.cpp:0:0
#21 0x0000000006262a64 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6262a64)
#22 0x000000000626a1d2 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0
#23 0x000000000626adcf llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x626adcf)
#24 0x000000000576ce1e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x576ce1e)
#25 0x0000000003cd27d7 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3cd27d7)
#26 0x00000000012e419e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x12e419e)
#27 0x0000000003cd1346 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3cd1346)
#28 0x00000000012e446e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x12e446e)
#29 0x0000000003cd0977 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3cd0977)
#30 0x00000000047b6e2b (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
#31 0x00000000047ba523 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, 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+0x47ba523)
#32 0x0000000004e86817 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e86817)
#33 0x0000000006c455cc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6c455cc)
#34 0x0000000004e86c58 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4e86c58)
#35 0x00000000051bffb8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x51bffb8)
#36 0x000000000513d2bd clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x513d2bd)
#37 0x00000000052bfffd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x52bfffd)
#38 0x0000000000e22d7f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xe22d7f)
#39 0x0000000000e1973a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#40 0x0000000000e198bd 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
#41 0x0000000004ef98c9 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
#42 0x00000000042cf7b4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42cf7b4)
#43 0x0000000004ef9f16 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
#44 0x0000000004eb62e2 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4eb62e2)
#45 0x0000000004eb728e 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+0x4eb728e)
#46 0x0000000004ebf495 clang::driver::Driver::Exe<truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to