mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-24 21:51:32 +02:00
LLVM: use llvm.dbg.declare instead of llvm.dbg.addr for variable declarations
Even though it's supposedly deprecated, clang also still uses it and without the declaration ranges of local variables are sometimes cut off
This commit is contained in:
parent
dd768554b4
commit
49cb7b2564
@ -653,7 +653,7 @@ unit hlcgobj;
|
|||||||
{ allocate a local temp to serve as storage for a para/localsym }
|
{ allocate a local temp to serve as storage for a para/localsym }
|
||||||
procedure getlocal(list: TAsmList; sym: tsym; size: asizeint; alignment: shortint; def: tdef; out ref : treference);
|
procedure getlocal(list: TAsmList; sym: tsym; size: asizeint; alignment: shortint; def: tdef; out ref : treference);
|
||||||
{ the symbol is stored at this location from now on }
|
{ the symbol is stored at this location from now on }
|
||||||
procedure recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference); virtual;
|
procedure recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference; initial: boolean); virtual;
|
||||||
protected
|
protected
|
||||||
procedure gen_loadfpu_loc_cgpara(list: TAsmList; size: tdef; const l: tlocation;const cgpara: tcgpara;locintsize: longint);virtual;
|
procedure gen_loadfpu_loc_cgpara(list: TAsmList; size: tdef; const l: tlocation;const cgpara: tcgpara;locintsize: longint);virtual;
|
||||||
procedure init_paras(p:TObject;arg:pointer);
|
procedure init_paras(p:TObject;arg:pointer);
|
||||||
@ -5289,10 +5289,10 @@ implementation
|
|||||||
procedure thlcgobj.getlocal(list: TAsmList; sym: tsym; size: asizeint; alignment: shortint; def: tdef; out ref: treference);
|
procedure thlcgobj.getlocal(list: TAsmList; sym: tsym; size: asizeint; alignment: shortint; def: tdef; out ref: treference);
|
||||||
begin
|
begin
|
||||||
tg.getlocal(list,size,alignment,def,ref);
|
tg.getlocal(list,size,alignment,def,ref);
|
||||||
recordnewsymloc(list,sym,def,ref);
|
recordnewsymloc(list,sym,def,ref,true);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure thlcgobj.recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference);
|
procedure thlcgobj.recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference; initial: boolean);
|
||||||
begin
|
begin
|
||||||
// do nothing
|
// do nothing
|
||||||
end;
|
end;
|
||||||
|
@ -83,6 +83,7 @@ interface
|
|||||||
{ reusable deref node }
|
{ reusable deref node }
|
||||||
fderefexpression : tai_llvmspecialisedmetadatanode;
|
fderefexpression : tai_llvmspecialisedmetadatanode;
|
||||||
|
|
||||||
|
fllvm_dbg_declare_pd: tprocdef;
|
||||||
fllvm_dbg_addr_pd: tprocdef;
|
fllvm_dbg_addr_pd: tprocdef;
|
||||||
|
|
||||||
function absolute_llvm_path(const s:tcmdstr):tcmdstr;
|
function absolute_llvm_path(const s:tcmdstr):tcmdstr;
|
||||||
@ -490,6 +491,8 @@ implementation
|
|||||||
|
|
||||||
procedure TDebugInfoLLVM.ensuremetainit;
|
procedure TDebugInfoLLVM.ensuremetainit;
|
||||||
begin
|
begin
|
||||||
|
if not assigned(fllvm_dbg_declare_pd) then
|
||||||
|
fllvm_dbg_declare_pd:=search_system_proc('llvm_dbg_declare');
|
||||||
if not assigned(fllvm_dbg_addr_pd) then
|
if not assigned(fllvm_dbg_addr_pd) then
|
||||||
fllvm_dbg_addr_pd:=search_system_proc('llvm_dbg_addr');
|
fllvm_dbg_addr_pd:=search_system_proc('llvm_dbg_addr');
|
||||||
if not assigned(fenums) then
|
if not assigned(fenums) then
|
||||||
@ -574,7 +577,8 @@ implementation
|
|||||||
{ not really clean since hardcoding the structure of the call
|
{ not really clean since hardcoding the structure of the call
|
||||||
instruction's procdef encoding, but quick }
|
instruction's procdef encoding, but quick }
|
||||||
if (hp.oper[taillvm.callpdopernr]^.def.typ<>pointerdef) or
|
if (hp.oper[taillvm.callpdopernr]^.def.typ<>pointerdef) or
|
||||||
(tpointerdef(hp.oper[taillvm.callpdopernr]^.def).pointeddef<>fllvm_dbg_addr_pd) then
|
((tpointerdef(hp.oper[taillvm.callpdopernr]^.def).pointeddef<>fllvm_dbg_declare_pd) and
|
||||||
|
(tpointerdef(hp.oper[taillvm.callpdopernr]^.def).pointeddef<>fllvm_dbg_addr_pd)) then
|
||||||
exit;
|
exit;
|
||||||
deref:=false;
|
deref:=false;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ uses
|
|||||||
procedure allocallcpuregisters(list: TAsmList); override;
|
procedure allocallcpuregisters(list: TAsmList); override;
|
||||||
procedure deallocallcpuregisters(list: TAsmList); override;
|
procedure deallocallcpuregisters(list: TAsmList); override;
|
||||||
|
|
||||||
procedure recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference); override;
|
procedure recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference; initial: boolean); override;
|
||||||
|
|
||||||
class function def2regtyp(def: tdef): tregistertype; override;
|
class function def2regtyp(def: tdef): tregistertype; override;
|
||||||
public
|
public
|
||||||
@ -403,7 +403,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure thlcgllvm.recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference);
|
procedure thlcgllvm.recordnewsymloc(list: TAsmList; sym: tsym; def: tdef; const ref: treference; initial: boolean);
|
||||||
var
|
var
|
||||||
varmetapara,
|
varmetapara,
|
||||||
symmetadatapara,
|
symmetadatapara,
|
||||||
@ -414,7 +414,10 @@ implementation
|
|||||||
(sym.visibility<>vis_hidden) and
|
(sym.visibility<>vis_hidden) and
|
||||||
(cs_debuginfo in current_settings.moduleswitches) then
|
(cs_debuginfo in current_settings.moduleswitches) then
|
||||||
begin
|
begin
|
||||||
pd:=search_system_proc('llvm_dbg_addr');
|
if initial then
|
||||||
|
pd:=search_system_proc('llvm_dbg_declare')
|
||||||
|
else
|
||||||
|
pd:=search_system_proc('llvm_dbg_addr');
|
||||||
varmetapara.init;
|
varmetapara.init;
|
||||||
symmetadatapara.init;
|
symmetadatapara.init;
|
||||||
exprmetapara.init;
|
exprmetapara.init;
|
||||||
|
@ -236,7 +236,7 @@ implementation
|
|||||||
location.reference:=ref;
|
location.reference:=ref;
|
||||||
tg.ChangeTempType(current_asmdata.CurrAsmList,location.reference,oldtemptype);
|
tg.ChangeTempType(current_asmdata.CurrAsmList,location.reference,oldtemptype);
|
||||||
tabstractnormalvarsym(symtableentry).localloc:=location;
|
tabstractnormalvarsym(symtableentry).localloc:=location;
|
||||||
hlcg.recordnewsymloc(current_asmdata.CurrAsmList,symtableentry,tabstractnormalvarsym(symtableentry).vardef,location.reference);
|
hlcg.recordnewsymloc(current_asmdata.CurrAsmList,symtableentry,tabstractnormalvarsym(symtableentry).vardef,location.reference,false);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,4 +117,5 @@ function llvm_experimental_constrained_uitofp_f64_i64(val: qword; rounding, exce
|
|||||||
function llvm_experimental_constrained_uitofp_f80_i64(val: qword; rounding, exceptions: LLVMMetadata): extended; compilerproc; external name 'llvm.experimental.constrained.uitofp.x86_fp80.i64';
|
function llvm_experimental_constrained_uitofp_f80_i64(val: qword; rounding, exceptions: LLVMMetadata): extended; compilerproc; external name 'llvm.experimental.constrained.uitofp.x86_fp80.i64';
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
procedure llvm_dbg_declare(address, description, expression: LLVMMetadata); compilerproc; external name 'llvm.dbg.declare';
|
||||||
procedure llvm_dbg_addr(address, description, expression: LLVMMetadata); compilerproc; external name 'llvm.dbg.addr';
|
procedure llvm_dbg_addr(address, description, expression: LLVMMetadata); compilerproc; external name 'llvm.dbg.addr';
|
||||||
|
Loading…
Reference in New Issue
Block a user