From a76085e463af334c83a13341f3349e6ee29d396c Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Fri, 27 May 2022 21:23:09 +0200 Subject: [PATCH] tllvmcallpara: record whether it's passed to metadata Sometimes we need the def to store a the original def of the passed parameter, e.g. for the first argument to llvm.dbg.addr --- compiler/llvm/aasmllvm.pas | 2 +- compiler/llvm/agllvm.pas | 5 +++++ compiler/llvm/hlcgllvm.pas | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/llvm/aasmllvm.pas b/compiler/llvm/aasmllvm.pas index 64ea39a02e..e1df6104d2 100644 --- a/compiler/llvm/aasmllvm.pas +++ b/compiler/llvm/aasmllvm.pas @@ -209,7 +209,7 @@ interface destructor destroy; override; end; - tllvmcallparaflag = (lcp_byval, lcp_sret); + tllvmcallparaflag = (lcp_byval, lcp_sret, lcp_metadata); tllvmcallparaflags = set of tllvmcallparaflag; tllvmcallparaval = record diff --git a/compiler/llvm/agllvm.pas b/compiler/llvm/agllvm.pas index 4894ad8c0f..581f375095 100644 --- a/compiler/llvm/agllvm.pas +++ b/compiler/llvm/agllvm.pas @@ -347,6 +347,11 @@ implementation if i<>0 then owner.writer.AsmWrite(', '); para:=pllvmcallpara(paras[i]); + if (lcp_metadata in para^.flags) and + (para^.def<>llvm_metadatatype) then + begin + owner.writer.AsmWrite('metadata ') + end; owner.writer.AsmWrite(llvmencodetypename(para^.def)); if para^.valueext<>lve_none then owner.writer.AsmWrite(llvmvalueextension2str[para^.valueext]); diff --git a/compiler/llvm/hlcgllvm.pas b/compiler/llvm/hlcgllvm.pas index 42c15fe588..46947a9627 100644 --- a/compiler/llvm/hlcgllvm.pas +++ b/compiler/llvm/hlcgllvm.pas @@ -476,6 +476,8 @@ implementation while assigned(paraloc) do begin new(callpara,init(paraloc^.def,std_param_align,lve_none,[])); + if paras[i]^.def=llvm_metadatatype then + include(callpara^.flags,lcp_metadata); callpara^.def:=paraloc^.def; { if the paraloc doesn't contain the value itself, it's a byval parameter }