[llvm-bugs] [Bug 37660] New: opt miscompiles with "opt -O3 -gvn-hoist -newgvn"
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Jun 2 07:50:41 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37660
Bug ID: 37660
Summary: opt miscompiles with "opt -O3 -gvn-hoist -newgvn"
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 20383
--> https://bugs.llvm.org/attachment.cgi?id=20383&action=edit
Reproducer.
Opt produces incorrect code with opt -O3 -gvn-hoist -newgvn.
opt-bisect-limit points to Global Value Numbering on function
Reproducer:
> cat func.c
extern const long long c;
extern long long d;
extern int e;
extern long long *b;
extern long long f;
long long int foo() {
if (d) {
if (e - c)
;
else
f = (int)(307814 + c);
}
*b = (int)(c);
return *b;
}
>$ cat driver.c
#include <stdio.h>
long long a;
long long *b = &a;
const long long c = 1030468986380352444LL;
long long d;
int e;
long long f;
long long foo();
int main() {
printf("%llu\n", foo());
}
Error:
>$ clang driver.c func.c
>$ ./a.out
1564605372
>$ clang -O3 -Xclang -disable-llvm-optzns -emit-llvm -c -o func.bc func.c
>$ opt -O3 -o func.ll func.bc -gvn-hoist -newgvn
>$ clang -c -o func.o func.ll
>$ clang func.o driver.c
>$ ./a.out
1030468986380352444
LLVM version:
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/638f78b5/attachment.html>
More information about the llvm-bugs
mailing list