Problem with callstack/frame-index

Hello!

I’m trying to get stack-passed arguments working on my back-end, and I’ve run into an issue I can’t resolve.

I got the code working to the point that function F1 can call F2 with 5+ arguments fine (we pass 4 in registers). The problem is if F2 then calls another function F3 with 5+ args, then all reading of the stack/call frame is off, the address doesn’t get compensated for the difference in stack-depth. When I compile the same code with the MSP430 back end I get something like this (pseudo-code):
f1: sub #4, sp
move arg1, 0(sp)
move arg2, 2(sp)
…fix registerargs…
call f2

f2:
sub #4, sp
move 6(sp), arg1
move 8(sp), arg2
…fix args call f3…

The important bit in that code is the 6/8 in F2. When I compile the same code with our back-end, the offsets are 0/2, which is off by 4. Structurally our solution mimics MSP430, and I thought I was sure we’d gotten all the relevant parts copied and adjusted, but I can’t seem to find a cure for this offset issue! Any help greatly appreciated!

//Per