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.
This commit is contained in:
		
							parent
							
								
									c09b6ce975
								
							
						
					
					
						commit
						6775c7cb3a
					
				
					 1 changed files with 14 additions and 9 deletions
				
			
		
							
								
								
									
										9
									
								
								tccgen.c
									
										
									
									
									
								
							
							
						
						
									
										9
									
								
								tccgen.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -5111,8 +5111,13 @@ static void block(int *bsym, int *csym, int is_expr)
 | 
			
		|||
                    else
 | 
			
		||||
                        r = RC_IRET;
 | 
			
		||||
 | 
			
		||||
                    for (;;) {
 | 
			
		||||
                    if (ret_nregs == 1)
 | 
			
		||||
                        gv(r);
 | 
			
		||||
                    else {
 | 
			
		||||
                        for (;;) {
 | 
			
		||||
                            vdup();
 | 
			
		||||
                            gv(r);
 | 
			
		||||
                            vpop();
 | 
			
		||||
                            if (--ret_nregs == 0)
 | 
			
		||||
                              break;
 | 
			
		||||
                            /* We assume that when a structure is returned in multiple
 | 
			
		||||
| 
						 | 
				
			
			@ -5120,7 +5125,7 @@ static void block(int *bsym, int *csym, int is_expr)
 | 
			
		|||
                               suite s(n) = 2^n */
 | 
			
		||||
                            r <<= 1;
 | 
			
		||||
                            vtop->c.i += regsize;
 | 
			
		||||
                        vtop->r = VT_LOCAL | VT_LVAL;
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            } else if (is_float(func_vt.t)) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue