If the scalar does not need to be scheduled and it was vectorized
already in one of the vector nodes, we still can try to vectorize it in
another node. Just does not need account its cost in the scalar total
cost, as it will be handled in the main vectorized node.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Heads-up: this revision is causing a crash in the LTO compiler backend.
Here's the stack trace:
#3 0x000055b7d3018588 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x8818588) #4 0x000055b7d30184dd llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x88184dd) #5 0x000055b7d30186d2 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x88186d2) #6 0x000055b7d3017cda llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x8817cda) #7 0x000055b7d30186d2 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x88186d2) #8 0x000055b7d3017cda llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x8817cda) #9 0x000055b7d30186d2 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x88186d2) #10 0x000055b7d3017cda llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x8817cda) #11 0x000055b7d3019acd llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x8819acd) #12 0x000055b7d301d763 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::__u::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::__u::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (build/clang+0x881d763) #13 0x000055b7d301d597 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (build/clang+0x881d597) #14 0x000055b7d302bd9e llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (build/clang+0x882bd9e) #15 0x000055b7d3030735 bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (build/clang+0x8830735) #16 0x000055b7d302777f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (build/clang+0x882777f) #17 0x000055b7d3025e1d llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (build/clang+0x8825e1d) #18 0x000055b7d3025726 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x8825726) #19 0x000055b7d212edb2 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x792edb2) #20 0x000055b7d3755cf5 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x8f55cf5) #21 0x000055b7cf116812 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x4916812) #22 0x000055b7d3758029 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/clang+0x8f58029) #23 0x000055b7cf111a32 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/clang+0x4911a32) #24 0x000055b7d37551f5 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/clang+0x8f551f5) #25 0x000055b7cf5b9f5e llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::__u::vector<unsigned char, std::__u::allocator<unsigned char>> const&) (build/clang+0x4db9f5e) #26 0x000055b7cf5bc4e5 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::__u::function<llvm::Expected<std::__u::unique_ptr<llvm::CachedFileStream, std::__u::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::DenseMap<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>>> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, llvm::SmallVector<std::__u::pair<llvm::StringRef, llvm::BitcodeModule>, 0u>>*, std::__u::vector<unsigned char, std::__u::allocator<unsigned char>> const&)::$_0::operator()(llvm::Module&, llvm::TargetMachine*, std::__u::unique_ptr<llvm::ToolOutputFile, std::__u::default_delete<llvm::ToolOutputFile>>) const (build/clang+0x4dbc4e5) #27 0x000055b7cf5bc418 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::__u::function<llvm::Expected<std::__u::unique_ptr<llvm::CachedFileStream, std::__u::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::DenseMap<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>>> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned lng, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, llvm::SmallVector<std::__u::pair<llvm::StringRef, llvm::BitcodeModule>, 0u>>*, std::__u::vector<unsigned char, std::__u::allocator<unsigned char>> const&) (build/clang+0x4dbc418) #28 0x000055b7cf1070c8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream>>) (build/clang+0x49070c8) #29 0x000055b7cf103423 clang::CodeGenAction::ExecuteAction() (build/clang+0x4903423) #30 0x000055b7cfc78bba clang::FrontendAction::Execute() (build/clang+0x5478bba) #31 0x000055b7cfbebe94 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (build/clang+0x53ebe94) #32 0x000055b7cedad069 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (build/clang+0x45ad069) #33 0x000055b7ceda1705 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (build/clang+0x45a1705) #34 0x000055b7ced9f424 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (build/clang+0x459f424) #35 0x000055b7cfd7f31e void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__u::optional<llvm::StringRef>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, bool*) const::$_0>(long) (build/clang+0x557f31e) #36 0x000055b7d38b2fcf llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (build/clang+0x90b2fcf) #37 0x000055b7cfd7eabb clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__u::optional<llvm::StringRef>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, bool*) const (build/clang+0x557eabb) #38 0x000055b7cfd3e734 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (build/clang+0x553e734) #39 0x000055b7cfd3ec8f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&, bool) const (build/clang+0x553ec8f) #40 0x000055b7cfd5dff0 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&) (build/clang+0x555dff0) #41 0x000055b7ced9e891 clang_main(int, char**, llvm::ToolContext const&) (build/clang+0x459e891) #42 0x000055b7ced9b3c4 main (build/clang+0x459b3c4) #43 0x00007f29fdd91633 __libc_start_main #44 0x000055b7ced9b32a _start (build/clang+0x459b32a) clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
@ABataev : coming up with a reduced reproducer might take some time, could you please revert to green until then?
I would prefer to wait for the reproducer before to see if it easy to fix or not. If it will require some time, I will revert the patch
Hi, could you provide top most part of the crash report? I have the idea what's the cause but I need to confirm it.
Sorry I cut the first few lines! Here's the complete stack trace:
#0 0x00005593d44f0d29 llvm::sys::RunSignalHandlers() (build/clang+0x90f0d29) #1 0x00005593d44b31f6 CrashRecoverySignalHandler(int) (build/clang+0x90b31f6) #2 0x00007f4716e9f1c0 __restore_rt (libpthread.so.0+0x151c0) #3 0x00005593d3c18588 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x8818588) #4 0x00005593d3c184dd llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x88184dd) #5 0x00005593d3c186d2 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x88186d2) #6 0x00005593d3c17cda llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x8817cda) #7 0x00005593d3c186d2 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x88186d2) #8 0x00005593d3c17cda llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x8817cda) #9 0x00005593d3c186d2 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x88186d2) #10 0x00005593d3c17cda llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int) (build/clang+0x8817cda) #11 0x00005593d3c19acd llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*) (build/clang+0x8819acd) #12 0x00005593d3c1d763 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::__u::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::__u::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (build/clang+0x881d763) #13 0x00005593d3c1d597 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (build/clang+0x881d597) #14 0x00005593d3c2bd9e llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (build/clang+0x882bd9e) #15 0x00005593d3c30735 bool tryToVectorizeSequence<llvm::Value>(llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::Value*, llvm::Value*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::Value*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) (build/clang+0x8830735) #16 0x00005593d3c2777f llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (build/clang+0x882777f) #17 0x00005593d3c25e1d llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (build/clang+0x8825e1d) #18 0x00005593d3c25726 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x8825726) #19 0x00005593d2d2edb2 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x792edb2) #20 0x00005593d4355cf5 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x8f55cf5) #21 0x00005593cfd16812 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build/clang+0x4916812) #22 0x00005593d4358029 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/clang+0x8f58029) #23 0x00005593cfd11a32 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/clang+0x4911a32) #24 0x00005593d43551f5 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build/clang+0x8f551f5) #25 0x00005593d01b9f5e llvm::lto::opt(llvm::lto::Config const&, llvm::TargetMachine*, unsigned int, llvm::Module&, bool, llvm::ModuleSummaryIndex*, llvm::ModuleSummaryIndex const*, std::__u::vector<unsigned char, std::__u::allocator<unsigned char>> const&) (build/clang+0x4db9f5e) #26 0x00005593d01bc4e5 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::__u::function<llvm::Expected<std::__u::unique_ptr<llvm::CachedFileStream, std::__u::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::DenseMap<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>>> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, llvm::SmallVector<std::__u::pair<llvm::StringRef, llvm::BitcodeModule>, 0u>>*, std::__u::vector<unsigned char, std::__u::allocator<unsigned char>> const&)::$_0::operator()(llvm::Module&, llvm::TargetMachine*, std::__u::unique_ptr<llvm::ToolOutputFile, std::__u::default_delete<llvm::ToolOutputFile>>) const (build/clang+0x4dbc4e5) #27 0x00005593d01bc418 llvm::lto::thinBackend(llvm::lto::Config const&, unsigned int, std::__u::function<llvm::Expected<std::__u::unique_ptr<llvm::CachedFileStream, std::__u::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, llvm::Module&, llvm::ModuleSummaryIndex const&, llvm::DenseMap<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, std::__u::unordered_set<unsigned long, std::__u::hash<unsigned long>, std::__u::equal_to<unsigned long>, std::__u::allocator<unsigned long>>>> const&, llvm::DenseMap<unsigned long, llvm::GlobalValueSummary*, llvm::DenseMapInfo<unsigned long, void>, llvm::detail::DenseMapPair<unsigned long, llvm::GlobalValueSummary*>> const&, llvm::MapVector<llvm::StringRef, llvm::BitcodeModule, llvm::DenseMap<llvm::StringRef, unsigned int, llvm::DenseMapInfo<llvm::StringRef, void>, llvm::detail::DenseMapPair<llvm::StringRef, unsigned int>>, llvm::SmallVector<std::__u::pair<llvm::StringRef, llvm::BitcodeModule>, 0u>>*, std::__u::vector<unsigned char, std::__u::allocator<unsigned char>> const&) (build/clang+0x4dbc418) #28 0x00005593cfd070c8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream>>) (build/clang+0x49070c8) #29 0x00005593cfd03423 clang::CodeGenAction::ExecuteAction() (build/clang+0x4903423) #30 0x00005593d0878bba clang::FrontendAction::Execute() (build/clang+0x5478bba) #31 0x00005593d07ebe94 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (build/clang+0x53ebe94) #32 0x00005593cf9ad069 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (build/clang+0x45ad069) #33 0x00005593cf9a1705 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (build/clang+0x45a1705) #34 0x00005593cf99f424 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (build/clang+0x459f424) #35 0x00005593d097f31e void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__u::optional<llvm::StringRef>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, bool*) const::$_0>(long) (build/clang+0x557f31e) #36 0x00005593d44b2fcf llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (build/clang+0x90b2fcf) #37 0x00005593d097eabb clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__u::optional<llvm::StringRef>>, std::__u::basic_string<char, std::__u::char_traits<char>, std::__u::allocator<char>>*, bool*) const (build/clang+0x557eabb) #38 0x00005593d093e734 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (build/clang+0x553e734) #39 0x00005593d093ec8f clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&, bool) const (build/clang+0x553ec8f) #40 0x00005593d095dff0 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&) (build/clang+0x555dff0) #41 0x00005593cf99e891 clang_main(int, char**, llvm::ToolContext const&) (build/clang+0x459e891) #42 0x00005593cf99b3c4 main (build/clang+0x459b3c4) #43 0x00007f4716d30633 __libc_start_main #44 0x00005593cf99b32a _start (build/clang+0x459b32a) clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Is there something else above, like assertion message? It would really help more rather than the rest of the stack trace
Is there something else above, like assertion message? It would really help more rather than the rest of the stack trace
No, I've built the code with assertions enabled in the compiler and no assertion was triggered. The stack trace is all I get.
I have a patch, could you try it?
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 38ef4fa9464f..94abd8ac59da 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -2916,8 +2916,11 @@ private: const TreeEntry *TE = getTreeEntry(V); assert((!TE || TE == Last || doesNotNeedToBeScheduled(V)) && "Scalar already in tree!"); - if (TE) + if (TE) { + if (TE != Last) + MultiNodeScalar.insert(V); continue; + } ScalarToTreeEntry[V] = Last; } // Update the scheduler bundle to point to this TreeEntry. @@ -2976,6 +2979,9 @@ private: /// Maps a specific scalar to its tree entry. SmallDenseMap<Value *, TreeEntry *> ScalarToTreeEntry; + /// List of scalar, used in several vectorize nodes. + SmallDenseSet<Value *> MultiNodeScalar; + /// Maps a value to the proposed vectorizable size. SmallDenseMap<Value *, unsigned> InstrElementSize; @@ -9843,17 +9849,32 @@ Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx) { S = getSameOpcode(*It, *TLI); } if (S.getOpcode()) { - if (TreeEntry *VE = getTreeEntry(S.OpValue); - VE && VE->isSame(VL) && - (any_of(VE->UserTreeIndices, - [E, NodeIdx](const EdgeInfo &EI) { - return EI.UserTE == E && EI.EdgeIdx == NodeIdx; - }) || - any_of(VectorizableTree, - [E, NodeIdx, VE](const std::unique_ptr<TreeEntry> &TE) { - return TE->isOperandGatherNode({E, NodeIdx}) && - VE->isSame(TE->Scalars); - }))) { + auto CheckSameVE = [&](const TreeEntry *VE) { + return VE->isSame(VL) && + (any_of(VE->UserTreeIndices, + [E, NodeIdx](const EdgeInfo &EI) { + return EI.UserTE == E && EI.EdgeIdx == NodeIdx; + }) || + any_of(VectorizableTree, + [E, NodeIdx, VE](const std::unique_ptr<TreeEntry> &TE) { + return TE->isOperandGatherNode({E, NodeIdx}) && + VE->isSame(TE->Scalars); + })); + }; + TreeEntry *VE = getTreeEntry(S.OpValue); + bool IsSameVE = VE && CheckSameVE(VE); + if (!IsSameVE && MultiNodeScalar.contains(S.OpValue)) { + auto *I = + find_if(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) { + return TE->State != TreeEntry::NeedToGather && TE.get() != VE && + CheckSameVE(TE.get()); + }); + if (I != VectorizableTree.end()) { + VE = I->get(); + IsSameVE = true; + } + } + if (IsSameVE) { auto FinalShuffle = [&](Value *V, ArrayRef<int> Mask) { ShuffleInstructionBuilder ShuffleBuilder(Builder, *this); ShuffleBuilder.add(V, Mask);
I was able to prepare a reproducer for this, will fix it soon. Let me know if it fixes your issue.
Just tried the patch and it fixes our issue! Waiting unpatiantly for you to submit the fix forward!
Haven't yet got near a reproducer, do you still need it?
We found another issue where the compiler enters an infinite loop at this revision.
The infinite loop reproduces up until revision 7db87a66b0206af027724fc1704e5e5ce7772a45 where the compiler exits with error:
Instruction does not dominate all uses! %7 = shufflevector <2 x double> %6, <2 x double> poison, <2 x i32> zeroinitializer %5 = fmul <2 x double> %7, <double 0x3FD4F2094F2094F2, double 0x3FE5555555555555> in function aa fatal error: error in backend: Broken function found, compilation aborted!
There's no change at the revision fixing the previous report (ebed4692f8160e65c5a04c3edfb61b82ca037574)
Reduced repro:
int a; double b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z; void aa() { double ab, ac, ad = ab = c ? h + d : f * g; double un = 0.18e2 / 0.55e2 * ab - 0.1e2 / 0.33e2 * ab - 0.2e1 / 0.3e1 * ab; if (a) t = s; ac = v + 0.2e1 / 0.3e1 * ab * d - w - 0.2e1 / 0.3e1 * ab * 0 + x + i - y - j + e + k - e - l + e + m - e - n; ad = d + 0.18e2 / 0.55e2 * ab * o - e - 0.1e2 / 0.33e2 * ab * p + f + b - d - q + e + b - e - r + f + b - e - b; z = c ? u + ac + ad : 0; }
Compile command:
$ clang -cc1 -triple x86_64-pc-linux-gnu -S \ -fmath-errno -target-feature +sse4.2 \ -O3 -vectorize-slp -x c repro.c \ -o /tmp/out
@ABataev can you please take a look? This second issue is much more spread and causes lots of breakages for us.
Hi Alexey,
The change causes a crash for this code:
$ cat ~/test.ll target triple = "x86_64-unknown-linux-gnu" define void @f(i64 %0) { %2 = bitcast i64 0 to double %3 = bitcast i64 0 to double %4 = bitcast i64 %0 to double br label %5 5: ; preds = %1 %6 = fmul double 0.000000e+00, %4 %7 = fmul double 0.000000e+00, %3 %8 = fmul double 0.000000e+00, %2 br label %9 9: ; preds = %5 %10 = fmul double 0.000000e+00, %7 %11 = fmul double 0.000000e+00, %8 %12 = fadd double %10, 0.000000e+00 %13 = fadd double %12, %11 %14 = fadd double %13, 0.000000e+00 %15 = fadd double %14, 0.000000e+00 %16 = fmul double 0.000000e+00, %15 %17 = getelementptr double, ptr null, i64 1 store double %16, ptr %17, align 1 %18 = fmul double 0.000000e+00, %6 %19 = fadd double %18, 0.000000e+00 %20 = fmul double 0.000000e+00, %6 %21 = fsub double %19, %20 %22 = fmul double %21, 0.000000e+00 %23 = fadd double %22, 0.000000e+00 %24 = fmul double %23, 0.000000e+00 %25 = getelementptr double, ptr null, i64 2 store double %24, ptr %25, align 1 ret void } $ bin/opt ~/test.ll -passes=slp-vectorizer -S opt: /llorg/llvm/llvm/lib/IR/Value.cpp:506: void llvm::Value::doRAUW(llvm::Value*, llvm::Value::ReplaceMetadataUses): Assertion `!contains(New, this) && "this->replaceAllUsesWith(expr(this)) is NOT valid!"' failed. PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. ...
After applying later fixes the error message changes to "Instruction does not dominate all uses" but it still crashes. Could you please take a look?