llvm-project
llvm-project copied to clipboard
[LoopVectorizer] Assertion `U && "Cannot dereference end iterator!"' failed
Godbolt link: https://godbolt.org/z/dhcfc4xss
opt crashes on loop-vectorize pass with aarch64 in target triple. x86_64 works well.
Removing %tmp6 = mul i32 0, 0 resolves the crash.
Crash looks like:
opt: /root/llvm-project/llvm/include/llvm/IR/Value.h:157: UseT& llvm::Value::use_iterator_impl<UseT>::operator*() const [with UseT = llvm::Use]: Assertion `U && "Cannot dereference end iterator!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>
#0 0x00005609ae722f34 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x00005609ae720694 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f413477f3c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
#3 0x00007f413424c03b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4303b)
#4 0x00007f413422b859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f413422b729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f413423d006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
#7 0x00005609ae955955 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x39f5955)
#8 0x00005609ae987ace llvm::LoopVectorizationCostModel::getReductionPatternCost(llvm::Instruction*, llvm::ElementCount, llvm::Type*, llvm::TargetTransformInfo::TargetCostKind) (.part.0) LoopVectorize.cpp:0:0
#9 0x00005609ae987c2f llvm::LoopVectorizationCostModel::getReductionPatternCost(llvm::Instruction*, llvm::ElementCount, llvm::Type*, llvm::TargetTransformInfo::TargetCostKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a27c2f)
#10 0x00005609ae99a698 llvm::LoopVectorizationCostModel::getInstructionCost(llvm::Instruction*, llvm::ElementCount, llvm::Type*&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a3a698)
#11 0x00005609ae99bbf4 llvm::LoopVectorizationCostModel::getInstructionCost(llvm::Instruction*, llvm::ElementCount) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a3bbf4)
#12 0x00005609ae99c327 llvm::LoopVectorizationCostModel::expectedCost(llvm::ElementCount, llvm::SmallVectorImpl<std::pair<llvm::Instruction*, llvm::ElementCount>>*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a3c327)
#13 0x00005609ae99eaa6 llvm::LoopVectorizationCostModel::selectVectorizationFactor(llvm::SmallSet<llvm::ElementCount, 16u, llvm::ElementCountComparator> const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a3eaa6)
#14 0x00005609ae9ad0c9 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a4d0c9)
#15 0x00005609ae9afded llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a4fded)
#16 0x00005609ae9b26d0 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo&, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AAResults&, llvm::AssumptionCache&, std::function<llvm::LoopAccessInfo const& (llvm::Loop&)>&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a526d0)
#17 0x00005609ae9b2f97 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3a52f97)
#18 0x00005609aea8cb06 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3b2cb06)
#19 0x00005609ade3ff9a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2edff9a)
#20 0x00005609abfcbbd6 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>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x106bbd6)
#21 0x00005609ade3ead6 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2edead6)
#22 0x00005609abfcc5d6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x106c5d6)
#23 0x00005609ade3caff llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2edcaff)
#24 0x00005609abbad168 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xc4d168)
#25 0x00005609abae9ab9 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xb89ab9)
#26 0x00007f413422d0b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#27 0x00005609abba025e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xc4025e)
Compiler returned: 139
This patch makes some simple fix https://reviews.llvm.org/D136227
https://github.com/llvm/llvm-project/commit/d1cee3539fdf766e544fa783e7db1cd9ec8de801