Browse Source

+ tcalo_make_dead_strippable to indicate that a typed constant data block
should be dead-strippable; may imply the creation of a separate section
(on platforms that dead-strip data based on sections), but does not
require it
* replaced all existing tcalo_new_section uses with
tcalo_make_dead_strippable, as that is their meaning/purpose

git-svn-id: branches/hlcgllvm@30335 -

Jonas Maebe 10 years ago
parent
commit
5e1bb8e408
4 changed files with 23 additions and 12 deletions
  1. 16 5
      compiler/aasmcnst.pas
  2. 2 2
      compiler/ncgcon.pas
  3. 2 2
      compiler/ncgvmt.pas
  4. 3 3
      compiler/ngtcon.pas

+ 16 - 5
compiler/aasmcnst.pas

@@ -104,8 +104,13 @@ type
    ttcasmlistoption = (
    ttcasmlistoption = (
      { the tasmsymbol is a tasmlabel }
      { the tasmsymbol is a tasmlabel }
      tcalo_is_lab,
      tcalo_is_lab,
-     { start a new section }
-     tcalo_new_section
+     { start a new section (e.g., because we don't know the current section
+       type) }
+     tcalo_new_section,
+     { this symbol is the start of a block of data that should be
+       dead-stripable/smartlinkable; may imply starting a new section, but
+       not necessarily (depends on what the platform requirements are) }
+     tcalo_make_dead_strippable
    );
    );
    ttcasmlistoptions = set of ttcasmlistoption;
    ttcasmlistoptions = set of ttcasmlistoption;
 
 
@@ -669,11 +674,17 @@ implementation
        prelist:=tasmlist.create;
        prelist:=tasmlist.create;
        { only now add items based on the symbolname, because it may be
        { only now add items based on the symbolname, because it may be
          modified by the "section" specifier in case of a typed constant }
          modified by the "section" specifier in case of a typed constant }
-       if tcalo_new_section in options then
+       if tcalo_make_dead_strippable in options then
          begin
          begin
            maybe_new_object_file(prelist);
            maybe_new_object_file(prelist);
+           { we always need a new section here, since if we started a new
+             object file then we have to say what the section is, and otherwise
+             we need a new section because that's how the dead stripping works
+             (except on Darwin, but that will be addressed in a future commit) }
            new_section(prelist,section,secname,const_align(alignment));
            new_section(prelist,section,secname,const_align(alignment));
          end
          end
+       else if tcalo_new_section in options then
+         new_section(prelist,section,secname,const_align(alignment))
        else
        else
          prelist.concat(cai_align.Create(const_align(alignment)));
          prelist.concat(cai_align.Create(const_align(alignment)));
        if not(tcalo_is_lab in options) then
        if not(tcalo_is_lab in options) then
@@ -958,7 +969,7 @@ implementation
      begin
      begin
        options:=[tcalo_is_lab];
        options:=[tcalo_is_lab];
        if NewSection then
        if NewSection then
-         include(options,tcalo_new_section);
+         include(options,tcalo_make_dead_strippable);
        datatcb:=self.create(options);
        datatcb:=self.create(options);
        result:=datatcb.emit_string_const_common(st_ansistring,len,encoding,startlab);
        result:=datatcb.emit_string_const_common(st_ansistring,len,encoding,startlab);
 
 
@@ -985,7 +996,7 @@ implementation
        uniwidestrrecdef: trecorddef;
        uniwidestrrecdef: trecorddef;
        datatcb: ttai_typedconstbuilder;
        datatcb: ttai_typedconstbuilder;
      begin
      begin
-       datatcb:=self.create([tcalo_is_lab,tcalo_new_section]);
+       datatcb:=self.create([tcalo_is_lab,tcalo_make_dead_strippable]);
        strlength:=getlengthwidestring(pcompilerwidestring(data));
        strlength:=getlengthwidestring(pcompilerwidestring(data));
        if winlike then
        if winlike then
          begin
          begin

+ 2 - 2
compiler/ncgcon.pas

@@ -360,7 +360,7 @@ implementation
                         begin
                         begin
                           current_asmdata.getdatalabel(lastlabel.lab);
                           current_asmdata.getdatalabel(lastlabel.lab);
 
 
-                          datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
+                          datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
                           { truncate strings larger than 255 chars }
                           { truncate strings larger than 255 chars }
                           if len>255 then
                           if len>255 then
                            l:=255
                            l:=255
@@ -384,7 +384,7 @@ implementation
                         begin
                         begin
                           current_asmdata.getdatalabel(lastlabel.lab);
                           current_asmdata.getdatalabel(lastlabel.lab);
 
 
-                          datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
+                          datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
                           { include terminating zero }
                           { include terminating zero }
                           getmem(pc,len+1);
                           getmem(pc,len+1);
                           move(value_str^,pc[0],len);
                           move(value_str^,pc[0],len);

+ 2 - 2
compiler/ncgvmt.pas

@@ -894,7 +894,7 @@ implementation
       if assigned(_class.iidguid) then
       if assigned(_class.iidguid) then
         begin
         begin
           s:=make_mangledname('IID',_class.owner,_class.objname^);
           s:=make_mangledname('IID',_class.owner,_class.objname^);
-          tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
+          tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
           tcb.emit_guid_const(_class.iidguid^);
           tcb.emit_guid_const(_class.iidguid^);
           list.concatlist(tcb.get_final_asmlist(
           list.concatlist(tcb.get_final_asmlist(
             current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
             current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
@@ -905,7 +905,7 @@ implementation
           tcb.free;
           tcb.free;
         end;
         end;
       s:=make_mangledname('IIDSTR',_class.owner,_class.objname^);
       s:=make_mangledname('IIDSTR',_class.owner,_class.objname^);
-      tcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
+      tcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
       def:=tcb.emit_shortstring_const(_class.iidstr^);
       def:=tcb.emit_shortstring_const(_class.iidstr^);
       list.concatlist(tcb.get_final_asmlist(
       list.concatlist(tcb.get_final_asmlist(
         current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
         current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),

+ 3 - 3
compiler/ngtcon.pas

@@ -441,7 +441,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
       begin
       begin
         inherited;
         inherited;
         fsym:=sym;
         fsym:=sym;
-        ftcb:=ctai_typedconstbuilder.create([tcalo_new_section]);
+        ftcb:=ctai_typedconstbuilder.create([tcalo_make_dead_strippable]);
         fdatalist:=tasmlist.create;
         fdatalist:=tasmlist.create;
         curoffset:=0;
         curoffset:=0;
       end;
       end;
@@ -804,7 +804,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
             begin
             begin
               { create a tcb for the string data (it's placed in a separate
               { create a tcb for the string data (it's placed in a separate
                 asmlist) }
                 asmlist) }
-              datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
+              datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
               current_asmdata.getlabel(ll,alt_data);
               current_asmdata.getlabel(ll,alt_data);
               if node.nodetype=stringconstn then
               if node.nodetype=stringconstn then
                 varalign:=size_2_align(tstringconstnode(node).len)
                 varalign:=size_2_align(tstringconstnode(node).len)
@@ -865,7 +865,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                    begin
                    begin
                      { create a tcb for the string data (it's placed in a separate
                      { create a tcb for the string data (it's placed in a separate
                        asmlist) }
                        asmlist) }
-                     datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_new_section]);
+                     datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      { include terminating #0 }
                      { include terminating #0 }
                      datadef:=getarraydef(cwidechartype,tstringconstnode(node).len+1);
                      datadef:=getarraydef(cwidechartype,tstringconstnode(node).len+1);