[PATCH] D98602: [SCCP] Avoid modifying AdditionalUsers while iterating over it
Dimitry Andric via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 15 12:11:34 PDT 2021
dim added a comment.
Hm, I've reduced the test case to the following C++ source:
// clang -cc1 -triple amd64-- -S -O1 lastransform-min.cpp
int a(int, int);
int b(int, int, int);
int *c;
int d;
int h(int i) {
int e = 1;
for (; e < i;)
if (c)
if (c[0]) {
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
if (e + 3 >= i)
e += 3;
if (e >= i)
e++;
if (e + 2 >= i)
e += 2;
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
e++;
if (e >= i)
e++;
if (c) {
if (e >= i)
return 0;
} else if (d) {
if (e >= i)
e++;
if (e + 1 >= i)
e++;
} else if (e + 2 >= i)
c[e + 2];
} else if (b(0, 0, 0)) {
if (e + 3 >= i)
c[e + 3];
if (e + 3 >= i)
c[e + 3];
if (e + 3 >= i)
e += 3;
if (e >= i)
e++;
if (e + 1 >= i)
e++;
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
c[0];
} else if (b(0, 0, 0))
if (b(0, 0, 0)) {
if (e + 1 >= i)
e++;
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
c[e];
else if (i)
c[e];
if (e >= i)
return 0;
} else if (c) {
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
} else if (d) {
if (e + 1 >= i)
c[e + 1];
} else if (a(0, 0)) {
if (e + 1 >= i) {
c[e + 1];
return 0;
}
int f[e + 1];
} else if (c) {
if (e + 1 >= i)
c[e + 1];
} else if (b(0, 0, 0)) {
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
} else if (c) {
if (e + 1 >= i) {
c[e + 1];
return 0;
}
int g[e + 1];
} else if (d) {
if (e + 1 >= i)
c[e + 1];
} else if (a(0, 0)) {
if (e + 1 >= i)
c[e + 1];
} else if (c) {
if (e + 2 >= i)
e += 2;
} else if (b(0, 0, 0))
if (c) {
if (e + 3 >= i)
e += 3;
} else {
if (e + 4 >= i)
c[e + 4];
}
else if (c) {
if (e + 1 >= i)
c[e + 1];
else if (i)
c[e + 1];
} else if (b(0, 0, 0)) {
if (e + 2 >= i)
e += 2;
if (e >= i)
e++;
if (e >= i)
e++;
if (e >= i)
e++;
if (b(0, 0, 0)) {
if (e >= i)
c[e];
if (e >= i)
c[e];
else
c[e + 0];
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
c[e];
if (e >= i)
c[e];
else
c[e + 0];
if (e + 1 >= i)
c[e + 1];
} else if (a(0, 0)) {
if (e + 1 >= i)
c[e + 1];
} else if (a(0, 0)) {
if (e + 1 >= i)
c[e + 1];
} else if (a(0, 0)) {
if (e + 3 >= i)
c[e + 3];
} else if (a(0, 0)) {
if (e + 1 >= i)
e++;
} else if (a(0, 0)) {
if (e)
if (e >= i)
c[0];
} else if (a(0, 0)) {
if (e + 1 >= i)
e++;
} else if (e + 2 >= i)
c[e + 2];
} else if (b(0, 0, 0))
if (a(0, 0)) {
if (e + 1 >= i)
e++;
} else if (a(0, 0)) {
if (e + 1 >= i)
e++;
} else if (e + 1 >= i)
e++;
else {
if (i)
e++;
}
else if (b(0, 0, 0)) {
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
if (e + 1 >= i)
c[e + 1];
if (e + 2 >= i)
c[e + 2];
if (e + 2 >= i)
c[e + 2];
if (e + 1 >= i)
c[e + 1];
else {
0 >= i;
c[e + 1];
}
if (e + 1 >= i)
e++;
} else if (b(0, 0, 0)) {
if (e + 2 >= i)
c[e + 2];
else if (i)
c[e + 2];
if (e + 1 >= i)
c[e + 1];
} else if (b(0, 0, 0))
if (e + 1 >= i)
c[e + 1];
else if (i)
c[e + 1];
}
but I have not been able to change this into a `.ll` file that works in the context of `llvm/test/Transforms/SCCP`, where it's mostly `.ll` run through `opt -sccp` or `opt -ipsccp`.
I can't get `opt` to show invalid reads in valgrind though, these only show up when compiling the .cpp file with clang, as shown above in the comment.
Can anybody give me a clue on how to run `opt` so it performs the same optimization(s) as clang does?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98602/new/
https://reviews.llvm.org/D98602
More information about the llvm-commits
mailing list