Skip to content

Crash in Loop Strength Reduction pass when trying to PGO zsh #87225

@ms178

Description

@ms178

I've seen the following crash in the Loop Strength Reduction pass when trying to build zsh 5.9 with the following PKGBUILD.
PKGBUILD.txt

clang version 19.0.0git (https://github.com/llvm/llvm-project.git 6aa5388)

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/marcus/llvm19/bin/ld.lld --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -export-dynamic -pie -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o zsh /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib64/Scrt1.o /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/crtbeginS.o -L/home/marcus/llvm19/bin/../lib/x86_64-pc-linux-gnu -L/home/marcus/llvm19/lib/clang/19/lib/x86_64-pc-linux-gnu -L/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1 -L/usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/lib -L/usr/lib -plugin-opt=mcpu=haswell --lto-CGO3 --gc-sections --icf=all --lto-O3 -O3 -Bsymbolic-functions --as-needed -mllvm -extra-vectorizer-passes -mllvm -enable-cond-stores-vec -mllvm -slp-vectorize-hor-store -mllvm -enable-loopinterchange -mllvm -enable-loop-distribute -mllvm -enable-unroll-and-jam -mllvm -enable-loop-flatten -mllvm -unroll-runtime-multi-exit -mllvm -aggressive-ext-opt -mllvm -enable-interleaved-mem-accesses -mllvm -enable-masked-interleaved-mem-accesses -zmax-page-size=0x200000 -mllvm -adce-remove-loops -mllvm -enable-ext-tsp-block-placement -mllvm -enable-gvn-hoist -mllvm -enable-dfa-jump-thread --push-state -whole-archive -ljemalloc_pic --pop-state -lpthread -lstdc++ -lm -ldl -z now -z relro -z pack-relative-relocs --hash-style=gnu --undefined-version main.o builtin.o compat.o cond.o context.o exec.o glob.o hashtable.o hashnameddir.o hist.o init.o input.o jobs.o lex.o linklist.o loop.o math.o mem.o module.o options.o params.o parse.o pattern.o prompt.o signals.o signames.o sort.o string.o subst.o text.o utils.o openssh_bsd_setres_id.o Builtins/rlimits.o Builtins/sched.o Modules/datetime.o Modules/langinfo.o Modules/parameter.o Modules/termcap.o Modules/terminfo.o Modules/zutil.o Zle/compctl.o Zle/complete.o Zle/compcore.o Zle/compmatch.o Zle/compresult.o Zle/complist.o Zle/computil.o Zle/zle_bindings.o Zle/zle_hist.o Zle/zle_keymap.o Zle/zle_main.o Zle/zle_misc.o Zle/zle_move.o Zle/zle_params.o Zle/zle_refresh.o Zle/zle_thingy.o Zle/zle_tricky.o Zle/zle_utils.o Zle/zle_vi.o Zle/zle_word.o Zle/textobjects.o Zle/zleparameter.o -lgdbm -lpcre -lcap -ldl -lncursesw -lncursesw -lrt -lm -lgcov -lc -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/crtendS.o /usr/lib64/gcc/x86_64-pc-linux-gnu/13.2.1/../../../../lib64/crtn.o
1.      Running pass 'Function Pass Manager' on module 'ld-temp.o'.
2.      Running pass 'Loop Pass Manager' on function '@spname'
3.      Running pass 'Loop Strength Reduction' on basic block '%146'
 #0 0x0000564884a0fdb9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/marcus/llvm19/bin/ld.lld+0x660fdb9)
 #1 0x0000564884a101d5 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f96ed696830 (/usr/lib/libc.so.6+0x296830)
 #3 0x00005648841cc1b3 canCreateUndefOrPoison(llvm::Operator const*, UndefPoisonKind, bool) (.llvm.16588075821092707243.cold) ValueTracking.cpp:0:0
 #4 0x0000564883b83520 isGuaranteedNotToBeUndefOrPoison(llvm::Value const*, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int, UndefPoisonKind) (.llvm.16588075821092707243) ValueTracking.cpp:0:0
 #5 0x0000564883b83740 isGuaranteedNotToBeUndefOrPoison(llvm::Value const*, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int, UndefPoisonKind) (.llvm.16588075821092707243) ValueTracking.cpp:0:0
 #6 0x0000564883b83740 isGuaranteedNotToBeUndefOrPoison(llvm::Value const*, llvm::AssumptionCache*, llvm::Instruction const*, llvm::DominatorTree const*, unsigned int, UndefPoisonKind) (.llvm.16588075821092707243) ValueTracking.cpp:0:0
 #7 0x0000564883dcfd20 llvm::ScalarEvolution::canReuseInstruction(llvm::SCEV const*, llvm::Instruction*, llvm::SmallVectorImpl<llvm::Instruction*>&) (/home/marcus/llvm19/bin/ld.lld+0x59cfd20)
 #8 0x0000564884510fe2 llvm::SCEVExpander::FindValueInExprValueMap(llvm::SCEV const*, llvm::Instruction const*, llvm::SmallVectorImpl<llvm::Instruction*>&) (/home/marcus/llvm19/bin/ld.lld+0x6110fe2)
 #9 0x0000564884303285 llvm::SCEVExpander::expand(llvm::SCEV const*) (.cold) DLangDemangle.cpp:0:0
#10 0x0000564884303f2f llvm::SCEVExpander::expand(llvm::SCEV const*) (.cold) DLangDemangle.cpp:0:0
#11 0x000056488451517f (anonymous namespace)::LSRInstance::Expand((anonymous namespace)::LSRUse const&, (anonymous namespace)::LSRFixup const&, (anonymous namespace)::Formula const&, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void, true>, false, false>, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) const LoopStrengthReduce.cpp:0:0
#12 0x000056488451699f (anonymous namespace)::LSRInstance::ImplementSolution(llvm::SmallVectorImpl<(anonymous namespace)::Formula const*> const&) LoopStrengthReduce.cpp:0:0
#13 0x000056488466bf61 (anonymous namespace)::LSRInstance::LSRInstance(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSAUpdater*) LoopStrengthReduce.cpp:0:0
#14 0x00005648846c7bc4 ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0
#15 0x00005648846c792e (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) (.8695a2139a255b5990ba0c3e8c89610f) LoopStrengthReduce.cpp:0:0
#16 0x00005648846bdcaa llvm::LPPassManager::runOnFunction(llvm::Function&) (/home/marcus/llvm19/bin/ld.lld+0x62bdcaa)
#17 0x00005648846bf1d3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/marcus/llvm19/bin/ld.lld+0x62bf1d3)
#18 0x00005648846be3ff llvm::FPPassManager::runOnModule(llvm::Module&) (/home/marcus/llvm19/bin/ld.lld+0x62be3ff)
#19 0x00005648846bbb22 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/marcus/llvm19/bin/ld.lld+0x62bbb22)
#20 0x000056488488b491 codegen(llvm::lto::Config const&, llvm::TargetMachine*, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) LTOBackend.cpp:0:0
#21 0x00005648859844f2 llvm::lto::backend(llvm::lto::Config const&, std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex&) (/home/marcus/llvm19/bin/ld.lld+0x75844f2)
#22 0x00005648848940fa llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>) (/home/marcus/llvm19/bin/ld.lld+0x64940fa)
#23 0x00005648848939ed llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream>>> (unsigned int, llvm::Twine const&)>> (unsigned int, llvm::StringRef, llvm::Twine const&)>) (/home/marcus/llvm19/bin/ld.lld+0x64939ed)
#24 0x0000564884bf2bd3 lld::elf::BitcodeCompiler::compile() (/home/marcus/llvm19/bin/ld.lld+0x67f2bd3)
#25 0x0000564884b3dc52 void lld::elf::LinkerDriver::link<llvm::object::ELFType<(llvm::endianness)1, true>>(llvm::opt::InputArgList&) Driver.cpp:0:0
#26 0x0000564884b1df1e lld::elf::LinkerDriver::linkerMain(llvm::ArrayRef<char const*>) (/home/marcus/llvm19/bin/ld.lld+0x671df1e)
#27 0x0000564884b1acd4 lld::elf::link(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, bool, bool) (/home/marcus/llvm19/bin/ld.lld+0x671acd4)
#28 0x0000564884a113bc lld::unsafeLldMain(llvm::ArrayRef<char const*>, llvm::raw_ostream&, llvm::raw_ostream&, llvm::ArrayRef<lld::DriverDef>, bool) (/home/marcus/llvm19/bin/ld.lld+0x66113bc)
#29 0x00005648845470b9 lld_main(int, char**, llvm::ToolContext const&) (/home/marcus/llvm19/bin/ld.lld+0x61470b9)
#30 0x0000564880be8e46 (/home/marcus/llvm19/bin/ld.lld+0x27e8e46)
#31 0x00007f96ed67cedc (/usr/lib/libc.so.6+0x27cedc)
#32 0x00007f96ed67cdec __libc_start_main (/usr/lib/libc.so.6+0x27cdec)
#33 0x0000564881105895 _start (/home/marcus/llvm19/bin/ld.lld+0x2d05895)
clang: error: unable to execute command: Segmentation fault

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]llvm:ir

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions