瀏覽代碼

* set the dummy exception handling personality function for functions using
exceptions for LLVM (except on Windows targets, since they (will) use
their own kind of exception handling)
o ensure we generate an external function symbol definition for such
personality functions on LLVM

git-svn-id: branches/debug_eh@40402 -

Jonas Maebe 6 年之前
父節點
當前提交
5b8f7224af
共有 3 個文件被更改,包括 28 次插入2 次删除
  1. 8 0
      compiler/llvm/agllvm.pas
  2. 11 1
      compiler/llvm/llvmpi.pas
  3. 9 1
      compiler/llvm/llvmtype.pas

+ 8 - 0
compiler/llvm/agllvm.pas

@@ -1195,6 +1195,14 @@ implementation
                       WriteLinkageVibilityFlags(taillvmdecl(hp).namesym.bind);
                       writer.AsmWrite(llvmencodeproctype(tprocdef(taillvmdecl(hp).def), '', lpd_def));
                       WriteFunctionFlags(tprocdef(taillvmdecl(hp).def));
+                      if assigned(tprocdef(taillvmdecl(hp).def).personality) then
+                        begin
+                          writer.AsmWrite(' personality i8* bitcast (');
+                          writer.AsmWrite(llvmencodeproctype(tprocdef(taillvmdecl(hp).def).personality, '', lpd_procvar));
+                          writer.AsmWrite('* ');
+                          writer.AsmWrite(llvmmangledname(tprocdef(taillvmdecl(hp).def).personality.mangledname));
+                          writer.AsmWrite(' to i8*)');
+                        end;
                       writer.AsmWriteln(' {');
                     end;
                 end

+ 11 - 1
compiler/llvm/llvmpi.pas

@@ -38,6 +38,7 @@ 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;
@@ -46,7 +47,7 @@ interface
 implementation
 
     uses
-      globtype,verbose,
+      globtype,verbose,systems,
       symtable;
 
 
@@ -65,6 +66,15 @@ 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);

+ 9 - 1
compiler/llvm/llvmtype.pas

@@ -401,7 +401,15 @@ implementation
           ait_typedconst:
             insert_typedconst_typeconversion(toplevellist,tai_abstracttypedconst(p));
           ait_llvmdecl:
-            insert_asmlist_typeconversions(toplevellist,taillvmdecl(p).initdata);
+            begin
+              if (ldf_definition in taillvmdecl(p).flags) and
+                 (taillvmdecl(p).def.typ=procdef) and
+                 assigned(tprocdef(taillvmdecl(p).def).personality) then
+                maybe_insert_extern_sym_decl(toplevellist,
+                  current_asmdata.RefAsmSymbol(tprocdef(taillvmdecl(p).def).personality.mangledname,AT_FUNCTION,false),
+                  tprocdef(taillvmdecl(p).def).personality);
+              insert_asmlist_typeconversions(toplevellist,taillvmdecl(p).initdata);
+            end;
         end;
       end;