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

    <tr>
        <th>Summary</th>
        <td>
            clang crashes at -O1 and above on x86_64-linux-gnu: Assertion `hasUseList()' 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>
    Compiler Explorer: https://godbolt.org/z/9bbozcWxa

Also see: https://github.com/llvm/llvm-project/issues/150338

```
[586] % clangtk -v
clang version 22.0.0git (https://github.com/llvm/llvm-project.git 2b8696b58e25f53f23d35a3904c111c1ae61d6f4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 12.1
[587] % 
[587] % clangtk -O1 -w -c small.c
clangtk: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/IR/Value.h:357: llvm::Value::use_iterator llvm::Value::materialized_use_begin(): Assertion `hasUseList()' 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 -O1 -w -c small.c
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "function<eager-inv>(mem2reg,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>)" on module "small.c"
4.      Running pass "instcombine<max-iterations=1;no-verify-fixpoint>" on function "d"
 #0 0x000055fa34769c30 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4221c30)
 #1 0x000055fa347668df llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x421e8df)
 #2 0x000055fa346a6d88 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f2000d17520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f2000d6b9fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
 #5 0x00007f2000d6b9fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
 #6 0x00007f2000d6b9fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
 #7 0x00007f2000d17476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f2000cfd7f3 abort ./stdlib/./stdlib/abort.c:81:7
 #9 0x00007f2000cfd71b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9
#10 0x00007f2000d0ee96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055fa336532b9 (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x310b2b9)
#12 0x000055fa3485b5f1 llvm::wouldInstructionBeTriviallyDead(llvm::Instruction const*, llvm::TargetLibraryInfo const*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x43135f1)
#13 0x000055fa342a0410 llvm::InstCombinerImpl::run() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3d58410)
#14 0x000055fa342a20ba combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) InstructionCombining.cpp:0:0
#15 0x000055fa342a3490 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3d5b490)
#16 0x000055fa34a06da6 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x44beda6)
#17 0x000055fa340c0827 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3b78827)
#18 0x000055fa318312c6 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/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12e92c6)
#19 0x000055fa340c0d99 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3b78d99)
#20 0x000055fa318319b6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x12e99b6)
#21 0x000055fa340beb44 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3b76b44)
#22 0x000055fa34a15bf3 (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
#23 0x000055fa34a1a193 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x44d2193)
#24 0x000055fa3510c5cf clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4bc45cf)
#25 0x000055fa36b59c5c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x6611c5c)
#26 0x000055fa354292a9 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ee12a9)
#27 0x000055fa353a4cf5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4e5ccf5)
#28 0x000055fa35519668 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4fd1668)
#29 0x000055fa313b6103 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe6e103)
#30 0x000055fa313ac69a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#31 0x000055fa3517b71d 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
#32 0x000055fa346a7230 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x415f230)
#33 0x000055fa3517bfbe 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
#34 0x000055fa35139531 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4bf1531)
#35 0x000055fa3513a651 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&, bool) const (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4bf2651)
#36 0x000055fa35146ec4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4bfeec4)
#37 0x000055fa313b1fb7 clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe69fb7)
#38 0x000055fa3127e9eb main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd369eb)
#39 0x00007f2000cfed90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#40 0x00007f2000cfee40 call_init ./csu/../csu/libc-start.c:128:20
#41 0x00007f2000cfee40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#42 0x000055fa313abdc5 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe63dc5)
clangtk: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git (https://github.com/llvm/llvm-project.git 2b8696b58e25f53f23d35a3904c111c1ae61d6f4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/home/suz/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-2b299c.c
clangtk: note: diagnostic msg: /tmp/small-2b299c.sh
clangtk: note: diagnostic msg: 

********************
[588] % 
[588] % cat small.c
int h;
static int *a, **b = &a;
int c() { return h; }
int *d() {
  int e = *a;
  if (c())
 f : {
    int g;
    if (e)
      return &g;
    b = 0;
  }
  goto f;
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsW1tzo7iz_zTKi8oukADDQx6IE-_O1uxJKsn899ElRGPrBCT_JZHLfPpTEhCD7cxmdjZzLnu2shMQ3a3uX7darUuYMWIjAc5RfIHiyzPW2q3S51-3IEslN6Y9K1T5cr5UzU7UoPHV865WGjSiOd5auzOI5oisEFltVFmo2s6V3iCy-orIKisK9ZX_8cxQkKMgz2ujsAE4wSrsti3mXDWIrOr6cfg122n1n8AtIithTAsGkVUYB5SmnUSUBP1PkKP4Ik4TFF9iRGLMayY39gHPHlGQ-xf8CNoIJTEh82AebITFiKTfp8fccZEiTbKkiFMgcRXTitCSxoxmQcTDMOQhgyQskypCJENBfs_0Bqwz-TlN1kk0a-WDVE9yVgvZPs82snVEWw2sxI0qoXakO2XEMwryT9JYVtdQXgoPuFNHcVYjstqqBhBZmfZr9-9s-GBUZZ-YhhGtt39mdSsfEFkVQqIgv2hFXWKuZCU2negLZgxoK5Q0KMhXqpUl5kyWomQW8C_LJRadOszR9Oq0RruOROHQ4xyRVW_m3jyyCsO_WyBBQX4HNXAL5Y9LWr4q1bS1FY6F5niO6AWKgiaJxp29SdHZt_xymX9DmcEhbckQWb6GZEjm4RDCiyGEjxpeY_o6xLMnPOPYNKyu53wIcftwECRvxIUnLlwA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