From 81471859075f0835a88bf09bc3d49df5b6fe6c7e Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 2 Jan 2024 21:55:18 +0100 Subject: [PATCH] LLVM: fix missing line debug info for some invokes in specialised functions Required when the code can be inlined. Fixes compilation with debug info of system.messaging.pp --- compiler/llvm/dbgllvm.pas | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/compiler/llvm/dbgllvm.pas b/compiler/llvm/dbgllvm.pas index 11f8530a90..2b00d52d23 100644 --- a/compiler/llvm/dbgllvm.pas +++ b/compiler/llvm/dbgllvm.pas @@ -2937,18 +2937,23 @@ implementation functionscope.addint64('scopeLine',tailineinfo(hp).fileinfo.line); firstline:=false; end; + positionmeta:=filepos_getmetanode(tailineinfo(hp).fileinfo,procdeffileinfo,functionscope,nolineinfolevel<>0); - end + end; + { LLVM requires line info for call instructions that may potentially be inlined } - else if taillvm(hp).llvmopcode in [la_call,la_invoke] then + if (taillvm(hp).llvmopcode in [la_call,la_invoke]) and + not assigned(positionmeta) then begin - positionmeta:=filepos_getmetanode(tailineinfo(hp).fileinfo,procdeffileinfo,functionscope,true); + positionmeta:=filepos_getmetanode(procdeffileinfo,procdeffileinfo,functionscope,true); end; + if assigned(positionmeta) then taillvm(hp).addinsmetadata(tai_llvmmetadatareferenceoperand.createreferenceto('dbg',positionmeta)); + if (cs_debuginfo in current_settings.moduleswitches) and - (taillvm(hp).llvmopcode=la_call) then + (taillvm(hp).llvmopcode = la_call) then updatelocalvardbginfo(taillvm(hp),pd,functionscope); end; hp:=tai(hp.next);