diff --git a/compiler/llvm/llvmpara.pas b/compiler/llvm/llvmpara.pas index 0244bb58de..e256dd821b 100644 --- a/compiler/llvm/llvmpara.pas +++ b/compiler/llvm/llvmpara.pas @@ -163,7 +163,12 @@ unit llvmpara; paralocs } while assigned(paraloc) do begin - if (vo_is_funcret in parasym.varoptions) + if (vo_is_funcret in parasym.varoptions) and + { sret attribute is only valid for the first parameter; sometimes + FPC will place other parameters first (e.g. self), and then + we can't use it; we use other attributes in that case to + approximate the optimisations that LLVM can do for sret } + (tabstractprocdef(parasym.owner.defowner).paras[0] = parasym) {$ifdef aarch64} { see AArch64's tcpuparamanager.create_paraloc_info_intern() } and not is_managed_type(parasym.vardef)