<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/87225>87225</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Crash in Loop Strength Reduction pass when trying to PGO zsh
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ms178
      </td>
    </tr>
</table>

<pre>
    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](https://github.com/llvm/llvm-project/files/14822335/PKGBUILD.txt)

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

```
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

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsOltz3CqTv0Z-oTQloZFGevCDb3O-1OdsUpkkW7UvLgQtDTECLSB7nF-_BZobM5PY4_3OeTh1UvEINd1NX6DpFhBjeCsBLqP8OspvL8hgl0pfdiadlRe1Yi-XHyI8ewJkACSyS0CNEkI9c9kiqolZIj6C75Xq0cJqkK1doi_ABmq5kqgnxqDnpSPWL47KKlQPXDAUFclPs0T5pIqKBD1zuzzg__nff1x_-3B_O4mS2yi5ivLrLcSubJTfRrhcWtubKLuK8DzC85bb5VBPqOoiPBfiafOIe61-ALURnjdcgInwPJ2WGGdZHuF5wBVX69H8LxVEtugJtHG6pNUkmSQtt-jskSeOqiAkz8qyJCWUpICsSWqGZ1WeVbMka6ZsOkvSegqzAyGiIln_96-f7--uFnfIDHXHLSKoHlqkoVfaOtuebRBuzOAtgohkiEsqBgbeE6N_a0IfrSYU1m5YWEIfERu63o3iQckE-X-ftWo16RDR7dCBtE4OFOH5UnUQ4XlHNB3MWoK0ivC85tK9sokQDMXxkphlbOyLgCi7beWA4hiWcaNJB_GSaRR3CETzsCqLh2KKYlg5pWP2IknHKYp7DmjzFgsuH0G70QWvi6kfxgGHVbwqi7iYToyaYBQr5CZhhOeD0XvILaURno8jxT1dU7ZycFMnm-BJGuH5ZHL8s2GwoNqmE_UncKba8nczptrW0HK5mCgU37_um83Ipzm_wmKk82vIyVC9zupcjd5H9T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