Skip to content

clang crashes at -O{1,2,3} on x86_64-linux-gnu: Assertion `pred_empty(DelBB) && "DelBB has one or more predecessors."' failed #153295

@zhendongsu

Description

@zhendongsu

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

Note:

  • fails: 20.1.0 and trunk
  • works: 19.1.0 and earlier
  • original code was valid, but the reduced isn't
[599] % clangtk -v
clang version 22.0.0git (https://github.com/llvm/llvm-project.git 44f41f55b4df5ec490df0d69e046b2d1a58acaeb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin
Build config: +assertions
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
Found CUDA installation: /usr/local/cuda, version 12.1
[600] % 
[600] % clangtk -O1 -w -c small.c
clangtk: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Analysis/DomTreeUpdater.cpp:91: void llvm::DomTreeUpdater::validateDeleteBB(llvm::BasicBlock*): Assertion `pred_empty(DelBB) && "DelBB has one or more predecessors."' 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: clangtk -I/usr/local/include -I/local/suz-local/software/local/include -O1 -w -c small.c
1.	<eof> parser at end of file
2.	Optimizer
3.	Running pass "ipsccp" on module "small.c"
 #0 0x000055bd288ea430 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4263430)
 #1 0x000055bd288e70df llvm::sys::RunSignalHandlers() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x42600df)
 #2 0x000055bd288277d8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f13e112e520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f13e11829fc __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
 #5 0x00007f13e11829fc __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
 #6 0x00007f13e11829fc pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
 #7 0x00007f13e112e476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f13e11147f3 abort ./stdlib/./stdlib/abort.c:81:7
 #9 0x00007f13e111471b _nl_load_domain ./intl/./intl/loadmsgcat.c:1177:9
