浏览代码

* 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 年之前
父节点
当前提交
3b7efb5123
共有 2 个文件被更改,包括 8 次插入2 次删除
  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);
         end
       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;
 
   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);
                       LOC_REFERENCE :
                         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);
                         end;
                     end;