From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by sourceware.org (Postfix) with ESMTPS id 27E413858414 for ; Sat, 30 Sep 2023 07:44:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 27E413858414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=starynkevitch.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=starynkevitch.net Received: by mail.gandi.net (Postfix) with ESMTPSA id 88C97240004; Sat, 30 Sep 2023 07:44:53 +0000 (UTC) Content-Type: multipart/alternative; boundary="------------04d0w9qpvuthEJ0B2avJHDUD" Message-ID: <1182dbfd-2dba-4289-9b99-5ffbc89994aa@starynkevitch.net> Date: Sat, 30 Sep 2023 09:44:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Is it safe to use unaligned pointer with libgccjit? Content-Language: en-US To: Schrodinger ZHU Yifan References: Cc: jit@gcc.gnu.org From: Basile Starynkevitch In-Reply-To: X-GND-Sasl: basile@starynkevitch.net X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,HTML_MESSAGE,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_SHORT,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This is a multi-part message in MIME format. --------------04d0w9qpvuthEJ0B2avJHDUD Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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 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 to generate machine code). RefPerSys is work in progress, and we welcome contributors. Regards from near Paris in France -- Basile Starynkevitch (only mine opinions / les opinions sont miennes uniquement) 92340 Bourg-la-Reine, France web page: starynkevitch.net/Basile/ --------------04d0w9qpvuthEJ0B2avJHDUD--