<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54266>54266</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang crashes on valid code at -O2 and -O3: Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' 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>
```
[512] % clangtk -v
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 49a29e5c9f8f358a2168ad5488ba6959d94525d3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
[513] %
[513] % clangtk -Os small.c; ./a.out
[514] %
[514] % clangtk -O2 small.c
Instruction does not dominate all uses!
%xor11.i37 = xor i32 0, %conv.i33
%xor11.i37.lcssa.lcssa = phi i32 [ %xor11.i37.lcssa, %for.inc3 ], [ %xor11.i37, %middle.block ]
clang-15: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10725: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `!verifyFunction(*L->getHeader()->getParent(), &dbgs())' 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/suz-local/software/local/clang-trunk/bin/clang-15 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20220308-clangtk-m64-O3-mllvm-enable-constraint-elimination-build-065826/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/15.0.0 -I /usr/local/include/csmith -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/15.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.5.0/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20220308-clangtk-m64-O3-mllvm-enable-constraint-elimination-build-065826/delta -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-da63db.o -x c small.c
1. <eof> parser at end of file
2. Optimizer
#0 0x000055d93121b06f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x000055d93121882d SignalHandler(int) Signals.cpp:0:0
#2 0x00007fd0bb400980 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
#3 0x00007fd0ba0b1e87 raise /build/glibc-uZu3wS/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
#4 0x00007fd0ba0b37f1 abort /build/glibc-uZu3wS/glibc-2.27/stdlib/abort.c:81:0
#5 0x00007fd0ba0a33fa __assert_fail_base /build/glibc-uZu3wS/glibc-2.27/assert/assert.c:89:0
#6 0x00007fd0ba0a3472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
#7 0x000055d93144e310 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x3cf8310)
#8 0x000055d93144f691 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo&, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AAResults&, llvm::AssumptionCache&, std::function<llvm::LoopAccessInfo const& (llvm::Loop&)>&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x3cf9691)
#9 0x000055d93144fc29 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x3cf9c29)
#10 0x000055d932443051 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x4ced051)
#11 0x000055d93097f9dc llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x32299dc)
#12 0x000055d92ee17711 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>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x16c1711)
#13 0x000055d93097f3fa llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x32293fa)
#14 0x000055d92ee18071 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x16c2071)
#15 0x000055d93097dbb4 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x3227bb4)
#16 0x000055d931557dd0 (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> >&) (.constprop.836) BackendUtil.cpp:0:0
#17 0x000055d93155ada2 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream> >) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x3e04da2)
#18 0x000055d932267fdb clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x4b11fdb)
#19 0x000055d93317bd89 clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x5a25d89)
#20 0x000055d932266ad8 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x4b10ad8)
#21 0x000055d931bfe311 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x44a8311)
#22 0x000055d931b9890a clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x444290a)
#23 0x000055d931ccc203 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x4576203)
#24 0x000055d92eb55011 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x13ff011)
#25 0x000055d92eb50ea9 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#26 0x000055d92ea99689 main (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x1343689)
#27 0x00007fd0ba094c87 __libc_start_main /build/glibc-uZu3wS/glibc-2.27/csu/../csu/libc-start.c:344:0
#28 0x000055d92eb50a1a _start (/local/suz-local/software/local/clang-trunk/bin/clang-15+0x13faa1a)
clang-15: error: unable to execute command: Aborted
clang-15: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 49a29e5c9f8f358a2168ad5488ba6959d94525d3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
clang-15: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-15: note: diagnostic msg: /tmp/small-a00f0e.c
clang-15: note: diagnostic msg: /tmp/small-a00f0e.sh
clang-15: note: diagnostic msg:
********************
[515] %
[515] % cat small.c
static int a[8];
int b, c, e, f;
void g() {
b = a[b];
b = a[b & 5];
b = a[b ^ c];
b = a[b ^ c];
b = (b > 8) ^ a[b ^ c];
}
void h() {
for (; e; e++)
for (f = 0; f < 7; f++) {
g();
g();
g();
}
}
int main() {
int d;
h();
if (e)
a[0] = d;
return 0;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWt1v2zgS_2ucF0KGvi095MFx4jZA9hI06S5wLwYlUTa3kqgjpdTpX38zpORIipukbXLYu73CdWRyOB-_GQ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