[fpc-pascal] Register Allocation on x86_64

Martok listbox at martoks-place.de
Wed Jan 10 17:06:22 CET 2018


> variables in the same routine. Unlike in e.g. gcc, there are no 
> annotations for assembly routines that they expect certain variables to 
> be in memory and/or registers, that the block may touch arbitrary memory 
> locations, etc. Hence, the compiler is as conservative as possible.
This took me a while to understand, but what you're saying is that the issue is
not so much about what registers might be modified (we could just say that if
the annotation exists, it is assumed to be complete), but that the assembler
code might try to take the address of a variable (possibly with indirections),
which must therefore not be a regvar?
That makes sense. Unfortunately...

> Afaik there are only two limitations:
> * routines containing assembly blocks (including pure assembly routines) 
> cannot be inlined> * regular procedures that contain assembly blocks will never use regvars
Somehow I have a feeling that the fix for one would also fix the other...

I'd add the manual RIP addressing that was mentioned on the bugtracker recently
(OT: is -Cg supposed to work on platforms where it is not set by default?).

For the original issue, since manually using assembler blocks makes things
complicated, is there a way to "strongly suggest" to the compiler that a
variable should become a regvar if the entire routine is pure Pascal? Something
like the (purely decorative) {register} comments in


Ceterum censeo b32079 esse sanandam.

More information about the fpc-pascal mailing list