[llvm-bugs] [Bug 37662] New: opt miscompiles with "opt -O3 -flattencfg"

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jun 2 08:54:20 PDT 2018


            Bug ID: 37662
           Summary: opt miscompiles with "opt -O3 -flattencfg"
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: Vsevolod.Livinskij at frtk.ru
                CC: llvm-bugs at lists.llvm.org

Created attachment 20384
  --> https://bugs.llvm.org/attachment.cgi?id=20384&action=edit

Opt produces incorrect code with opt -O3 -o func.ll func.bc -flattencfg
opt-bisect-limit points to Simplify the CFG on function

>$ cat func.cpp
extern unsigned short a, c;
extern short *d;
extern unsigned short *e;
extern short b;
void foo() {
  e = &a;
  c = 0;
  if (*d)
    e = &c;
  if (b)
    e = &c;

>$ cat driver.cpp
#include <stdio.h>

short a = 6, b = 6;
unsigned short c;
unsigned short *d = &c;
short *e;

void foo();

int main() {
  printf("%hd\n", *(e));

>$ clang++ driver.cpp func.cpp
>$ ./a.out
>$ clang++ -O3 -Xclang -disable-llvm-optzns -emit-llvm -c -o func.bc func.cpp
>$ opt -O3 -o func.ll func.bc -flattencfg
>$ clang++ -c -o func.o func.ll
>$ clang++ driver.cpp func.o
>$ ./a.out

LLVM version:
>$ clang++ -v
clang version 7.0.0 (trunk 333377)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /llvm/bin-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180602/ae9acbed/attachment.html>

More information about the llvm-bugs mailing list