Explorar el Código

* explicitly specify whether an llvm specification is a definition (= locally
defined) or a declaration (external symbol), instead of deriving it from
from the bind of the tasmsymbol. The reason is that with module-level
inline assembly, some locally implemented functions (in pure assembler)
won't have an LLVM IR body

git-svn-id: trunk@31629 -

Jonas Maebe hace 10 años
padre
commit
c80fb6a20e

+ 13 - 3
compiler/llvm/aasmllvm.pas

@@ -156,8 +156,10 @@ interface
       def: tdef;
       sec: TAsmSectiontype;
       alignment: shortint;
+      definition: boolean;
       tls: boolean;
-      constructor create(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
+      constructor createdecl(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
+      constructor createdef(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       constructor createtls(_namesym: tasmsymbol; _def: tdef; _alignment: shortint);
       destructor destroy; override;
     end;
@@ -184,7 +186,7 @@ uses
 
     { taillvmprocdecl }
 
-    constructor taillvmdecl.create(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
+    constructor taillvmdecl.createdecl(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
       begin
         inherited create;
         typ:=ait_llvmdecl;
@@ -194,12 +196,20 @@ uses
         sec:=_sec;
         alignment:=_alignment;
         _namesym.declared:=true;
+        definition:=false;
+      end;
+
+
+    constructor taillvmdecl.createdef(_namesym: tasmsymbol; _def: tdef; _initdata: tasmlist; _sec: tasmsectiontype; _alignment: shortint);
+      begin
+        createdecl(_namesym,_def,_initdata,_sec,_alignment);
+        definition:=true;
       end;
 
 
     constructor taillvmdecl.createtls(_namesym: tasmsymbol; _def: tdef; _alignment: shortint);
       begin
-        create(_namesym,_def,nil,sec_data,_alignment);
+        createdef(_namesym,_def,nil,sec_data,_alignment);
         tls:=true;
       end;
 

+ 1 - 1
compiler/llvm/agllvm.pas

@@ -873,7 +873,7 @@ implementation
             begin
               if taillvmdecl(hp).def.typ=procdef then
                 begin
-                  if taillvmdecl(hp).namesym.bind in [AB_EXTERNAL, AB_WEAK_EXTERNAL] then
+                  if not taillvmdecl(hp).definition then
                     begin
                       writer.AsmWrite('declare');
                       writer.AsmWriteln(llvmencodeproctype(tprocdef(taillvmdecl(hp).def), taillvmdecl(hp).namesym.name, lpd_decl));

+ 1 - 1
compiler/llvm/hlcgllvm.pas

@@ -1085,7 +1085,7 @@ implementation
             list.concat(taillvmalias.create(asmsym,item.str,current_procinfo.procdef,llv_default,lll_default));
           item:=TCmdStrListItem(item.next);
         end;
-      list.concat(taillvmdecl.create(asmsym,current_procinfo.procdef,nil,sec_code,current_procinfo.procdef.alignment));
+      list.concat(taillvmdecl.createdef(asmsym,current_procinfo.procdef,nil,sec_code,current_procinfo.procdef.alignment));
     end;
 
 

+ 1 - 1
compiler/llvm/llvmtype.pas

@@ -420,7 +420,7 @@ implementation
               sec:=sec_code
             else
               sec:=sec_data;
-            toplevellist.Concat(taillvmdecl.create(sym,def,nil,sec,def.alignment));
+            toplevellist.Concat(taillvmdecl.createdecl(sym,def,nil,sec,def.alignment));
             record_asmsym_def(sym,def,true);
           end;
       end;

+ 1 - 1
compiler/llvm/nllvmtcon.pas

@@ -133,7 +133,7 @@ implementation
       newasmlist:=tasmlist.create;
       { llvm declaration with as initialisation data all the elements from the
         original asmlist }
-      newasmlist.concat(taillvmdecl.create(sym,def,fasmlist,section,alignment));
+      newasmlist.concat(taillvmdecl.createdef(sym,def,fasmlist,section,alignment));
       fasmlist:=newasmlist;
     end;
 

+ 1 - 1
compiler/llvm/nllvmutil.pas

@@ -63,7 +63,7 @@ implementation
       else
         asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_LOCAL,AT_DATA);
       if not(vo_is_thread_var in sym.varoptions) then
-        list.concat(taillvmdecl.create(asmsym,sym.vardef,nil,sec_data,varalign))
+        list.concat(taillvmdecl.createdef(asmsym,sym.vardef,nil,sec_data,varalign))
       else
         list.concat(taillvmdecl.createtls(asmsym,sym.vardef,varalign))
     end;