#10 0x00007f13e1125e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000055bd276cf797 llvm::DomTreeUpdater::validateDeleteBB(llvm::BasicBlock*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3048797)
#12 0x000055bd276cf926 llvm::DomTreeUpdater::deleteBB(llvm::BasicBlock*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3048926)
#13 0x000055bd2a1de05a runIPSCCP(llvm::Module&, llvm::DataLayout const&, llvm::AnalysisManager<llvm::Function>*, std::function<llvm::TargetLibraryInfo const& (llvm::Function&)>, std::function<llvm::TargetTransformInfo& (llvm::Function&)>, std::function<llvm::AssumptionCache& (llvm::Function&)>, std::function<llvm::DominatorTree& (llvm::Function&)>, std::function<llvm::BlockFrequencyInfo& (llvm::Function&)>, bool) SCCP.cpp:0:0
#14 0x000055bd2a1deca7 llvm::IPSCCPPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5b57ca7)
#15 0x000055bd299cf216 llvm::detail::PassModel<llvm::Module, llvm::IPSCCPPass, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5348216)
#16 0x000055bd2822a194 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x3ba3194)
#17 0x000055bd28b90d13 (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
#18 0x000055bd28b952b3 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*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x450e2b3)
#19 0x000055bd2928f05f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c0805f)
#20 0x000055bd2acf2a0c clang::ParseAST(clang::Sema&, bool, bool) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x666ba0c)
#21 0x000055bd295acb59 clang::FrontendAction::Execute() (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4f25b59)
#22 0x000055bd295284c5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4ea14c5)
#23 0x000055bd2969d628 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x5016628)
#24 0x000055bd25500d58 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe79d58)
#25 0x000055bd254f735a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#26 0x000055bd292fe17d 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
#27 0x000055bd28827c80 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x41a0c80)
#28 0x000055bd292fea1e 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
#29 0x000055bd292bbf31 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c34f31)
#30 0x000055bd292bd051 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&, bool) const (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c36051)
#31 0x000055bd292c9a34 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*> >&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0x4c42a34)
#32 0x000055bd254fcbfb clang_main(int, char**, llvm::ToolContext const&) (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe75bfb)
#33 0x000055bd253c806b main (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xd4106b)
#34 0x00007f13e1115d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#35 0x00007f13e1115e40 call_init ./csu/../csu/libc-start.c:128:20
#36 0x00007f13e1115e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#37 0x000055bd254f6a85 _start (/local/home/suz/suz-local/software/local/clang-trunk/bin/clang-22+0xe6fa85)
clangtk: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git (https://github.com/llvm/llvm-project.git 44f41f55b4df5ec490df0d69e046b2d1a58acaeb)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/home/suz/suz-local/software/local/clang-trunk/bin
Build config: +assertions
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-9f4e27.c
clangtk: note: diagnostic msg: /tmp/small-9f4e27.sh
clangtk: note: diagnostic msg: 

********************
[601] % 
[601] % cat small.c
int a, b, c, d, e, f, h, i, j, l, n;
long g;
char k, m;
int q() {}
long r();
int s();
int t();
int u();
int v() {}
int w();
int x(int, int, int, int) { return 0; }
char y();
int z(long);
int aa(int[]) { return 0; }
static int ab(int ac, int ad, int ae, int af, int ag) {
  int o = 0, p;
  a / 1;
  goto ah;
ai:
  1 % a + 1 % b + 0;
  if (5 * s(d + 2, d + 9 + d - 1) + d - 1 % ac - 2 * b + 9 + b - 3 + b -
      2 * s(ad + ad - 3) + ad - 1)
    a = o = (char)u - 1 + c + 7 / y(b + 1) + b - 3 + b + 1;
  if (1 % (s(o + 8 + o - 2) + o) + -p + 1 % (s(0, d + 2, d + 4 + d - 2) + d) +
      1 / ad - 3)
    goto ai;
  ad = 1 + -r(o - 2) + o + 3;
  if (1 + s(r) + ad - -s(c + 8 + c - 2) + c - 2 / a - 5)
    d = 1 % p + -z(a + 4 - 2) + a + -s((char)q + 5, a + 7, a + 9 + a - 6) + a -
        1 % s(p + 1 + p - 3) + p - 1;
  if (-(-u(0, o + o + 3, o + 3 + o - 1) + o - 1 % (v() + af - 2) + b - 7))
    goto aj;
ah:
  d + s(c + 6 + u) - 4294967294 + c + o + -s(0, 0, ad + 3 + ad - 4 - 8) + ad +
      -a + 1 % s(b + 9, b + 5 + b - 2) + b + 0;
  if (1 / (char)a - 2 + a + 2 * r(6, 5) - 4 + ac + 1 / s(0) - b + 7 / d + 1)
    p = -18 / (x(a + 5, 0, a + 2, ac + 3) + ae + ac + o + ag + af - 2) + ae -
        -ad - 1;
  goto ai;
aj:
  b = -s(ac + a + d - 4) + ac - -z(d + 1 + d - 3) + d - 1 % t(p + 1 + p - 1) +
      p - 1 % s((char)a + 4 + c + a + ad + q) + a - 2 + c - 1;
  n = m = u(ac + 9);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  w(w);
  l = s((char)s);
  k = y(b + 5);
  j = s(0, b + 7);
  i = s((char)c + c + 209);
  h = s(p + 4);
  g = r(8, 6, 9, 6, 5, 9, 6, 4, 5, 8, 4);
  f = w(r);
  e = s(d);
  int bb[] = {n + a - 2 + a, m + (char)q - 2 + ac, f + ad, l + a - 3 + a,
                    k + (char)t - 8 + b, j + b - 2 + b, i - 1 + c,
                    h + p - 5 + p, 0, g + -e + -d};
  return aa(bb);
}
void ak() {
  ab(2, 2, 3, -2, 2);
  if (q())
    if (ab(2, 2, 3, 2, 2))
      ab(2, 2, 9, 1, 1);
}

Metadata

Metadata

Assignees

Labels

confirmedVerified by a second partycrashPrefer [crash-on-valid] or [crash-on-invalid]function-specializationipoInterprocedural optimizationsregression:20Regression in 20 release

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions