Skip to content

SLPVectorizer: Avoid looking at uselists of constants #134578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Apr 7, 2025

This is an unproductive use of compile time

This is an unproductive use of compile time
Copy link
Contributor Author

arsenm commented Apr 7, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Apr 7, 2025

@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-llvm-transforms

Author: Matt Arsenault (arsenm)

Changes

This is an unproductive use of compile time


Full diff: https://github.com/llvm/llvm-project/pull/134578.diff

1 Files Affected:

  • (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (+3-3)
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 31c684e16f051..94c0289807245 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -6273,7 +6273,7 @@ BoUpSLP::getReorderingData(const TreeEntry &TE, bool TopToBottom,
 
     SmallVector<Instruction *> UserBVHead(TE.Scalars.size());
     for (auto [I, V] : zip(UserBVHead, TE.Scalars)) {
-      if (!V->hasNUsesOrMore(1))
+      if (isa<Constant>(V) || !V->hasNUsesOrMore(1))
         continue;
       auto *II = dyn_cast<InsertElementInst>(*V->user_begin());
       if (!II)
@@ -13433,7 +13433,7 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
        allSameBlock(VectorizableTree.front()->Scalars));
   if (any_of(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {
         return TE->isGather() && all_of(TE->Scalars, [&](Value *V) {
-                 return isa<ExtractElementInst, UndefValue>(V) ||
+                 return isa<ExtractElementInst, Constant>(V) ||
                         (IsAllowedSingleBVNode &&
                          !V->hasNUsesOrMore(UsesLimit) &&
                          any_of(V->users(), IsaPred<InsertElementInst>));
@@ -19459,7 +19459,7 @@ bool BoUpSLP::collectValuesToDemote(
     return FinalAnalysis();
 
   if (any_of(E.Scalars, [&](Value *V) {
-        return !all_of(V->users(), [=](User *U) {
+        return !isa<Constant>(V) && !all_of(V->users(), [=](User *U) {
           return isVectorized(U) ||
                  (E.Idx == 0 && UserIgnoreList &&
                   UserIgnoreList->contains(U)) ||

@arsenm arsenm merged commit 65c7ea7 into main Apr 7, 2025
17 checks passed
@arsenm arsenm deleted the users/arsenm/slp-vectorizer-avoid-looking-at-constant-uselists branch April 7, 2025 09:52
@alexfh
Copy link
Contributor

alexfh commented Apr 12, 2025

We're seeing Clang crashes after this commit. The same setup didn't cause any problems before, and I verified that this only started happening after 65c7ea7.

The crash is happening in very specific circumstances, which are not trivial to reproduce and reason about, so I fully realize that the problem may be elsewhere, and this commit is just a trigger.

The way I can consistently reproduce the crash is:

  1. bootstrap clang in plain opt mode (-O3)
  2. build instrumented clang (-fprofile-generate=...)
  3. using instrumented clang, run a number compilations of representative code samples with a few sets of options each
  4. merge the resulting profiles
  5. build clang with the resulting profile (-fprofile-use=...) and context-sensitive profile instrumentation (-fcs-profile-generate=...)
  6. and this CSFDO-instrumented clang crashes on some piece of the code (the same IR doesn't cause crashes for other clang builds)

So far I figured out that changing the set of inputs used in step 3 can make the crash disappear. -fno-slp-vectorize also explainably makes the crash disappear.

The crash stack trace looks like this:

1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,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-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>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;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 "bcm.cc"
4.      Running pass "slp-vectorizer" on function "_ZL8keccak_fPm"
 #0 0x0000557db1db479b llvm::sys::CleanupOnSignal(unsigned long)
 #1 0x0000557db1d8daca (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long)
 #2 0x0000557db1d8dce1 CrashRecoverySignalHandler(int) (.llvm.1583429734693567393)
 #3 0x00007f6df9192e80 __restore_rt (/usr/grte/v5/lib64/libpthread.so.0+0x14e80)
 #4 0x0000557dad590315 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::$_0::operator()(std::__u::map<int, unsigned int, std::__u::less<int>, std::__u::allocator<std::__u::pair<int const, unsigned int>>> const&) const (.cold)
 #5 0x0000557dac3c4185 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)
 #6 0x0000557dac5e6129 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*)
 #7 0x0000557dabb87d05 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
 #8 0x0000557dabb87a59 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
 #9 0x0000557dac668e9b llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
#10 0x0000557dac65a0fc llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)
#11 0x0000557dabe44b19 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)
#12 0x0000557dabd48eb5 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)
#13 0x0000557dadf94c7d (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream>>&, std::__u::unique_ptr<llvm::ToolOutputFile, std::__u::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*)
#14 0x0000557daca5f557 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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>>, clang::BackendConsumer*) (.cold)
#15 0x0000557dadd13b70 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
#16 0x0000557dae9a2e9a clang::ParseAST(clang::Sema&, bool, bool)
#17 0x0000557dabddc381 clang::FrontendAction::Execute()
#18 0x0000557dabddc1a5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
#19 0x0000557dabdd4c8e clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
#20 0x0000557dabdd609b cc1_main(llvm::ArrayRef<char const*>, char const*, void*)
#21 0x0000557dabdd5045 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (.llvm.5713672688515963801)
#22 0x0000557dabe49405 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) (.llvm.12200153564871006636)
#23 0x0000557dabde9e99 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>)
#24 0x0000557dabde9d3e 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
#25 0x0000557dabc97391 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const
#26 0x0000557dabc97137 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__u::pair<int, clang::driver::Command const*>>&)
#27 0x0000557dac4b1752 clang_main(int, char**, llvm::ToolContext const&)
#28 0x0000557dabc91c9f main

@alexfh
Copy link
Contributor

alexfh commented Apr 12, 2025

After a bit more investigation I found out that the only thing this commit affects is the instrumented profile, which then leads to the crash even when compiling clang from sources before this commit. So the problem is in the SLP vectorizer, but not in this change.

Looking further...

@alexfh
Copy link
Contributor

alexfh commented Apr 12, 2025

I managed to gather a line annotated stack trace:

 #0 0x0000561203aac51d llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #1 0x0000561203aac51d llvm::sys::CleanupOnSignal(unsigned long) llvm-project/llvm/lib/Support/Unix/Signals.inc:369:3
 #2 0x0000561203a8e703 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #3 0x0000561203a8e8c7 CrashRecoverySignalHandler(int) (.llvm.2568623048927594347) llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #4 0x00007fd7d4eb2e80 __restore_rt (/usr/grte/v5/lib64/libpthread.so.0+0x14e80)
 #5 0x00005612005b44f2 llvm::SmallVectorTemplateCommon<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>::begin() llvm-project/llvm/include/llvm/ADT/SmallVector.h:267:45
 #6 0x00005612005b44f2 llvm::SmallVectorTemplateCommon<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>::end() llvm-project/llvm/include/llvm/ADT/SmallVector.h:269:27
 #7 0x00005612005b44f2 llvm::SmallVectorTemplateBase<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, true>::push_back(llvm::slpvectorizer::BoUpSLP::TreeEntry const*) llvm-project/llvm/include/llvm/ADT/SmallVector.h:563:43
 #8 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:14877:15
 #9 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15201:9
#10 0x00005612005b44f2 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:16488:11
#11 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12318:12
#12 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>, llvm::InstructionCost) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:13928:25
#13 0x00005612005b44f2 llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20296:28
#14 0x00005612005b44f2 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::$_0::operator()(std::__u::map<int, unsigned int, std::__u::less<int>, std::__u::allocator<std::__u::pair<int const, unsigned int>>> const&) const (.cold) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20544:19
#15 0x00005611ffa88f06 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20769:36
#16 0x00005611ffe2b37d bool tryToVectorizeSequence<llvm::StoreInst>(llvm::SmallVectorImpl<llvm::StoreInst*>&, llvm::function_ref<bool (llvm::StoreInst*, llvm::StoreInst*)>, llvm::function_ref<bool (llvm::StoreInst*, llvm::StoreInst*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::StoreInst*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:23128:21
#17 0x00005611ffe2b37d llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:23915:16
#18 0x00005611ffe2b37d llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20199:18
#19 0x00005611ff3bda21 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20131:18

@alexey-bataev could you take a look at this?

Upd: I bisected this error to 19aec00, the follow-up fix 076318b doesn't help here.

@alexey-bataev
Copy link
Member

I managed to gather a line annotated stack trace:

 #0 0x0000561203aac51d llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #1 0x0000561203aac51d llvm::sys::CleanupOnSignal(unsigned long) llvm-project/llvm/lib/Support/Unix/Signals.inc:369:3
 #2 0x0000561203a8e703 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:73:5
 #3 0x0000561203a8e8c7 CrashRecoverySignalHandler(int) (.llvm.2568623048927594347) llvm-project/llvm/lib/Support/CrashRecoveryContext.cpp:391:1
 #4 0x00007fd7d4eb2e80 __restore_rt (/usr/grte/v5/lib64/libpthread.so.0+0x14e80)
 #5 0x00005612005b44f2 llvm::SmallVectorTemplateCommon<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>::begin() llvm-project/llvm/include/llvm/ADT/SmallVector.h:267:45
 #6 0x00005612005b44f2 llvm::SmallVectorTemplateCommon<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, void>::end() llvm-project/llvm/include/llvm/ADT/SmallVector.h:269:27
 #7 0x00005612005b44f2 llvm::SmallVectorTemplateBase<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, true>::push_back(llvm::slpvectorizer::BoUpSLP::TreeEntry const*) llvm-project/llvm/include/llvm/ADT/SmallVector.h:563:43
 #8 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::isGatherShuffledSingleRegisterEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::MutableArrayRef<int>, llvm::SmallVectorImpl<llvm::slpvectorizer::BoUpSLP::TreeEntry const*>&, unsigned int, bool) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:14877:15
 #9 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::isGatherShuffledEntry(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallVectorImpl<int>&, llvm::SmallVectorImpl<llvm::SmallVector<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, 6u>>&, unsigned int, bool) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15201:9
#10 0x00005612005b44f2 llvm::InstructionCost llvm::slpvectorizer::BoUpSLP::processBuildVector<llvm::slpvectorizer::BoUpSLP::ShuffleCostEstimator, llvm::InstructionCost, llvm::TargetTransformInfo, llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP, llvm::SmallPtrSetImpl<llvm::Value*>>(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*, llvm::TargetTransformInfo&, llvm::ArrayRef<llvm::Value*>&, llvm::slpvectorizer::BoUpSLP&, llvm::SmallPtrSetImpl<llvm::Value*>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:16488:11
#11 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:12318:12
#12 0x00005612005b44f2 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>, llvm::InstructionCost) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:13928:25
#13 0x00005612005b44f2 llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20296:28
#14 0x00005612005b44f2 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::$_0::operator()(std::__u::map<int, unsigned int, std::__u::less<int>, std::__u::allocator<std::__u::pair<int const, unsigned int>>> const&) const (.cold) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20544:19
#15 0x00005611ffa88f06 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::__u::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20769:36
#16 0x00005611ffe2b37d bool tryToVectorizeSequence<llvm::StoreInst>(llvm::SmallVectorImpl<llvm::StoreInst*>&, llvm::function_ref<bool (llvm::StoreInst*, llvm::StoreInst*)>, llvm::function_ref<bool (llvm::StoreInst*, llvm::StoreInst*)>, llvm::function_ref<bool (llvm::ArrayRef<llvm::StoreInst*>, bool)>, bool, llvm::slpvectorizer::BoUpSLP&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:23128:21
#17 0x00005611ffe2b37d llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:23915:16
#18 0x00005611ffe2b37d llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20199:18
#19 0x00005611ff3bda21 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:20131:18

@alexey-bataev could you take a look at this?

Upd: I bisected this error to 19aec00, the follow-up fix 076318b doesn't help here.

Need a reproducer, the crash occurs on push_back to SmallVector and cannot understand why without reproducer

@alexey-bataev
Copy link
Member

Currently it looks like some memory corruption problem

@alexfh
Copy link
Contributor

alexfh commented Apr 14, 2025

As I mentioned, the reproducer is tricky here. I haven't yet figured out how to build a clang that would reliably crash on the inputs I have without the specific profiles gathered from our code. I'm still working on this though.

@aeubanks
Copy link
Contributor

I'm looking at the crash, seems like a codegenprepare issue

@alexfh
Copy link
Contributor

alexfh commented May 6, 2025

To close the loop: the details of the problem are in #138208 (unrelated to SLPVectorizer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants