-
Notifications
You must be signed in to change notification settings - Fork 15.6k
Closed
llvm/llvm-project-release-prs
#701Labels
llvm:GVNGVN and NewGVN stages (Global value numbering)GVN and NewGVN stages (Global value numbering)miscompilationregression
Milestone
Description
Clang at -O2 emits the wrong code.
Bisected to 84bcfa0, which was committed by @weiguozhi
Compiler explorer: https://godbolt.org/z/rW9chv3hj
% cat a.c
int printf(const char *, ...);
int a, d, e, f, h, j, t, q;
char c, s;
signed char g;
signed char *i = &g;
int *k = &h;
int **l = &k;
signed char **m = &i;
signed char ***r = &m;
static signed char ****n = &r;
long o, u;
int p[7];
void v() {
t = 0;
for (; t < 9; t++) {
q = 0;
for (; c + q; q++)
p[q] = 3;
}
}
void w(long x, char y) {
for (; o;) {
v();
s = x;
u = y;
}
}
int main() {
for (; d <= 3; d++) {
e = 0;
for (; e <= 3; e++) {
int *b;
f = 3;
for (; f; f--) {
w(****n, **l);
b = &j;
*b = **l + ***r;
}
}
}
for (; **l;)
;
printf("%X\n", a);
}
%
% clang -O0 a.c && ./a.out
0
% clang -O2 a.c && ./a.out
Segmentation fault
%Metadata
Metadata
Assignees
Labels
llvm:GVNGVN and NewGVN stages (Global value numbering)GVN and NewGVN stages (Global value numbering)miscompilationregression
Type
Projects
Status
Done