Browse Source

* only specify the "unnamed_addr" flag for initialised data if its symbol is
a tasmlabel, since otherwise the address needs to remain unique

git-svn-id: trunk@31654 -

Jonas Maebe 10 years ago
parent
commit
2741b37f28
3 changed files with 10 additions and 3 deletions
  1. 2 1
      compiler/llvm/aasmllvm.pas
  2. 3 1
      compiler/llvm/agllvm.pas
  3. 5 1
      compiler/llvm/nllvmtcon.pas

+ 2 - 1
compiler/llvm/aasmllvm.pas

@@ -150,7 +150,8 @@ interface
     taillvmdeclflag =
     taillvmdeclflag =
     (
     (
       ldf_definition,   { definition as opposed to (an external) declaration }
       ldf_definition,   { definition as opposed to (an external) declaration }
-      ldf_tls           { tls definition }
+      ldf_tls,          { tls definition }
+      ldf_unnamed_addr  { address doesn't matter, only content }
     );
     );
     taillvmdeclflags = set of taillvmdeclflag;
     taillvmdeclflags = set of taillvmdeclflag;
 
 

+ 3 - 1
compiler/llvm/agllvm.pas

@@ -948,10 +948,12 @@ implementation
                   end;
                   end;
                   if (ldf_tls in taillvmdecl(hp).flags) then
                   if (ldf_tls in taillvmdecl(hp).flags) then
                     writer.AsmWrite('thread_local ');
                     writer.AsmWrite('thread_local ');
+                  if ldf_unnamed_addr in taillvmdecl(hp).flags then
+                    writer.AsmWrite('unnamed_addr ');
                   { todo: handle more different section types (mainly
                   { todo: handle more different section types (mainly
                       Objective-C }
                       Objective-C }
                   if taillvmdecl(hp).sec in [sec_rodata,sec_rodata_norel] then
                   if taillvmdecl(hp).sec in [sec_rodata,sec_rodata_norel] then
-                    writer.AsmWrite('unnamed_addr constant ')
+                    writer.AsmWrite('constant ')
                   else
                   else
                     writer.AsmWrite('global ');
                     writer.AsmWrite('global ');
                   if not assigned(taillvmdecl(hp).initdata) then
                   if not assigned(taillvmdecl(hp).initdata) then

+ 5 - 1
compiler/llvm/nllvmtcon.pas

@@ -160,6 +160,7 @@ implementation
   procedure tllvmtai_typedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions);
   procedure tllvmtai_typedconstbuilder.finalize_asmlist(sym: tasmsymbol; def: tdef; section: TAsmSectiontype; const secname: TSymStr; alignment: shortint; const options: ttcasmlistoptions);
     var
     var
       newasmlist: tasmlist;
       newasmlist: tasmlist;
+      decl: taillvmdecl;
     begin
     begin
       { todo }
       { todo }
       if section = sec_user then
       if section = sec_user then
@@ -167,7 +168,10 @@ implementation
       newasmlist:=tasmlist.create;
       newasmlist:=tasmlist.create;
       { llvm declaration with as initialisation data all the elements from the
       { llvm declaration with as initialisation data all the elements from the
         original asmlist }
         original asmlist }
-      newasmlist.concat(taillvmdecl.createdef(sym,def,fasmlist,section,alignment));
+      decl:=taillvmdecl.createdef(sym,def,fasmlist,section,alignment);
+      if tcalo_is_lab in options then
+        include(decl.flags,ldf_unnamed_addr);
+      newasmlist.concat(decl);
       fasmlist:=newasmlist;
       fasmlist:=newasmlist;
     end;
     end;