* create LLVM TAsmCFI wrapper that calls through to the original TASmCFI for

pure assembler routines and for generating the CFI tables, and does nothing
    for LLVM-handled routines (LLVM takes care of the CFI there)

git-svn-id: branches/debug_eh@41580 -
This commit is contained in:
Jonas Maebe 2019-03-03 17:15:09 +00:00
parent efaa7d67bb
commit 16cde0da15
4 changed files with 152 additions and 3 deletions

1
.gitattributes vendored
View File

@ -343,6 +343,7 @@ compiler/llvm/cgllvm.pas svneol=native#text/plain
compiler/llvm/hlcgllvm.pas svneol=native#text/plain
compiler/llvm/itllvm.pas svneol=native#text/plain
compiler/llvm/llvmbase.pas svneol=native#text/plain
compiler/llvm/llvmcfi.pas svneol=native#text/plain
compiler/llvm/llvmdef.pas svneol=native#text/plain
compiler/llvm/llvminfo.pas svneol=native#text/plain
compiler/llvm/llvmnode.pas svneol=native#text/plain

View File

@ -1405,7 +1405,7 @@ implementation
WriteTypedConstData(tai_abstracttypedconst(hp));
end
else
internalerror(2019012001);
internalerror(2019012010);
end;
end;
@ -1438,7 +1438,7 @@ implementation
current_asmdata.asmlists[hal].Empty then
continue;
writer.AsmWriteLn(asminfo^.comment+'Begin asmlist '+AsmlistTypeStr[hal]);
if hal<>al_pure_assembler then
if not(hal in [al_pure_assembler,al_dwarf_frame]) then
writetree(current_asmdata.asmlists[hal])
else
begin

147
compiler/llvm/llvmcfi.pas Normal file
View File

@ -0,0 +1,147 @@
{
Copyright (c) 2019 by Jonas Maebe, member of the Free Pascal Compiler
development team
LLVM CFI wrapper: use native CFI instance for pure assembler routines,
and dummy one for LLVM (the LLVM code generator will take care of CFI)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit llvmcfi;
{$i fpcdefs.inc}
interface
uses
aasmbase,
aasmdata,
cgbase;
type
tllvmcfi = class(TAsmCFI)
constructor create; override;
destructor destroy; override;
procedure generate_code(list: TAsmList); override;
procedure start_frame(list:TAsmList);override;
procedure end_frame(list:TAsmList);override;
procedure outmost_frame(list:TAsmList);override;
procedure cfa_offset(list:TAsmList;reg:tregister;ofs:longint);override;
procedure cfa_restore(list:TAsmList;reg:tregister);override;
procedure cfa_def_cfa_register(list:TAsmList;reg:tregister);override;
procedure cfa_def_cfa_offset(list:TAsmList;ofs:longint);override;
function get_frame_start: TAsmLabel; override;
function get_cfa_list: TAsmList; override;
private
fnativecfi: TAsmCFI;
end;
implementation
uses
symconst,
procinfo;
var
nativecficlass: TAsmCFIClass;
constructor tllvmcfi.create;
begin
inherited;
fnativecfi:=nativecficlass.create;
end;
destructor tllvmcfi.destroy;
begin
fnativecfi.free;
inherited destroy;
end;
procedure tllvmcfi.generate_code(list: TAsmList);
begin
fnativecfi.generate_code(list);
end;
procedure tllvmcfi.start_frame(list: TAsmList);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.start_frame(list);
end;
procedure tllvmcfi.end_frame(list: TAsmList);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.end_frame(list);
end;
procedure tllvmcfi.outmost_frame(list: TAsmList);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.outmost_frame(list);
end;
procedure tllvmcfi.cfa_offset(list: TAsmList; reg: tregister; ofs: longint);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.cfa_offset(list, reg, ofs);
end;
procedure tllvmcfi.cfa_restore(list: TAsmList; reg: tregister);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.cfa_restore(list, reg);
end;
procedure tllvmcfi.cfa_def_cfa_register(list: TAsmList; reg: tregister);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.cfa_def_cfa_register(list, reg);
end;
procedure tllvmcfi.cfa_def_cfa_offset(list: TAsmList; ofs: longint);
begin
if po_assembler in current_procinfo.procdef.procoptions then
fnativecfi.cfa_def_cfa_offset(list, ofs);
end;
function tllvmcfi.get_frame_start: TAsmLabel;
begin
result:=fnativecfi.get_frame_start;
end;
function tllvmcfi.get_cfa_list: TAsmList;
begin
result:=fnativecfi.get_cfa_list;
end;
begin
nativecficlass:=CAsmCFI;
CAsmCFI:=tllvmcfi;
end.

View File

@ -40,6 +40,7 @@ implementation
nllvmadd,nllvmbas,nllvmcal,nllvmcnv,nllvmcon,nllvmflw,nllvminl,nllvmld,
nllvmmat,nllvmmem,nllvmtcon,nllvmutil,
llvmpara,llvmpi,
symllvm;
symllvm,
llvmcfi;
end.