Skip to content

trunk test/tfuncref26.pp failure with -O2 option for aarch64 CPU.

Summary

test/tfuncref26.pp test fails to compile with current trunk compiler for aarch64 CPU, both Linux and Darwin OS.

System Information

  • **Operating system: Linux and Darwin
  • **Processor architecture: aarch64 (other not checked)
  • **Compiler version:trunk 3.3

Steps to reproduce

gcc104:check muller$ ppca64 -gl tfuncref26.pp -O2 tfuncref26.pp(44,3) Fatal: Internal error 200409241 Fatal: Compilation aborted

Example Project

test source is already in git.

What is the current bug behavior?

What is the expected (correct) behavior?

Relevant logs and/or screenshots

Possible fixes

Starting program: /home/muller/pas/fpc-3.3.1-64/bin/ppca64 -gl tfuncref26.pp -O2
Free Pascal Compiler version 3.3.1-12018-ge63cc73cfa [2022/10/24] for aarch64
Copyright (c) 1993-2022 by Florian Klaempfl and others
Target OS: Linux for AArch64
Compiling tfuncref26.pp

Breakpoint 1, Internalerror (i=200409241) at verbose.pas:590
590           begin
(gdb) bt 6
#0  Internalerror (i=200409241) at verbose.pas:590
#1  0x000000000064c809 in generate_nested_access (this=0x7ffff78da5e0, vs=0x7ffff7c76680) at ncgld.pas:252
#2  0x000000000064da45 in pass_generate_code (this=0x7ffff7715f00) at ncgld.pas:509
#3  0x00000000005dcf0d in secondpass (p=0x1050027) at pass_2.pas:211
#4  0x000000000064ebef in pass_generate_code (this=0x4c7060) at ncgld.pas:783
#5  0x00000000005dcf0d in secondpass (p=0xadd2b0) at pass_2.pas:211
(More stack frames follow...)
(gdb) f 1
#1  0x000000000064c809 in generate_nested_access (this=0x7ffff78da5e0, vs=0x7ffff7c76680) at ncgld.pas:252
252               internalerror(200409241);
(gdb) li 243
238             tabstractnormalvarsym(symtableentry).localloc:=location;
239             hlcg.recordnewsymloc(current_asmdata.CurrAsmList,symtableentry,tabstractnormalvarsym(symtableentry).vardef,location.reference);
240           end;
241
242
243         procedure tcgloadnode.generate_nested_access(vs: tsym);
244           var
245             { parameter declared as tsym to reduce interface unit dependencies }
246             lvs: tabstractnormalvarsym absolute vs;
247           begin
(gdb)
248             secondpass(left);
249             if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
250               internalerror(200309286);
251             if lvs.localloc.loc<>LOC_REFERENCE then
252               internalerror(200409241);
253             hlcg.reference_reset_base(location.reference,left.resultdef,left.location.register,lvs.localloc.reference.offset,ctempposinvalid,lvs.localloc.reference.alignment,lvs.localloc.reference.volatility);
254           end;
255
256
257         procedure tcgloadnode.generate_absaddr_access(vs: tabsolutevarsym);
(gdb) p lvs.localloc.loc
warning: can't find linker symbol for virtual table for `tabstractnormalvarsym' value
$6 = LOC_CREGISTER
(gdb) p lvs.FRealName ^
warning: can't find linker symbol for virtual table for `tabstractnormalvarsym' value
$7 = '$Capturer'

This clearly shows the the '$Capturer' is optimized into a CREGISTER, which generate_absaddr_access does not support.

Maybe forbid '$Capturer' to be stored into a register would be enough to fix the issue, but as I have no insight into this new part of the compiler, I will leave the resolution to Sven.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information