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

    <tr>
        <th>Summary</th>
        <td>
            clang crashes on valid code at -O3 on x86_64-linux-gnu: Assertion `Val && "isa<> used on a null pointer"' failed 
        </td>
    </tr>

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

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

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

<pre>
    It appears to be a recent regression.

```
[510] % clangtk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git b89b3cdb612f43e91c7330a13c3f60a1ad251e50)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
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
[511] % 
[511] % clangtk -O3 small.c
clang-17: /local/suz-local/software/clangbuild/llvm-project/llvm/include/llvm/Support/Casting.h:109: static bool llvm::isa_impl_cl<To, const From*>::doit(const From*) [with To = llvm::SCEVAddRecExpr; From = llvm::SCEV]: Assertion `Val && "isa<> used on a null pointer"' 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: /local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/home/suz -resource-dir /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/17 -I /usr/local/include -internal-isystem /local/home/suz/suz-local/software/local/clang-trunk/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -fdebug-compilation-dir=/home/suz -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-72ccd7.o -x c small.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'small.c'.
4.      Running pass 'Loop Pass Manager' on function '@main'
5.      Running pass 'Loop Strength Reduction' on basic block '%while.cond5.6.4'
 #0 0x000055b2568e59c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x3b9e9c0)
 #1 0x000055b2568e32df llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x3b9c2df)
 #2 0x000055b2568e3435 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f883f7a8520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f883f7fca7c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x96a7c)
 #5 0x00007f883f7a8476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x00007f883f78e7f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00007f883f78e71b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x00007f883f79fe96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000055b256a3f39f llvm::SCEVExpander::expandAddRecExprLiterally(llvm::SCEVAddRecExpr const*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x3cf839f)
#10 0x000055b256a3a984 llvm::SCEVExpander::expand(llvm::SCEV const*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x3cf3984)
#11 0x000055b256a3ab70 llvm::SCEVExpander::expandCodeForImpl(llvm::SCEV const*, llvm::Type*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x3cf3b70)
#12 0x000055b256722a97 (anonymous namespace)::LSRInstance::Expand((anonymous namespace)::LSRUse const&, (anonymous namespace)::LSRFixup const&, (anonymous namespace)::Formula const&, llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, false>, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) const LoopStrengthReduce.cpp:0:0
#13 0x000055b25672dd8d (anonymous namespace)::LSRInstance::RewriteForPHI(llvm::PHINode*, (anonymous namespace)::LSRUse const&, (anonymous namespace)::LSRFixup const&, (anonymous namespace)::Formula const&, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) const LoopStrengthReduce.cpp:0:0
#14 0x000055b2567302e9 (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
#15 0x000055b256731d0c ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&, llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&, llvm::TargetTransformInfo const&, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::MemorySSA*) LoopStrengthReduce.cpp:0:0
#16 0x000055b2567348fc (anonymous namespace)::LoopStrengthReduce::runOnLoop(llvm::Loop*, llvm::LPPassManager&) LoopStrengthReduce.cpp:0:0
#17 0x000055b25591b51b llvm::LPPassManager::runOnFunction(llvm::Function&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x2bd451b)
#18 0x000055b2562434de llvm::FPPassManager::runOnFunction(llvm::Function&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x34fc4de)
#19 0x000055b256243729 llvm::FPPassManager::runOnModule(llvm::Module&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x34fc729)
#20 0x000055b256244055 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x34fd055)
#21 0x000055b256b4b977 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>>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x3e04977)
#22 0x000055b257b281aa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x4de11aa)
#23 0x000055b258ac4c89 clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x5d7dc89)
#24 0x000055b257372ef9 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x462bef9)
#25 0x000055b2572f62be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x45af2be)
#26 0x000055b257441edf clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0x46faedf)
#27 0x000055b253d28733 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0xfe1733)
#28 0x000055b253d24503 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x000055b253d25b9c clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0xfdeb9c)
#30 0x000055b253c38813 main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0xef1813)
#31 0x00007f883f78fd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#32 0x00007f883f78fe40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#33 0x000055b253d1ed75 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-17+0xfd7d75)
clangtk: error: unable to execute command: Aborted
clangtk: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.0 (https://github.com/llvm/llvm-project.git b89b3cdb612f43e91c7330a13c3f60a1ad251e50)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
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-ce764d.c
clangtk: note: diagnostic msg: /tmp/small-ce764d.sh
clangtk: note: diagnostic msg: 

********************
[512] % 
[512] % cat small.c
int a, b;
volatile int c;
int main() {
  int d = 0;
 L:
  while (a) {
    if (d) {
      c;
      goto L;
    }
    for (a = 4; a >= 0; a--)
      for (b = 0; b < 7; b++)
        while (c)
 d--;
  }
  return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWlFzo7iT_zTkRYULJDDwkAfHjmdSlf1PKsnMPrqE1Nj6D0icJDLJfPorCWyDk0wme5u9u7qr8kyg1Wr1r9XqbglRY8RWApwH6UWQrs5oZ3dKn__cgeRKbk13Vir-dH5lEW1boNogq1AJiCINDKRFGrYajBFKzoJoFUSL4f95NPz61_QijaMgXaEAp4jVVG7tdxQ-9K3-HT2AdmJQnM2iWYQCnO-sbU1AFgFeB3i9FXbXlTOmmgCv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