Selaa lähdekoodia

* only free the temp holding the function result after we've loaded it into
the function return register (so we won't load from an already freed
temp once we emit lifetime info for temps on LLVM)

git-svn-id: trunk@40501 -

Jonas Maebe 6 vuotta sitten
vanhempi
commit
3b7efb5123
2 muutettua tiedostoa jossa 8 lisäystä ja 2 poistoa
  1. 3 1
      compiler/hlcgobj.pas
  2. 5 1
      compiler/ncgutil.pas

+ 3 - 1
compiler/hlcgobj.pas

@@ -5216,7 +5216,9 @@ implementation
             gen_load_loc_function_result(list,retdef,ressym.localloc);
             gen_load_loc_function_result(list,retdef,ressym.localloc);
         end
         end
       else
       else
-        gen_load_uninitialized_function_result(list,current_procinfo.procdef,retdef,current_procinfo.procdef.funcretloc[calleeside])
+        gen_load_uninitialized_function_result(list,current_procinfo.procdef,retdef,current_procinfo.procdef.funcretloc[calleeside]);
+      if ressym.localloc.loc=LOC_REFERENCE then
+        tg.UnGetLocal(list,ressym.localloc.reference);
     end;
     end;
 
 
   procedure thlcgobj.gen_stack_check_size_para(list: TAsmList);
   procedure thlcgobj.gen_stack_check_size_para(list: TAsmList);

+ 5 - 1
compiler/ncgutil.pas

@@ -1816,7 +1816,11 @@ implementation
                           cg.a_reg_sync(list,localloc.register);
                           cg.a_reg_sync(list,localloc.register);
                       LOC_REFERENCE :
                       LOC_REFERENCE :
                         begin
                         begin
-                          if typ in [localvarsym,paravarsym] then
+                          { can't free the result, because we load it after
+                            this call into the function result location
+                            (gets freed in thlcgobj.gen_load_return_value() }
+                          if (typ in [localvarsym,paravarsym]) and
+                             (([vo_is_funcret,vo_is_result]*varoptions)=[]) then
                             tg.Ungetlocal(list,localloc.reference);
                             tg.Ungetlocal(list,localloc.reference);
                         end;
                         end;
                     end;
                     end;