Переглянути джерело

+ 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 -

Jonas Maebe 6 роки тому
батько
коміт
2f8fcf7819

+ 0 - 10
compiler/llvm/llvmpi.pas

@@ -38,7 +38,6 @@ interface
        public
        public
         constructor create(aparent: tprocinfo); override;
         constructor create(aparent: tprocinfo); override;
         destructor destroy; override;
         destructor destroy; override;
-        procedure set_first_temp_offset; override;
         procedure pushexceptlabel(lab: TAsmLabel);
         procedure pushexceptlabel(lab: TAsmLabel);
         procedure popexceptlabel(lab: TAsmLabel);
         procedure popexceptlabel(lab: TAsmLabel);
         function CurrExceptLabel: TAsmLabel; inline;
         function CurrExceptLabel: TAsmLabel; inline;
@@ -66,15 +65,6 @@ implementation
       end;
       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);
     procedure tllvmprocinfo.pushexceptlabel(lab: TAsmLabel);
       begin
       begin
         fexceptlabelstack.add(lab);
         fexceptlabelstack.add(lab);

+ 6 - 0
compiler/options.pas

@@ -3157,6 +3157,12 @@ begin
     else
     else
       undef_system_macro('FPC_SECTION_THREADVARS');
       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 }
   { Code generation flags }
   if (tf_pic_default in target_info.flags) then
   if (tf_pic_default in target_info.flags) then
     if def then
     if def then

+ 8 - 0
compiler/procinfo.pas

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

+ 13 - 0
compiler/psub.pas

@@ -65,6 +65,7 @@ interface
         procedure parse_body;
         procedure parse_body;
 
 
         function has_assembler_child : boolean;
         function has_assembler_child : boolean;
+        procedure set_eh_info; override;
       end;
       end;
 
 
 
 
@@ -1126,6 +1127,16 @@ implementation
           end;
           end;
       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;
     procedure tcgprocinfo.generate_code_tree;
       var
       var
         hpi : tcgprocinfo;
         hpi : tcgprocinfo;
@@ -1749,6 +1760,8 @@ implementation
                not(target_info.system in systems_garbage_collected_managed_types) then
                not(target_info.system in systems_garbage_collected_managed_types) then
              internalerror(200405231);
              internalerror(200405231);
 
 
+            current_procinfo.set_eh_info;
+
             { Position markers are only used to insert additional code after the secondpass
             { 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
               and before this point. They are of no use in optimizer. Instead of checking and
               ignoring all over the optimizer, just remove them here. }
               ignoring all over the optimizer, just remove them here. }

+ 3 - 1
compiler/systems.pas

@@ -165,7 +165,9 @@ interface
             tf_x86_far_procs_push_odd_bp,
             tf_x86_far_procs_push_odd_bp,
             { indicates that this target can use dynamic packages otherwise an
             { indicates that this target can use dynamic packages otherwise an
               error will be generated if a package file is compiled }
               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;
        psysteminfo = ^tsysteminfo;

+ 2 - 1
compiler/systems/i_bsd.pas

@@ -1015,7 +1015,8 @@ unit i_bsd;
             system       : system_x86_64_darwin;
             system       : system_x86_64_darwin;
             name         : 'Darwin for x86_64';
             name         : 'Darwin for x86_64';
             shortname    : 'Darwin';
             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;
             cpu          : cpu_x86_64;
             unit_env     : 'BSDUNITS';
             unit_env     : 'BSDUNITS';
             extradefines : 'UNIX;BSD;HASUNIX';
             extradefines : 'UNIX;BSD;HASUNIX';