History

tccgen.c: fix multi-register structure return when not on stack

We need to preserve the type of the pointer to the structure, f.ex. when a global structure is returned. This is not a perfect solution. Registers loaded in the first iteration might be overwritten in a following iteration as the register is no longer on vtop. This is not a problem for ARM32 as gfunc_sret returns a maximum of 1 in the integer case.

Daniel Glöckner committed 10 years ago

Commit 6775c7c1 parent c09b6ce1 file · +14 −9Browse files

Unified · Split

tccgen.c+14−9
@@ -5111,16 +5111,21 @@ static void block(int *bsym, int *csym, int is_expr) · 5110 unmodified lines
51115111 else
51125112 r = RC_IRET;
51135113
5114− for (;;) {
5114+ if (ret_nregs == 1)
51155115 gv(r);
5116− if (--ret_nregs == 0)
5117− break;
5118− /* We assume that when a structure is returned in multiple
5119− registers, their classes are consecutive values of the
5120− suite s(n) = 2^n */
5121− r <<= 1;
5122− vtop->c.i += regsize;
5123− vtop->r = VT_LOCAL | VT_LVAL;
5116+ else {
5117+ for (;;) {
5118+ vdup();
5119+ gv(r);
5120+ vpop();
5121+ if (--ret_nregs == 0)
5122+ break;
5123+ /* We assume that when a structure is returned in multiple
5124+ registers, their classes are consecutive values of the
5125+ suite s(n) = 2^n */
5126+ r <<= 1;
5127+ vtop->c.i += regsize;
5128+ }
51245129 }
51255130 }
51265131 } else if (is_float(func_vt.t)) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t