[llvm] [X86] Recognize POP/ADD/SUB modifying rsp in getSPAdjust. (PR #114265)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 16 04:18:28 PST 2025
dyung wrote:
@daniel-zabawa sorry for the delay, but here is a reduced C++ program which demonstrates the issue we were seeing on our internal tests.
```c++
extern "C" {
void printf(char *);
void snprintf(char *, long...);
void atexit(void());
}
void a() { printf("{PASS}\n{END}\n\x1a\n"); }
__attribute__((constructor)) void b() { atexit(a); }
void c(char *, int, char *fmt...) {
__builtin_va_list args;
__builtin_va_start(args, fmt);
}
char d[1];
long e;
int main() {
struct f {
f() {
struct m {
m() {
for (long g = -10; g; ++g)
for (long h = -10; h != 10; ++h)
struct i {
long j;
i(long initial) {
char *k;
long l = initial, actual = __sync_lock_test_and_set_8(&l, j);
k = "";
snprintf(d, sizeof(d),
"%%s %%s0 expected %s/%s but got %s/%s", 0, 0, 0, 0,
0, "");
c("", 0, d, 0, "__sync_lock_test_and_set_8", initial, j,
actual, l);
}
} i(g);
struct i {
long j;
i(long initial) {
long actual = __sync_lock_test_and_set_8(&e, j);
c("", 0, "", j, 0, initial, actual, initial);
}
} i(0);
}
} m;
}
} f;
}
```
Compile with `clang -O2 -g -mavx repro.cpp` and run the resulting binary. A compiler built from the commit preceeding yours (a8a1e9033a902d961ad050a139b97ac0319b9e25) generates a binary that finishes quickly when run. When using a compiler built from your change (6fb7cdff3d90c565b87a253ff7dbd36319879111), the resulting binary gets stuck in an infinite loop. Like @bjope's example, debug info generation is required to hit the problem. Hope this helps.
https://github.com/llvm/llvm-project/pull/114265
More information about the llvm-commits
mailing list