Skip to content

wrong code at -O1 and above on x86_64-linux-gnu #124275

@zhendongsu

Description

@zhendongsu

It appears to be a recent regression from 19.1.0.

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

[548] % clangtk -v
clang version 20.0.0git (https://github.com/llvm/llvm-project.git ddd2f57b29661f21308eec0400fa92a6d075b0c6)
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
[549] % 
[549] % clangtk -O1 small.c
[550] % ./a.out
Aborted
[551] % 
[551] % cat small.c
int printf(const char *, ...);
unsigned a;
int b, c = 1;
int main() {
  int d;
  a = -1;
  if (a < 1)
    goto e;
  d = c;
  if (d) {
  e:;
  }
  if (!d)
    __builtin_abort();
  if (b)
    goto e;
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    llvm:analysisIncludes value tracking, cost tables and constant foldingmiscompilation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions