ソースを参照

+ vectorized dead-strippable section support for LLVM
o individual elements are not (yet) dead-strippable on LLVM though,
there doesn't seem to be a way to encode the necessary information
in LLVM (so e.g. all resource strings from a unit are currently
always linked in if at least one is referenced)

git-svn-id: trunk@32802 -

Jonas Maebe 9 年 前
コミット
81381cfbb4
2 ファイル変更26 行追加3 行削除
  1. 2 1
      compiler/llvm/aasmllvm.pas
  2. 24 2
      compiler/llvm/nllvmtcon.pas

+ 2 - 1
compiler/llvm/aasmllvm.pas

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

+ 24 - 2
compiler/llvm/nllvmtcon.pas

@@ -28,7 +28,7 @@ interface
   uses
     cclasses,constexp,globtype,
     aasmbase,aasmtai,aasmcnst,aasmllvm,
-    symconst,symtype,symdef,symsym,
+    symconst,symbase,symtype,symdef,symsym,
     ngtcon;
 
   type
@@ -111,6 +111,8 @@ interface
       procedure queue_emit_asmsym(sym: tasmsymbol; def: tdef); override;
       procedure queue_emit_ordconst(value: int64; def: tdef); override;
 
+      class function get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; out secname: TSymStr): boolean; override;
+
       function emit_placeholder(def: tdef): ttypedconstplaceholder; override;
 
       class function get_string_symofs(typ: tstringtype; winlikewidestring: boolean): pint; override;
@@ -123,7 +125,7 @@ implementation
     verbose,systems,
     aasmdata,
     cpubase,cpuinfo,llvmbase,
-    symbase,symtable,llvmdef,defutil,defcmp;
+    symtable,llvmdef,defutil,defcmp;
 
   { tllvmaggregateinformation }
 
@@ -190,6 +192,10 @@ implementation
         decl.setsecname(secname);
       if tcalo_is_lab in options then
         include(decl.flags,ldf_unnamed_addr);
+      if ([tcalo_vectorized_dead_strip_start,
+           tcalo_vectorized_dead_strip_item,
+           tcalo_vectorized_dead_strip_end]*options)<>[] then
+        include(decl.flags,ldf_vectorized);
       { TODO: tcalo_no_dead_strip: add to @llvm.user meta-variable }
       newasmlist.concat(decl);
       fasmlist:=newasmlist;
@@ -726,6 +732,22 @@ implementation
     end;
 
 
+  class function tllvmtai_typedconstbuilder.get_vectorized_dead_strip_custom_section_name(const basename: TSymStr; st: tsymtable; out secname: TSymStr): boolean;
+    begin
+      result:=inherited;
+      if result then
+        exit;
+      { put all of the resource strings in a single section: it doesn't hurt,
+        and this avoids problems with Darwin/mach-o's limitation of 255
+        sections }
+      secname:=basename;
+      { Darwin requires specifying a segment name too }
+      if target_info.system in systems_darwin then
+        secname:='__DATA,'+secname;
+      result:=true;
+    end;
+
+
   function tllvmtai_typedconstbuilder.emit_placeholder(def: tdef): ttypedconstplaceholder;
     var
       pos: longint;