Skip to content

wrong code at -Os and above with -mllvm -enable-constraint-elimination #54224

@zhendongsu

Description

@zhendongsu
[514] % clangtk -v
clang version 15.0.0 (https://github.com/llvm/llvm-project.git 30f1cef86b56e0bae5b78ceed05a7fdbad4959a9)
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
[515] % 
[515] % clangtk -Os small.c; ./a.out
[516] % 
[516] % clangtk -Os -mllvm -enable-constraint-elimination small.c
[517] % ./a.out
Aborted
[518] % 
[518] % cat small.c
int a;
unsigned c ;
int main() {
  unsigned char e;
  int f = 1;
  a--;
 L:
  e = ~c;
  if (!f)
    while (1)
      ;
  c = ~(e - ~0x30);
  if (f > c)
    while (1)
      ;
  if (c > 4294967000)
    __builtin_abort ();
  int h = ~a;
  f = a;
  if (h)
    goto L;
  return 0;
}

@fhahn

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions