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

    <tr>
        <th>Summary</th>
        <td>
            clang crashes on valid code at -O{s,2,3} on x86_64-linux-gnu: Assertion `!empty()' failed 
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    It seems to be a very recent regression as it doesn't reproduce with the latest build on Compiler Explorer.

```
[535] % clangtk -v
clang version 19.0.0git (https://github.com/llvm/llvm-project.git e481f565286e7fbf5dda9c4a0d00ca1daae8abeb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/software/local/clang-trunk/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
[536] %
[536] % clangtk -O1 -c small.c
[537] %
[537] % clangtk -Os -c small.c
clangtk: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:169: const T& llvm::ArrayRef<T>::front() const [with T = llvm::Value*]: Assertion `!empty()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: clangtk -I/usr/local/include -I/local/suz-local/software/local/include -Os -c small.c
1.      <eof> parser at end of file
2.      Optimizer
 #0 0x000055e723d77cef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3ff9cef)
 #1 0x000055e723d7582c llvm::sys::CleanupOnSignal(unsigned long) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3ff782c)
 #2 0x000055e723cb62b8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f05eecc2420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f05ee6c900b raise /build/glibc-wuryBv/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f05ee6a8859 abort /build/glibc-wuryBv/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007f05ee6a8729 get_sysdep_segment_value /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007f05ee6a8729 _nl_load_domain /build/glibc-wuryBv/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007f05ee6b9fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x000055e725638c4f llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&)::'lambda'(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&)::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0
#10 0x000055e725639591 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x58bb591)
#11 0x000055e725639c03 llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x58bbc03)
#12 0x000055e72563ace6 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
#13 0x000055e72563b7f3 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x58bd7f3)
#14 0x000055e725144926 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x53c6926)
#15 0x000055e7213d904c llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x165b04c)
#16 0x000055e72373641d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x39b841d)
#17 0x000055e7213bbc76 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x163dc76)
#18 0x000055e7237342ad llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x39b62ad)
#19 0x000055e723ffc948 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#20 0x000055e723fffc80 (anonymous namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#21 0x000055e7240002f9 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x42822f9)
#22 0x000055e724656f1a clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x48d8f1a)
#23 0x000055e72638daac clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x660faac)
#24 0x000055e7246562a8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x48d82a8)
#25 0x000055e7248e1509 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4b63509)
#26 0x000055e724868d2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4aead2e)
#27 0x000055e7249c8976 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x4c4a976)
#28 0x000055e720fc1b8c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x1243b8c)
#29 0x000055e720fbac9a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x000055e72469aecd void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#31 0x000055e723cb67c0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x3f387c0)
#32 0x000055e72469b4ef clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#33 0x000055e72466019c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x48e219c)
#34 0x000055e724660c2d clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x48e2c2d)
#35 0x000055e724669045 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x48eb045)
#36 0x000055e720fbef7b clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x1240f7b)
#37 0x000055e720ebc7cb main (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x113e7cb)
#38 0x00007f05ee6aa083 __libc_start_main /build/glibc-wuryBv/glibc-2.31/csu/../csu/libc-start.c:342:3
#39 0x000055e720fba76e _start (/local/suz-local/software/local/clang-trunk/bin/clang-19+0x123c76e)
clangtk: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 19.0.0git (https://github.com/llvm/llvm-project.git e481f565286e7fbf5dda9c4a0d00ca1daae8abeb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/software/local/clang-trunk/bin
Build config: +assertions
clangtk: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clangtk: note: diagnostic msg: /tmp/small-0509c2.c
clangtk: note: diagnostic msg: /tmp/small-0509c2.sh
clangtk: note: diagnostic msg:

********************
[538] %
[538] % cat small.c
struct a {
  char b;
  char c;
  char d;
} *e;
char f(struct a g) {
  struct a *h = e;
  *h = g;
  return g.c;
}
```

 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW91y27iSfhr6BmUVCf5f-EKW7UmmPGtXrDl7qQKBpowNCXAB0LHn6bcAUhIhyYmcY-9mz5mUI4v46-4PjQ8NsE205msBcBGkl0F6dUZ68yjVxV-PIJgUa92fVZK9XHw2SAO0GhmJKkAEPYF6QQooCIMUrBVozaVARCNuEJOgRYBzW9UpyXoK6Bs3j8g8AmqIAW1Q1fOGISnQQrYdb0Ch6-eukQrULAivgnA-fmbh-DM8ppdpnAbpFQpwimhDxNp8RedPQ617tqo5XaJyFs7CNTcowMWjMZ0O4nmAbwJ8s-bmsa9mVLYBvmmap82v807J_wJqZrYXJEVUp1mKiwzyuqpTxkhJExKyMKQkYoRAQSqoAlwO4pdErcEE8Rw9F9kqS8578VXIb-K84aJ_Pl-Lfmz3qIAw1EoGjW3dSc2fh6rPQhvSNMCuuLJVVi9JSRPgG93_db79LmvzjSiYVDvbz43qxdcA31RcDANeOpipFDVfDwNeEq1BGS6FHprcyF4wRIlgnBED6LfFAvFBD2KbjXr0WllxvLL4URrgm9HKnXX4Jgo_YMzo_cccZ-wBGqAG2Lvot9hq1vaN4bZXPEezIL4MkrDNkj2R32vk3Dwb3fxI0c7z7yJ0TpFuSdPM6KRlftg5P-ysDzqPdaf5nmvsFvLe-tmtKi5o0zPYFcyvlvZTKfLyBerZYxDPo6y08qg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