+ 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 -
This commit is contained in:
Jonas Maebe 2015-03-27 21:25:30 +00:00
parent e924dbed90
commit 5e1bb8e408
4 changed files with 23 additions and 12 deletions

View File

@ -104,8 +104,13 @@ type
ttcasmlistoption = (
{ the tasmsymbol is a tasmlabel }
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;
@ -669,11 +674,17 @@ implementation
prelist:=tasmlist.create;
{ only now add items based on the symbolname, because it may be
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
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));
end
else if tcalo_new_section in options then
new_section(prelist,section,secname,const_align(alignment))
else
prelist.concat(cai_align.Create(const_align(alignment)));
if not(tcalo_is_lab in options) then
@ -958,7 +969,7 @@ implementation
begin
options:=[tcalo_is_lab];
if NewSection then
include(options,tcalo_new_section);
include(options,tcalo_make_dead_strippable);
datatcb:=self.create(options);
result:=datatcb.emit_string_const_common(st_ansistring,len,encoding,startlab);
@ -985,7 +996,7 @@ implementation
uniwidestrrecdef: trecorddef;
datatcb: ttai_typedconstbuilder;
begin
datatcb:=self.create([tcalo_is_lab,tcalo_new_section]);
datatcb:=self.create([tcalo_is_lab,tcalo_make_dead_strippable]);
strlength:=getlengthwidestring(pcompilerwidestring(data));
if winlike then
begin

View File

@ -360,7 +360,7 @@ implementation
begin
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 }
if len>255 then
l:=255
@ -384,7 +384,7 @@ implementation
begin
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 }
getmem(pc,len+1);
move(value_str^,pc[0],len);

View File

@ -894,7 +894,7 @@ implementation
if assigned(_class.iidguid) then
begin
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^);
list.concatlist(tcb.get_final_asmlist(
current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),
@ -905,7 +905,7 @@ implementation
tcb.free;
end;
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^);
list.concatlist(tcb.get_final_asmlist(
current_asmdata.DefineAsmSymbol(s,AB_GLOBAL,AT_DATA),

View File

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