[fpc-devel] Do type-helpers block "regvar" opt?
    Martin Frb 
    lazarus at mfriebe.de
       
    Mon Sep 29 11:42:33 CEST 2025
    
    
  
Tested with 3.3.1  d3ac07ad27
-O4
Win 64 bit
In the code below, compiled with -alr
    .section .text.n_p$project1_$$_foo,"ax"
    ....
    # Var a located in register rbx
(and it stays in rbx, until the call to write is prepared)
But if I comment out the "write", and uncomment the "a.w"
    # Var a located at rsp+32, size=OS_64
Even the initial 2 lines will then NOT use a register for "a"?
program project1;
{$mode objfpc}{$Inline on}
{$StackFrames off}{$ImplicitExceptions off}
{$ModeSwitch typehelpers}
type
   P = ^integer;
   PH = type helper for P
     procedure w;
   end;
procedure PH.w;
begin
   write(self^)
end;
var g:p;
procedure Foo;
var a: p;
begin
   a:= g;
   a^:=1;
   //a.w;
   write(a^); //
end;
begin
   foo;
end.
    
    
More information about the fpc-devel
mailing list