I’m researching how different ABIs work in relation to implementing tail calls in the Rust compiler. One thing that I’m currently interested in is if there are ABIs which prohibit the callee from modifying the arguments passed to it by-ref/by-stack.
I tried reading through various ABI specifications, but found them incredibly confusing and hard to find the information I’m interested in…
I did some experimentation using the following code:
typedef struct {
uint64_t a;
uint64_t b;
uint64_t c;
uint64_t d;
} Big;
void f(Big x);
void g(Big x) {
f(x);
f(x);
}
void h(Big x) {
x.a = 1;
f(x);
}
And for all ABIs I tried:
ghas to make a copy ofxsince the first call tofmight modify the argument passed to ithdoesn’t have to make a copy ofxsince it’s allowed to modify the argument it receives
But is this true for all ABIs (supported by llvm)?