Răsfoiți Sursa

* initialise all register temps with "undef" for llvm, so that llvm knows
they exist even if we try to read them before writing to them (e.g.
because they represent the uninitialised function result of an
inlined function)

git-svn-id: trunk@32465 -

Jonas Maebe 9 ani în urmă
părinte
comite
4f287207cd
3 a modificat fișierele cu 70 adăugiri și 2 ștergeri
  1. 1 0
      .gitattributes
  2. 2 2
      compiler/llvm/llvmnode.pas
  3. 67 0
      compiler/llvm/nllvmbas.pas

+ 1 - 0
.gitattributes

@@ -338,6 +338,7 @@ compiler/llvm/llvmsym.pas svneol=native#text/plain
 compiler/llvm/llvmtarg.pas svneol=native#text/plain
 compiler/llvm/llvmtype.pas svneol=native#text/plain
 compiler/llvm/nllvmadd.pas svneol=native#text/plain
+compiler/llvm/nllvmbas.pas svneol=native#text/plain
 compiler/llvm/nllvmcal.pas svneol=native#text/plain
 compiler/llvm/nllvmcnv.pas svneol=native#text/plain
 compiler/llvm/nllvmcon.pas svneol=native#text/plain

+ 2 - 2
compiler/llvm/llvmnode.pas

@@ -37,8 +37,8 @@ implementation
     ncgbas,ncgflw,ncgcnv,ncgld,ncgmem,ncgcon,ncgset,
     ncgadd,ncgcal,ncgmat,ncginl,
     tgllvm,hlcgllvm,
-    nllvmadd,nllvmcal,nllvmcnv,nllvmcon,nllvminl,nllvmld,nllvmmat,nllvmmem,
-    nllvmtcon,nllvmutil,
+    nllvmadd,nllvmbas,nllvmcal,nllvmcnv,nllvmcon,nllvminl,nllvmld,nllvmmat,
+    nllvmmem,nllvmtcon,nllvmutil,
     llvmpara,
     symllvm;
 

+ 67 - 0
compiler/llvm/nllvmbas.pas

@@ -0,0 +1,67 @@
+{
+    Copyright (c) 2015 by Jonas Maebe
+
+    This unit implements llvm support for some basic nodes
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ ****************************************************************************
+}
+unit nllvmbas;
+
+{$i fpcdefs.inc}
+
+interface
+
+    uses
+       nbas,ncgbas;
+
+    type
+       tllvmtempcreatenode = class(tcgtempcreatenode)
+          procedure pass_generate_code;override;
+       end;
+
+  implementation
+
+    uses
+      aasmdata,
+      cgbase,cgutils,
+      llvmbase,aasmllvm
+      ;
+
+{*****************************************************************************
+                          TTEMPCREATENODE
+*****************************************************************************}
+
+    procedure tllvmtempcreatenode.pass_generate_code;
+      begin
+        inherited;
+
+        { if a temp is in a register and we never assign anything to it (e.g.
+          because it's the register for an inlined function result that never
+          gets assigned a value), then llvm will be confused the first time
+          we try to read from it (since it's never been defined) -> always
+          immediately assign undef to such registers }
+        if tempinfo^.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_FPUREGISTER,
+             LOC_CFPUREGISTER,LOC_MMREGISTER,LOC_CMMREGISTER] then
+          current_asmdata.CurrAsmList.concat(
+            taillvm.op_reg_size_undef(la_bitcast,tempinfo^.location.register,tempinfo^.typedef)
+          );
+      end;
+
+
+begin
+   ctempcreatenode:=tllvmtempcreatenode;
+end.