| Issue |
237915
|
| Summary |
preserve_all/preserve_most introduces wrong values at tailcalls
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
chriku
|
Doing tailcalls (`[[clang::musttail]]`) with `clang::preserve_all` on x86 results in the content of the arguments being changed.
With
```
#include <cstdint>
#include <iostream>
[[clang::preserve_all, clang::noinline]] void f(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
std::cout << a << " " << b << " " << c << " " << d << std::endl;
}
[[clang::preserve_all, clang::noinline]] void g(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
[[clang::musttail]] return f(a, b, 8192, d);
}
int main() { g(1024, 1025, 1026, 1027); }
```
I expect to see `1024 1025 8192 1027` but get `1024 1025 1026 1027`.
Removeing the calling convention or the `clang::musttail` results in it working
Under unknown circumstances (before doing the minimal reproducer) I have also seen the values being changed to random stuff, which usually look like pointers, so I would assume stack content (?).
Godbolt: https://godbolt.org/z/sMhq7b8hv
Related, but not duplicate:
* #210756 it also happens with `-O0`, so it doesn't feel like an optimization issue
* #204564 and #236674 I am not on AArch64 (yet)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs