[llvm-bugs] [Bug 37791] New: opt miscompiles with "opt -O3 -gvn-hoist"
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jun 13 09:33:50 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37791
Bug ID: 37791
Summary: opt miscompiles with "opt -O3 -gvn-hoist"
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 20423
--> https://bugs.llvm.org/attachment.cgi?id=20423&action=edit
Reproducer.
Opt produces incorrect code that crashes with FPE at runtime.
Opt-bisect-limit points to " Early GVN Hoisting of Expressions"
Reproducer is relatively large, but I can't reduce it further.
Reproducer (also in attachement):
>$ cat func.cpp
#include "init.h"
void tf_0_foo() {
if (tf_0_var_20 + tf_0_array_1.at(5).member_2_4 % tf_0_array_2[3].member_2_1)
tf_0_var_106 = 0;
tf_0_var_1274 =
(tf_0_array_1.at(1).member_2_1 | tf_0_array_2[1].member_2_1 - 50874) /
unsigned(~tf_0_var_10 + 3 || tf_0_array_2[3].member_2_1 ||
tf_0_var_44) -
(~tf_0_var_10 + 3 || tf_0_array_2[3].member_2_1 || tf_0_var_44) -
tf_0_var_44 + tf_0_array_1.at(5).member_2_4;
tf_0_var_1276 =
((tf_0_array_1.at(1).member_2_1 | tf_0_array_2[1].member_2_1 - 50874) /
unsigned(~tf_0_var_10 + 3 || tf_0_array_2[3].member_2_1 ||
tf_0_var_44) -
(tf_0_array_1.at(1).member_2_1 |
tf_0_array_2[1].member_2_1 - 50874) /
unsigned(~tf_0_var_10 + 3 || tf_0_array_2[3].member_2_1 ||
tf_0_var_44) +
(tf_0_var_20 - 3) ==
50) /
(~tf_0_var_10 + 3 || tf_0_array_2[3].member_2_1 ||
tf_0_var_10 + tf_0_array_2[3].member_2_1);
}
>$ cat driver.cpp
#include <stdio.h>
#include "init.h"
const unsigned tf_0_var_10 = 6;
bool tf_0_var_20, tf_0_var_44, tf_0_var_106 ;
unsigned short tf_0_var_1274 ;
unsigned tf_0_var_1276 ;
std::vector<tf_0_struct_2> tf_0_array_1 {{} , {} , {} , {} , {} , {} };
std::vector<tf_0_struct_2> tf_0_array_2 {{} , {} , {} , {true} };
void tf_0_foo ();
int main () {
tf_0_foo ();
}
>$ cat init.h
#include <vector>
extern const unsigned tf_0_var_10;
extern bool tf_0_var_20;
extern bool tf_0_var_44;
extern bool tf_0_var_106;
extern unsigned short tf_0_var_1274;
extern unsigned tf_0_var_1276;
struct tf_0_struct_2 {
bool member_2_1;
int member_2_4;
};
extern std::vector<tf_0_struct_2> tf_0_array_1;
extern std::vector<tf_0_struct_2> tf_0_array_2;
Error:
>$ clang++ -O3 -Xclang -disable-llvm-optzns -emit-llvm -c -o func.bc func.cpp
>$ opt -O3 -o func.ll func.bc -gvn-hoist
>$ clang++ -c -o func.o func.ll
>$ clang++ driver.cpp func.o
>$ ./a.out
Floating point exception (core dumped)
LLVM version:
clang version 7.0.0 (trunk 334571) (llvm/trunk 334570)
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/20180613/31a72c45/attachment.html>
More information about the llvm-bugs
mailing list