Skip to content
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

SLPVectorizer (hasOperandBundles() && "Don't call otherwise!") assertion trigger with verified module #95016

Closed
gbaraldi opened this issue Jun 10, 2024 · 0 comments · Fixed by #95937
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SLPVectorizer

Comments

@gbaraldi
Copy link
Contributor

SLPVectorize asserts while optimizing the following module

target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-ni:10:11:12:13"
target triple = "arm64-apple-darwin23.5.0"

define swiftcc void @julia_multiparameter_a_res_17823() {
top:
  %0 = call double @llvm.maximum.f64(double 0.000000e+00, double 0.000000e+00) [ "jl_roots"(ptr null) ]
  %1 = fadd double %0, 0.000000e+00
  %2 = fmul double 0.000000e+00, %1
  %3 = fmul double %2, 0.000000e+00
  %4 = select i1 false, double 0.000000e+00, double %3
  %5 = call double @llvm.maximum.f64(double 0.000000e+00, double 0.000000e+00)
  %6 = fadd double %5, 0.000000e+00
  %7 = fmul double 0.000000e+00, %6
  %8 = fmul double %7, 0.000000e+00
  %9 = select i1 false, double 0.000000e+00, double %8
  %10 = fmul double %9, 0.000000e+00
  %11 = fadd double 0.000000e+00, %10
  %12 = getelementptr { double, [1 x [2 x double]] }, ptr null, i64 0, i32 1
  store double %11, ptr %12, align 8
  %13 = fmul double %4, 0.000000e+00
  %14 = fadd double %13, 0.000000e+00
  store double %14, ptr null, align 8
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.maximum.f64(double, double) #0

; uselistorder directives
uselistorder ptr @llvm.maximum.f64, { 1, 0 }

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

This also seems to trigger on godbolt on whatever version of trunk they have there
https://godbolt.org/z/favErWG5K

stacktrace:

#0 0x0000000004e258c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e258c8)
#1 0x0000000004e2301c SignalHandler(int) Signals.cpp:0:0
#2 0x00007c7148042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007c71480969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007c7148042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007c71480287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007c714802871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007c7148039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000003ee5e8f (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3ee5e8f)
#9 0x0000000003f5e546 getSameOpcode(llvm::ArrayRefllvm::Value*, llvm::TargetLibraryInfo const&, unsigned int) (.constprop.1) SLPVectorizer.cpp:0:0
#10 0x0000000003f67928 llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getShallowScore(llvm::Value*, llvm::Value*, llvm::Instruction*, llvm::Instruction*, llvm::ArrayRefllvm::Value*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f67928)
#11 0x0000000003f67de0 llvm::slpvectorizer::BoUpSLP::LookAheadHeuristics::getScoreAtLevelRec(llvm::Value*, llvm::Value*, llvm::Instruction*, llvm::Instruction*, int, llvm::ArrayRefllvm::Value*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f67de0)
#12 0x0000000003f6aaf5 llvm::slpvectorizer::BoUpSLP::VLOperands::getBestOperand(unsigned int, int, int, llvm::ArrayRefllvm::slpvectorizer::BoUpSLP::VLOperands::ReorderingMode, llvm::ArrayRefllvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f6aaf5)
#13 0x0000000003f6bfcb llvm::slpvectorizer::BoUpSLP::VLOperands::reorder() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f6bfcb)
#14 0x0000000003f6c4f6 llvm::slpvectorizer::BoUpSLP::reorderInputsAccordingToOpcode(llvm::ArrayRefllvm::Value*, llvm::SmallVectorImplllvm::Value*&, llvm::SmallVectorImplllvm::Value*&, llvm::slpvectorizer::BoUpSLP const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f6c4f6)
#15 0x0000000003f702f4 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f702f4)
#16 0x0000000003f70392 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f70392)
#17 0x0000000003f70362 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f70362)
#18 0x0000000003f7022b llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f7022b)
#19 0x0000000003f70362 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f70362)
#20 0x0000000003f70362 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f70362)
#21 0x0000000003f6fe47 llvm::slpvectorizer::BoUpSLP::buildTree_rec(llvm::ArrayRefllvm::Value*, unsigned int, llvm::slpvectorizer::BoUpSLP::EdgeInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f6fe47)
#22 0x0000000003f71b59 llvm::slpvectorizer::BoUpSLP::buildTree(llvm::ArrayRefllvm::Value*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f71b59)
#23 0x0000000003f94622 llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRefllvm::Value*, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f94622)
#24 0x0000000003f95fb0 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRefllvm::StoreInst*, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::'lambda'(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRefllvm::StoreInst*, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&)::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRefllvm::StoreInst*, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0
#25 0x0000000003f97e88 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRefllvm::StoreInst*, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f97e88)
#26 0x0000000003f985b3 llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f985b3)
#27 0x0000000003f9970f 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
#28 0x0000000003f9a163 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f9a163)
#29 0x0000000002e1013e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManagerllvm::Function>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e1013e)
#30 0x0000000004c2e64c llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c2e64c)
#31 0x0000000000db3bce llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function>, llvm::AnalysisManagerllvm::Function>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdb3bce)
#32 0x0000000004c2cf8e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c2cf8e)
#33 0x0000000000db563e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManagerllvm::Module>::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdb563e)
#34 0x0000000004c2ae9c llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module>::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c2ae9c)
#35 0x00000000008d7b32 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRefllvm::PassPlugin, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d7b32)
#36 0x00000000008cacdc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cacdc)
#37 0x00007c7148029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x00007c7148029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x00000000008c212e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c212e)

@EugeneZelenko EugeneZelenko added llvm:SLPVectorizer crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Jun 10, 2024
alexey-bataev pushed a commit that referenced this issue Jul 2, 2024
I'm not super familiar with this code, but it seems that we were just
missing a check.

The original code that triggered this did not have uselistorders but
llvm-reduce created them and it reproduces the same issue in a way more
compact way.

Fixes #95016
giordano pushed a commit to JuliaLang/llvm-project that referenced this issue Jul 2, 2024
)

I'm not super familiar with this code, but it seems that we were just
missing a check.

The original code that triggered this did not have uselistorders but
llvm-reduce created them and it reproduces the same issue in a way more
compact way.

Fixes llvm#95016

(cherry picked from commit 380beae)
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this issue Jul 3, 2024
)

I'm not super familiar with this code, but it seems that we were just
missing a check.

The original code that triggered this did not have uselistorders but
llvm-reduce created them and it reproduces the same issue in a way more
compact way.

Fixes llvm#95016
kbluck pushed a commit to kbluck/llvm-project that referenced this issue Jul 6, 2024
)

I'm not super familiar with this code, but it seems that we were just
missing a check.

The original code that triggered this did not have uselistorders but
llvm-reduce created them and it reproduces the same issue in a way more
compact way.

Fixes llvm#95016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:SLPVectorizer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants