+ new tf_use_psabieh target flag to indicate a target uses PSABI/Dwarf EH

o use this flag to set the personality routine of a function if it uses
     exception handlinga
   o also define FPC_USE_PSABIEH if this target flag is set
   o set this target flag for darwin/x86-64 if the compiler is compiled with
     -dllvm

git-svn-id: branches/debug_eh@40415 -
This commit is contained in:
Jonas Maebe 2018-11-29 21:31:30 +00:00
parent fceb34dbd5
commit 2f8fcf7819
6 changed files with 32 additions and 12 deletions

View File

@ -38,7 +38,6 @@ interface
public
constructor create(aparent: tprocinfo); override;
destructor destroy; override;
procedure set_first_temp_offset; override;
procedure pushexceptlabel(lab: TAsmLabel);
procedure popexceptlabel(lab: TAsmLabel);
function CurrExceptLabel: TAsmLabel; inline;
@ -66,15 +65,6 @@ implementation
end;
procedure tllvmprocinfo.set_first_temp_offset;
begin
inherited;
if not(target_info.system in systems_windows) and
(([pi_uses_exceptions,pi_needs_implicit_finally]*flags)<>[]) then
procdef.personality:=search_system_proc('_FPC_EXCEPTION_PERSONALITY_DO_NOTHING_V0');
end;
procedure tllvmprocinfo.pushexceptlabel(lab: TAsmLabel);
begin
fexceptlabelstack.add(lab);

View File

@ -3157,6 +3157,12 @@ begin
else
undef_system_macro('FPC_SECTION_THREADVARS');
if (tf_use_psabieh in target_info.flags) then
if def then
def_system_macro('FPC_USE_PSABIEH')
else
undef_system_macro('FPC_USE_PSABIEH');
{ Code generation flags }
if (tf_pic_default in target_info.flags) then
if def then

View File

@ -178,6 +178,9 @@ unit procinfo;
procedure updatestackalignment(alignment: longint);
{ Specific actions after the code has been generated }
procedure postprocess_code; virtual;
{ set exception handling info }
procedure set_eh_info; virtual;
end;
tcprocinfo = class of tprocinfo;
@ -312,4 +315,9 @@ implementation
{ no action by default }
end;
procedure tprocinfo.set_eh_info;
begin
{ default code is in tcgprocinfo }
end;
end.

View File

@ -65,6 +65,7 @@ interface
procedure parse_body;
function has_assembler_child : boolean;
procedure set_eh_info; override;
end;
@ -1126,6 +1127,16 @@ implementation
end;
end;
procedure tcgprocinfo.set_eh_info;
begin
inherited;
if (tf_use_psabieh in target_info.flags) and
((pi_uses_exceptions in flags) or
((cs_implicit_exceptions in current_settings.moduleswitches) and
(pi_needs_implicit_finally in flags))) then
procdef.personality:=search_system_proc('_FPC_PSABIEH_PERSONALITY_V0');
end;
procedure tcgprocinfo.generate_code_tree;
var
hpi : tcgprocinfo;
@ -1749,6 +1760,8 @@ implementation
not(target_info.system in systems_garbage_collected_managed_types) then
internalerror(200405231);
current_procinfo.set_eh_info;
{ Position markers are only used to insert additional code after the secondpass
and before this point. They are of no use in optimizer. Instead of checking and
ignoring all over the optimizer, just remove them here. }

View File

@ -165,7 +165,9 @@ interface
tf_x86_far_procs_push_odd_bp,
{ indicates that this target can use dynamic packages otherwise an
error will be generated if a package file is compiled }
tf_supports_packages
tf_supports_packages,
{ use PSABI/Dwarf-based "zero cost" exception handling }
tf_use_psabieh
);
psysteminfo = ^tsysteminfo;

View File

@ -1015,7 +1015,8 @@ unit i_bsd;
system : system_x86_64_darwin;
name : 'Darwin for x86_64';
shortname : 'Darwin';
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources];
flags : [tf_p_ext_support,tf_files_case_sensitive,tf_smartlink_sections,tf_dwarf_relative_addresses,tf_dwarf_only_local_labels,tf_pic_default,tf_has_winlike_resources
{$ifdef llvm},tf_use_psabieh{$endif}];
cpu : cpu_x86_64;
unit_env : 'BSDUNITS';
extradefines : 'UNIX;BSD;HASUNIX';