Open
Description
I was going through the bug report guide and it suggests that it's a frontend bug. Interestingly enough, I also as able to get a middle-end bug out of it, albeit for a different pass than on this one.
Testcase:
long a;
unsigned short b;
void c(int d, _Bool e, short f, char g, int h[][9][9][9],
short i[][9][9][9][9][9]) {
for (_Bool j = 0; j < f; j = e)
;
for (short k = 0;;) {
for (_Bool l = 0; l < e; l = f)
for (char m = 0; m < 18; m += 4)
for (signed n = 1; n < 17; n += 3) {
int p = (unsigned short)(d ? i[1][1][n][n][n][1] : 0);
a = h[k][l][0][l];
b = b > p ? b : p;
}
for (char q = 3; q < g; q += 1)
for (char r = 1; r; r++)
for (char s = 0; s < 5; s++)
;
}
}
Command/backtrace:
$ /scratch/ewlu/daily-upstream-build/build-gcv/bin/clang -I/scratch/ewlu/ci/compiler-fuzz-ci/csmith-build/include -fsigned-char -fno-strict-aliasing -fwrapv -march=rv64gcv -O3 red.c -o rv64gcv.bc -w
clang-21: /scratch/ewlu/daily-upstream-build/llvm/llvm/lib/Transforms/Utils/LCSSA.cpp:439: bool formLCSSAImpl(llvm::Loop&, const llvm::DominatorTree&, const llvm::LoopInfo*, llvm::ScalarEvolution*, LoopExitBlocksTy&): Assertion `L.isLCSSAForm(DT)' 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: /scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21 -cc1 -triple riscv64-unknown-linux-gnu -emit-obj -dumpdir rv64gcv.bc- -disable-free -clear-ast-before-backend -main-file-name red.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic-rv64 -target-feature +m -target-feature +a -target-feature +f -target-feature +d -target-feature +c -target-feature +v -target-feature +zicsr -target-feature +zifencei -target-feature +zmmul -target-feature +zaamo -target-feature +zalrsc -target-feature +zca -target-feature +zcd -target-feature +zve32f -target-feature +zve32x -target-feature +zve64d -target-feature +zve64f -target-feature +zve64x -target-feature +zvl128b -target-feature +zvl32b -target-feature +zvl64b -target-feature -b -target-feature -e -target-feature -h -target-feature -q -target-feature -sdext -target-feature -sdtrig -target-feature -sha -target-feature -shcounterenw -target-feature -shgatpa -target-feature -shtvala -target-feature -shvsatpa -target-feature -shvstvala -target-feature -shvstvecd -target-feature -smaia -target-feature -smcdeleg -target-feature -smcntrpmf -target-feature -smcsrind -target-feature -smdbltrp -target-feature -smepmp -target-feature -smmpm -target-feature -smnpm -target-feature -smrnmi -target-feature -smstateen -target-feature -ssaia -target-feature -ssccfg -target-feature -ssccptr -target-feature -sscofpmf -target-feature -sscounterenw -target-feature -sscsrind -target-feature -ssdbltrp -target-feature -ssnpm -target-feature -sspm -target-feature -ssqosid -target-feature -ssstateen -target-feature -ssstrict -target-feature -sstc -target-feature -sstvala -target-feature -sstvecd -target-feature -ssu64xl -target-feature -supm -target-feature -svade -target-feature -svadu -target-feature -svbare -target-feature -svinval -target-feature -svnapot -target-feature -svpbmt -target-feature -svvptc -target-feature -xandesperf -target-feature -xandesvdot -target-feature -xandesvpackfph -target-feature -xcvalu -target-feature -xcvbi -target-feature -xcvbitmanip -target-feature -xcvelw -target-feature -xcvmac -target-feature -xcvmem -target-feature -xcvsimd -target-feature -xmipscmov -target-feature -xmipslsp -target-feature -xsfcease -target-feature -xsfmm128t -target-feature -xsfmm16t -target-feature -xsfmm32a16f -target-feature -xsfmm32a32f -target-feature -xsfmm32a8f -target-feature -xsfmm32a8i -target-feature -xsfmm32t -target-feature -xsfmm64a64f -target-feature -xsfmm64t -target-feature -xsfmmbase -target-feature -xsfvcp -target-feature -xsfvfnrclipxfqf -target-feature -xsfvfwmaccqqq -target-feature -xsfvqmaccdod -target-feature -xsfvqmaccqoq -target-feature -xsifivecdiscarddlone -target-feature -xsifivecflushdlone -target-feature -xtheadba -target-feature -xtheadbb -target-feature -xtheadbs -target-feature -xtheadcmo -target-feature -xtheadcondmov -target-feature -xtheadfmemidx -target-feature -xtheadmac -target-feature -xtheadmemidx -target-feature -xtheadmempair -target-feature -xtheadsync -target-feature -xtheadvdot -target-feature -xventanacondops -target-feature -xwchc -target-feature -za128rs -target-feature -za64rs -target-feature -zabha -target-feature -zacas -target-feature -zama16b -target-feature -zawrs -target-feature -zba -target-feature -zbb -target-feature -zbc -target-feature -zbkb -target-feature -zbkc -target-feature -zbkx -target-feature -zbs -target-feature -zcb -target-feature -zce -target-feature -zcf -target-feature -zclsd -target-feature -zcmop -target-feature -zcmp -target-feature -zcmt -target-feature -zdinx -target-feature -zfa -target-feature -zfbfmin -target-feature -zfh -target-feature -zfhmin -target-feature -zfinx -target-feature -zhinx -target-feature -zhinxmin -target-feature -zic64b -target-feature -zicbom -target-feature -zicbop -target-feature -zicboz -target-feature -ziccamoa -target-feature -ziccamoc -target-feature -ziccif -target-feature -zicclsm -target-feature -ziccrse -target-feature -zicntr -target-feature -zicond -target-feature -zihintntl -target-feature -zihintpause -target-feature -zihpm -target-feature -zilsd -target-feature -zimop -target-feature -zk -target-feature -zkn -target-feature -zknd -target-feature -zkne -target-feature -zknh -target-feature -zkr -target-feature -zks -target-feature -zksed -target-feature -zksh -target-feature -zkt -target-feature -ztso -target-feature -zvbb -target-feature -zvbc -target-feature -zvfbfmin -target-feature -zvfbfwma -target-feature -zvfh -target-feature -zvfhmin -target-feature -zvkb -target-feature -zvkg -target-feature -zvkn -target-feature -zvknc -target-feature -zvkned -target-feature -zvkng -target-feature -zvknha -target-feature -zvknhb -target-feature -zvks -target-feature -zvksc -target-feature -zvksed -target-feature -zvksg -target-feature -zvksh -target-feature -zvkt -target-feature -zvl1024b -target-feature -zvl16384b -target-feature -zvl2048b -target-feature -zvl256b -target-feature -zvl32768b -target-feature -zvl4096b -target-feature -zvl512b -target-feature -zvl65536b -target-feature -zvl8192b -target-feature -experimental-p -target-feature -experimental-smctr -target-feature -experimental-ssctr -target-feature -experimental-svukte -target-feature -experimental-xqccmp -target-feature -experimental-xqcia -target-feature -experimental-xqciac -target-feature -experimental-xqcibi -target-feature -experimental-xqcibm -target-feature -experimental-xqcicli -target-feature -experimental-xqcicm -target-feature -experimental-xqcics -target-feature -experimental-xqcicsr -target-feature -experimental-xqciint -target-feature -experimental-xqciio -target-feature -experimental-xqcilb -target-feature -experimental-xqcili -target-feature -experimental-xqcilia -target-feature -experimental-xqcilo -target-feature -experimental-xqcilsm -target-feature -experimental-xqcisim -target-feature -experimental-xqcisls -target-feature -experimental-xqcisync -target-feature -experimental-xrivosvisni -target-feature -experimental-xrivosvizip -target-feature -experimental-xsfmclic -target-feature -experimental-xsfsclic -target-feature -experimental-zalasr -target-feature -experimental-zicfilp -target-feature -experimental-zicfiss -target-feature -experimental-zvbc32e -target-feature -experimental-zvkgs -target-feature -experimental-zvqdotq -target-feature +relax -target-abi lp64d -debugger-tuning=gdb -fdebug-compilation-dir=/scratch/ewlu/ci/compiler-fuzz-ci/triage-ice/error_6 -fcoverage-compilation-dir=/scratch/ewlu/ci/compiler-fuzz-ci/triage-ice/error_6 -resource-dir /scratch/ewlu/daily-upstream-build/build-gcv/lib/clang/21 -I /scratch/ewlu/ci/compiler-fuzz-ci/csmith-build/include -isysroot /scratch/ewlu/daily-upstream-build/build-gcv/bin/../sysroot -internal-isystem /scratch/ewlu/daily-upstream-build/build-gcv/lib/clang/21/include -internal-isystem /scratch/ewlu/daily-upstream-build/build-gcv/bin/../sysroot/usr/local/include -internal-isystem /scratch/ewlu/daily-upstream-build/build-gcv/bin/../sysroot/lib/gcc/riscv64-unknown-linux-gnu/16.0.0/../../../../riscv64-unknown-linux-gnu/include -internal-externc-isystem /scratch/ewlu/daily-upstream-build/build-gcv/bin/../sysroot/include -internal-externc-isystem /scratch/ewlu/daily-upstream-build/build-gcv/bin/../sysroot/usr/include -O3 -w -ferror-limit 19 -fwrapv -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/red-31a195.o -x c red.c
1. <eof> parser at end of file
2. Optimizer
3. Running pass "function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop(evl-iv-simplify),loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "red.c"
4. Running pass "loop-unroll<O3>" on function "c"
#0 0x000056e74583a932 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x21d1932)
#1 0x000056e74583799f llvm::sys::RunSignalHandlers() (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x21ce99f)
#2 0x000056e745837ae4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000718a0da45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#4 0x0000718a0da9eb2c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x0000718a0da9eb2c __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x0000718a0da9eb2c pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x0000718a0da4527e raise ./signal/../sysdeps/posix/raise.c:27:6
#8 0x0000718a0da288ff abort ./stdlib/abort.c:81:7
#9 0x0000718a0da2881b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x0000718a0da3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#11 0x000056e74590c510 formLCSSAImpl(llvm::Loop&, llvm::DominatorTree const&, llvm::LoopInfo const*, llvm::ScalarEvolution*, llvm::SmallDenseMap<llvm::Loop*, llvm::SmallVector<llvm::BasicBlock*, 1u>, 4u, llvm::DenseMapInfo<llvm::Loop*, void>, llvm::detail::DenseMapPair<llvm::Loop*, llvm::SmallVector<llvm::BasicBlock*, 1u>>>&) LCSSA.cpp:0:0
#12 0x000056e74590db8e llvm::formLCSSARecursively(llvm::Loop&, llvm::DominatorTree const&, llvm::LoopInfo const*, llvm::ScalarEvolution*) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x22a4b8e)
#13 0x000056e74568456f llvm::LoopUnrollPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x201b56f)
#14 0x000056e7469121b5 llvm::detail::PassModel<llvm::Function, llvm::LoopUnrollPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x32a91b5)
#15 0x000056e7452e116a llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x1c7816a)
#16 0x000056e745aca5e5 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x24615e5)
#17 0x000056e7452e1654 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x1c78654)
#18 0x000056e745aca365 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x2461365)
#19 0x000056e7452dffdd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x1c76fdd)
#20 0x000056e745ad9f06 (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
#21 0x000056e745add3a9 (anonymous namespace)::EmitAssemblyHelper::emitAssembly(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) BackendUtil.cpp:0:0
#22 0x000056e745ade38c 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*) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x247538c)
#23 0x000056e7461cabfe clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x2b61bfe)
#24 0x000056e747db284c clang::ParseAST(clang::Sema&, bool, bool) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x474984c)
#25 0x000056e746513fc7 clang::FrontendAction::Execute() (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x2eaafc7)
#26 0x000056e746492925 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x2e29925)
#27 0x000056e7465fe9eb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0x2f959eb)
#28 0x000056e744521098 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0xeb8098)
#29 0x000056e7445169d7 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#30 0x000056e74451b3fd clang_main(int, char**, llvm::ToolContext const&) (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0xeb23fd)
#31 0x000056e7443dfafa main (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0xd76afa)
#32 0x0000718a0da2a1ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#33 0x0000718a0da2a28b call_init ./csu/../csu/libc-start.c:128:20
#34 0x0000718a0da2a28b __libc_start_main ./csu/../csu/libc-start.c:347:5
#35 0x000056e744515f55 _start (/scratch/ewlu/daily-upstream-build/build-gcv/bin/clang-21+0xeacf55)
clang: error: unable to execute command: Aborted
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 21.0.0git (https://github.com/llvm/llvm-project.git 3d028348ce0d6fa531ba7dad8fd38893019dc609)
Target: riscv64-unknown-linux-gnu
Thread model: posix
InstalledDir: /scratch/ewlu/daily-upstream-build/build-gcv/bin
Build config: +assertions
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/red-be326d.c
clang: note: diagnostic msg: /tmp/red-be326d.sh
clang: note: diagnostic msg:
********************
Godbolt: https://godbolt.org/z/Mz6PccbTG
Found via fuzzer