Browse Source

* use the def of the paraloc rather than the parasym's vardef in
gen_load_para_value(), as this may be different depending on
the calling conventions
* adapt llvm's gen_load_cgpara_loc() to use this passed def rather
than hardcoding the para's def (although these will normally match)

git-svn-id: trunk@31050 -

Jonas Maebe 10 năm trước cách đây
mục cha
commit
1019a6b090
2 tập tin đã thay đổi với 9 bổ sung7 xóa
  1. 3 1
      compiler/hlcgobj.pas
  2. 6 6
      compiler/llvm/hlcgllvm.pas

+ 3 - 1
compiler/hlcgobj.pas

@@ -4863,7 +4863,9 @@ implementation
       for i:=0 to current_procinfo.procdef.paras.count-1 do
         begin
           currpara:=tparavarsym(current_procinfo.procdef.paras[i]);
-          gen_load_cgpara_loc(list,currpara.vardef,currpara.paraloc[calleeside],currpara.initialloc,paramanager.param_use_paraloc(currpara.paraloc[calleeside]));
+          { don't use currpara.vardef, as this will be wrong in case of
+            call-by-reference parameters (it won't contain the pointer) }
+          gen_load_cgpara_loc(list,currpara.paraloc[calleeside].def,currpara.paraloc[calleeside],currpara.initialloc,paramanager.param_use_paraloc(currpara.paraloc[calleeside]));
         end;
 
       { generate copies of call by value parameters, must be done before

+ 6 - 6
compiler/llvm/hlcgllvm.pas

@@ -1382,26 +1382,26 @@ implementation
                 case def2regtyp(llvmparadef) of
                   R_INTREGISTER,
                   R_ADDRESSREGISTER:
-                    a_load_loc_ref(list,llvmparadef,para.def,hloc,destloc.reference);
+                    a_load_loc_ref(list,llvmparadef,vardef,hloc,destloc.reference);
                   R_FPUREGISTER:
-                    a_loadfpu_loc_ref(list,llvmparadef,para.def,hloc,destloc.reference);
+                    a_loadfpu_loc_ref(list,llvmparadef,vardef,hloc,destloc.reference);
                   R_MMREGISTER:
-                    a_loadmm_loc_ref(list,llvmparadef,para.def,hloc,destloc.reference,nil);
+                    a_loadmm_loc_ref(list,llvmparadef,vardef,hloc,destloc.reference,nil);
                   else
                     internalerror(2014080801);
                   end;
               end;
             LOC_REGISTER:
               begin
-                a_load_loc_reg(list,llvmparadef,para.def,hloc,destloc.register);
+                a_load_loc_reg(list,llvmparadef,vardef,hloc,destloc.register);
               end;
             LOC_FPUREGISTER:
               begin
-                a_loadfpu_loc_reg(list,llvmparadef,para.def,hloc,destloc.register);
+                a_loadfpu_loc_reg(list,llvmparadef,vardef,hloc,destloc.register);
               end;
             LOC_MMREGISTER:
               begin
-                a_loadmm_loc_reg(list,llvmparadef,para.def,hloc,destloc.register,nil);
+                a_loadmm_loc_reg(list,llvmparadef,vardef,hloc,destloc.register,nil);
               end;
             { TODO other possible locations }
             else