Is it safe to use unaligned pointer with libgccjit?
Basile Starynkevitch
basile@starynkevitch.net
Sat Sep 30 07:44:52 GMT 2023
On 9/30/23 02:29, Schrodinger ZHU Yifan via Jit wrote:
> Hi,
> I wonder if it is safe to use trailing bits as tags and passing them as some non-opaque type pointers. There isn't any direct dereference on such unaligned pointers, of course.
libgccjit <https://gcc.gnu.org/onlinedocs/jit/index.html> is in practice
yet another front-end to the GCC compiler suite.
So it should in practice be safe to do so.
My suggestion is (on Linux systems at least) to write a small C program
(or even a small C file containing a single C routine) doing what you
want, to write a small libgccjit example doing the same.
Then compile your small C program to produce its assembler code (using
gcc -O -S -fverbose-asm).
Do the same with your libgccjit toy example. Use
gcc_jit_context_dump_reproducer_to_filewithgcc_jit_context_add_command_line_optionor
the GCC_JIT_BOOL_OPTION_DUMP_GENERATED_CODE
If you found substantial differences, report a bug in libgccjit.
By the way my pet open source project is the RefPerSys
<http://refpersys.org/> open source inference engine project on
https://github.com/RefPerSys/RefPerSys (and we do generate at runtime
some code and want to generate more and more of it: currently generating
C++ code and using GNU lightning
<https://www.gnu.org/software/lightning/> to generate machine code).
RefPerSys is work in progress, and we welcome contributors.
Regards from near Paris in France
--
Basile Starynkevitch<basile@starynkevitch.net>
(only mine opinions / les opinions sont miennes uniquement)
92340 Bourg-la-Reine, France
web page: starynkevitch.net/Basile/
More information about the Jit
mailing list