浏览代码

* when a function returns a value in a register, but normally that type
would never be put in that kind of register by the compiler, store
it to memory to avoid issues down the line
o fixes tcalext6 on darwin/i386

git-svn-id: trunk@46449 -

Jonas Maebe 5 年之前
父节点
当前提交
cc14f06677
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      compiler/ncgcal.pas

+ 12 - 0
compiler/ncgcal.pas

@@ -623,6 +623,18 @@ implementation
              assigned(funcretnode) then
             hlcg.gen_load_cgpara_loc(current_asmdata.CurrAsmList,realresdef,retloc,location,false);
 
+        if ((location.loc=LOC_REGISTER) and
+            not realresdef.is_intregable) or
+           ((location.loc in [LOC_FPUREGISTER,LOC_MMREGISTER]) and
+            (not realresdef.is_fpuregable or
+             ((location.loc=LOC_MMREGISTER)<>use_vectorfpu(realresdef)))) then
+          begin
+            hlcg.location_force_mem(current_asmdata.CurrAsmList,location,realresdef);
+            { may have been record returned in a floating point register (-> location.size
+              will be the size of the fpuregister instead of the int size of the record) }
+            location.size:=def_cgsize(realresdef);
+          end;
+
         { copy value to the final location if this was already provided to the
           callnode. This must be done after the call node, because the location can
           also be used as parameter and may not be finalized yet }