<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63669>63669</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang crash: Assertion `isAvailableAtLoopEntry(OrigRHS, L) && "Must be!"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
shao-hua-li
</td>
</tr>
</table>
<pre>
```console
% cat a.c
int b;
int *const c = &b;
short d;
long e, j;
static char f = 9, l;
static char *g = &f, *h = &g;
char k;
void m() {
int n[2];
int i;
for (; *g + e + i < 2; i++)
n[i] = 3;
char *o = h;
k = n[0];
&o == l;
}
void p() {
d = 0;
for (; d < 6; d++) {
long *a = &e;
*a = *g + b;
}
}
void q() {
p();
m();
for (; j; j++)
if (*c)
break;
f = 0;
}
void main() {}
%
% clang-tk -Os -w a.c
clang-17: /zdata/shaoli/compilers/ccbuilder-repos/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:12831: llvm::ScalarEvolution::ExitLimit llvm::ScalarEvolution::howManyLessThans(const llvm::SCEV*, const llvm::SCEV*, const llvm::Loop*, bool, bool, bool): Assertion `isAvailableAtLoopEntry(OrigRHS, L) && "Must be!"' 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: /zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name crash_0_reduced.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=/zdata/shaoli/realsmith -resource-dir /zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/lib/clang/17 -internal-isystem /zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -fdebug-compilation-dir=/zdata/shaoli/realsmith -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/crash_0_reduced-f57a37.o -x c work76/work/wrong/crash_0_reduced.c
1. <eof> parser at end of file
2. Optimizer
#0 0x000055d5d00fe49f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3b6849f)
#1 0x000055d5d00fbbf4 SignalHandler(int) Signals.cpp:0:0
#2 0x00007f4c203cc420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#3 0x00007f4c1fe1d00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#4 0x00007f4c1fdfc859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f4c1fdfc729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f4c1fe0dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#7 0x000055d5cf22d9df llvm::ScalarEvolution::howManyLessThans(llvm::SCEV const*, llvm::SCEV const*, llvm::Loop const*, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c979df)
#8 0x000055d5cf22de66 llvm::ScalarEvolution::computeExitLimitFromICmp(llvm::Loop const*, llvm::CmpInst::Predicate, llvm::SCEV const*, llvm::SCEV const*, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c97e66)
#9 0x000055d5cf22e3a8 llvm::ScalarEvolution::computeExitLimitFromICmp(llvm::Loop const*, llvm::ICmpInst*, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c983a8)
#10 0x000055d5cf22e5ed llvm::ScalarEvolution::computeExitLimitFromCondImpl(llvm::ScalarEvolution::ExitLimitCache&, llvm::Loop const*, llvm::Value*, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c985ed)
#11 0x000055d5cf22ec2b llvm::ScalarEvolution::computeExitLimitFromCondCached(llvm::ScalarEvolution::ExitLimitCache&, llvm::Loop const*, llvm::Value*, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c98c2b)
#12 0x000055d5cf22ed6d llvm::ScalarEvolution::computeExitLimitFromCond(llvm::Loop const*, llvm::Value*, bool, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c98d6d)
#13 0x000055d5cf1f8920 llvm::ScalarEvolution::computeExitLimit(llvm::Loop const*, llvm::BasicBlock*, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c62920)
#14 0x000055d5cf1f9001 llvm::ScalarEvolution::computeBackedgeTakenCount(llvm::Loop const*, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c63001)
#15 0x000055d5cf1f9f38 llvm::ScalarEvolution::getBackedgeTakenInfo(llvm::Loop const*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c63f38)
#16 0x000055d5cf22fd1e llvm::PredicatedScalarEvolution::getBackedgeTakenCount() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2c99d1e)
#17 0x000055d5cf120109 llvm::LoopAccessInfo::canAnalyzeLoop() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2b8a109)
#18 0x000055d5cf130cdc llvm::LoopAccessInfo::LoopAccessInfo(llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetLibraryInfo const*, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2b9acdc)
#19 0x000055d5cf13134e llvm::LoopAccessInfoManager::getInfo(llvm::Loop&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x2b9b34e)
#20 0x000055d5d3af9f0e llvm::LoopLoadEliminationPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x7563f0e)
#21 0x000055d5d13e54c6 llvm::detail::PassModel<llvm::Function, llvm::LoopLoadEliminationPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4e4f4c6)
#22 0x000055d5cd99f08d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x140908d)
#23 0x000055d5cfaae5ed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x35185ed)
#24 0x000055d5cd982b26 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x13ecb26)
#25 0x000055d5cfaac56d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x351656d)
#26 0x000055d5d037b186 (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>>&) BackendUtil.cpp:0:0
#27 0x000055d5d037e1f9 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>>) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x3de81f9)
#28 0x000055d5d13828ed clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4dec8ed)
#29 0x000055d5d2502789 clang::ParseAST(clang::Sema&, bool, bool) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x5f6c789)
#30 0x000055d5d13810a8 clang::CodeGenAction::ExecuteAction() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4deb0a8)
#31 0x000055d5d0bc4879 clang::FrontendAction::Execute() (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x462e879)
#32 0x000055d5d0b4a1c6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x45b41c6)
#33 0x000055d5d0ca9b46 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x4713b46)
#34 0x000055d5cd5ef204 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x1059204)
#35 0x000055d5cd5eaf2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x000055d5cd5ec4fc clang_main(int, char**, llvm::ToolContext const&) (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x10564fc)
#37 0x000055d5cd5011a5 main (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0xf6b1a5)
#38 0x00007f4c1fdfe083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#39 0x000055d5cd5e5d0e _start (/zdata/shaoli/compilers/ccbuilder-compilers/clang-assertion/bin/clang-17+0x104fd0e)
clang-tk: error: unable to execute command: Aborted
clang-tk: 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 4314f4ceb5c8a95835b50d3b93f82e0f11f587f1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers
%
% clang-tk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4314f4ceb5c8a95835b50d3b93f82e0f11f587f1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers
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
%
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW1tz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