| Issue |
66216
|
| Summary |
[WebAssembly] Incorrect code generated after enabling tail-call
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
slavek-kucera
|
I've recently encountered a problem while compiling for the WebAssembly target after enabling a tail-call optimization (`-mtail-call`).
I believe I've managed to reproduce the issue with the following code:
```
struct X {
char a[124];
int b;
};
const X global = {{}, 5};
int __attribute__((noinline)) g(X x, X) {
volatile int i = 0;
return x.b;
}
int f(X x) {
return g(x, global);
}
```
Commenting out the volatile variable `i` in the `g` function changes the return value of the `f` function.
My understanding is that the __stack_pointer adjustment at the end of `f` leave the prepared arguments below the stack pointer address where they are overwritten by the store in the `g` function.
https://godbolt.org/z/dvMG9xde9
The code seems to be generated this way since release 15 (https://godbolt.org/z/x4TY57861)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs