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

    <tr>
        <th>Summary</th>
        <td>
            [clang] Crash at -O3: Instruction does not dominate all uses!
        </td>
    </tr>

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

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

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

<pre>
    This code crashes at `-O3`:

```c
int a;
double b;
long c;
int d(long f, long g) {
  if (f + g)
    return 1;
  for (long e = 0; e < g; e++)
 *(char *)e = 5;
  return 0;
}
int h(int f) {
  double i = 0.270112271089232341485679099e4;
  b = 0.1e1;
  for (; c; c--) {
    i = i * (80 + f) * (9 + f) + a;
    a = 0;
    b = b * f * (d(-42, f) + f) + 0.11623987080032122878585294e22;
  }
  return i / b;
}
void main() {}
```

Compiler Explorer: https://godbolt.org/z/b4YEsPMrq

Bisected to https://github.com/llvm/llvm-project/commit/894935cb5146fd2ac6334cc8b11e6d6e0e264fe6, which was committed by @alexey-bataev 

Crash:

```console
Instruction does not dominate all uses!
  %3 = insertelement <2 x i32> %2, i32 %f, i64 1
  %0 = insertelement <2 x i32> %3, i32 %add1, i64 0
in function h
fatal error: error in backend: Broken function found, compilation aborted!
```

Backtrace:

```console
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -O3 -Wall -Wextra <source>
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '<source>'.
4.      Running pass 'Module Verifier' on function '@h'
 #0 0x0000000003e87c38 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e87c38)
 #1 0x0000000003e858c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e858c4)
 #2 0x0000000003dcacb6 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcacb6)
 #3 0x0000000003e7cfee llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e7cfee)
 #4 0x0000000000d4e5a0 LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x0000000003dd5443 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd5443)
 #6 0x0000000003dd55a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dd55a8)
 #7 0x0000000003887952 (anonymous namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&) Verifier.cpp:0:0
 #8 0x00000000037d28df llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d28df)
 #9 0x00000000037d2c91 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d2c91)
#10 0x00000000037d3531 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x37d3531)
#11 0x000000000413d67e 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*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x413d67e)
#12 0x00000000048429a0 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48429a0)
#13 0x00000000064aecac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x64aecac)
#14 0x0000000004842da8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4842da8)
#15 0x0000000004b127f5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b127f5)
#16 0x0000000004a94a2e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a94a2e)
#17 0x0000000004c024fe clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4c024fe)
#18 0x0000000000d50baf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd50baf)
#19 0x0000000000d4836a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#20 0x000000000488b309 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
#21 0x0000000003dcabf4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcabf4)
#22 0x000000000488b91f 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
#23 0x000000000484e38d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484e38d)
#24 0x000000000484f41e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x484f41e)
#25 0x0000000004856af5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4856af5)
#26 0x0000000000d4d9a8 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4d9a8)
#27 0x0000000000c146c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc146c4)
#28 0x00007acc03029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#29 0x00007acc03029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#30 0x0000000000d47e15 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd47e15)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWU1z2ziT_jXwBUUVCJAUefBBlq3dmUrKrtg7U3tSgSAoYUMCGgB05P31bwEgxY84GU-9mrm8KceG8NH99NON7qZIjREHyfktSO9Aen9DO3tU-pZRXYkDlTFC-U2pqrfbl6MwkKmKQ6apOXIDqYUgQ9EjARkCZAOQ_8lQ-GEAbYS0kAJyB9CmUl3ZcFiGT42SB8jC2G2qAM79XA3wFvrRAeACgrXbAaGoIcC5-3XnF_wkhJrbTksYB0EQ1krDQRKHgNxDBMidH27hwQ8BvvM_XgTAG4BzdqQ6DItwKB3k9fJR-AzW9z3cI8C5-1tPMfYWiqB3hdcojjFexygvMMEkiZM8zdYFKgqeDArKfnPMlzY4sMz_iqKpFtgrEA6x25gjz0qAEqaK6czd4AF3ll5I6ScCgNKfrIfzzhtRgp0rLkIuA7SK4wyTIl-jHCGCY4zzdZ7mKS4SjvEgOpB1odDB3Q3eD2uvSlSwpUI6a3sL_cIlhEJEbVV7Eg3X8OF8apTmGpANPFp7Mi7o8A7g3UFVpWrsSukDwLv_B3hXJv_7YJ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