File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1714,15 +1714,20 @@ static void gen_defun(Function *func) {
17141714 // Store ref-taken parameters to stack frame.
17151715 if (func -> params != NULL ) {
17161716 const Vector * params = func -> params ;
1717+ const Type * rettype = functype -> func .ret ;
1718+ int param_index = rettype -> kind != TY_VOID && !is_prim_type (rettype ) ? 1 : 0 ;
17171719 for (int i = 0 , param_count = params -> len ; i < param_count ; ++ i ) {
17181720 VarInfo * varinfo = params -> data [i ];
1719- if (!( varinfo -> storage & VS_REF_TAKEN ) || is_stack_param (varinfo -> type ))
1721+ if (is_stack_param (varinfo -> type ))
17201722 continue ;
1721- VReg * vreg = varinfo -> local .vreg ;
1722- gen_bpofs (vreg -> non_prim .offset );
1723- ADD_CODE (OP_LOCAL_GET );
1724- ADD_ULEB128 (vreg -> param_index );
1725- gen_store (varinfo -> type );
1723+ if (varinfo -> storage & VS_REF_TAKEN ) {
1724+ VReg * vreg = varinfo -> local .vreg ;
1725+ gen_bpofs (vreg -> non_prim .offset );
1726+ ADD_CODE (OP_LOCAL_GET );
1727+ ADD_ULEB128 (param_index );
1728+ gen_store (varinfo -> type );
1729+ }
1730+ ++ param_index ;
17261731 }
17271732 }
17281733
You can’t perform that action at this time.
0 commit comments