From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 2A0E83858D35 for ; Mon, 24 Aug 2020 19:55:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2A0E83858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bebbosoft.de Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=s.franke@bebbosoft.de Received: from serveronline.org ([78.46.86.77]:59150 helo=bebbosoft.de) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kAIYU-0002gT-7b for gcc-help@gcc.gnu.org; Mon, 24 Aug 2020 15:54:59 -0400 Received: from ZETRA (pd9e557ad.dip0.t-ipconnect.de [217.229.87.173]) by serveronline.org (BEJY V1.6.12-SNAPSHOT (c) 2000-2019 by BebboSoft, Stefan "Bebbo" Franke, all rights reserved) with SMTP id 1742209a96d2a1f028dc613f7a7 from s.franke@bebbosoft.de for gcc-help@gcc.gnu.org; Mon, 24 Aug 2020 20:54:52 +0100 Reply-To: From: "Stefan Franke" To: References: <00cd01d668f8$eb26b950$c1742bf0$@franke.ms> <000301d66a2a$ad8dcb50$08a961f0$@franke.ms> <20200824210620.00005690@justmail.de> In-Reply-To: <20200824210620.00005690@justmail.de> Subject: AW: C and C++ parser performing optimizations Date: Mon, 24 Aug 2020 21:54:53 +0200 Message-ID: <04c301d67a50$6f855630$4e900290$@bebbosoft.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIoofI7fDD9ID/mfoLzAHfDQrR3agGT97PYAZ28xBUBI0cAqqiAsTDQ Content-Language: de Received-SPF: pass client-ip=78.46.86.77; envelope-from=s.franke@bebbosoft.de; helo=bebbosoft.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/24 15:54:53 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=2.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_FAIL, SPF_HELO_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: ** X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Aug 2020 19:55:01 -0000 > -----Urspr=FCngliche Nachricht----- > Von: Gunther Nikl > Gesendet: Montag, 24. August 2020 21:06 > An: Stefan Franke ; gcc-help@gcc.gnu.org > Betreff: Re: C and C++ parser performing optimizations >=20 > stefan@franke.ms (Stefan Franke) wrote: >=20 > > > Von: Alexander Monakov > > > Betreff: Re: C and C++ parser performing optimizations > > > > > > On Sun, 2 Aug 2020, Stefan Franke wrote: > > > > > > > So the parser performs unwanted and uncontrollable = optimizations, > > > > which I consider bogus. > > > > > > On occasion they are also incorrect. > > > > > > My (possibly wrong or incomplete) understanding is that GCC does = not > > > have internal separation of mandatory simplifications that need to > > > be done in > > the > > > frontend (like constant folding in the context of integer constant > > > expressions) vs. optional simplifications (optimizing > > > substitutions). So it just does both at the same time. > > > > > > Alexander > > > > Here is an example where gcc creates wrong code: > > > > test.c: > > int foo() { > > const char * const txt =3D "hello"; > > register const char * const p asm("ecx") =3D txt; > > register int dx asm("edx"); > > asm(" call _faa" :"=3Dr" (dx) :"rf" (p)); } >=20 > Let me guess: this is about the m68k-amigaos LP macros? Can you show = an > example for that target? >=20 > Gunther Your guess is correct, the m68k-amigaos LP macros are affected. And you = may choose any bogus defined lib function. E.g. #define InitStruct(___initTable, ___memory, ___size) \ LP3NR(0x4e, InitStruct , const APTR, ___initTable, a1, APTR, ___memory, a2, ULONG, ___size, d0,\ , EXEC_BASE_NAME) What's wrong here? It yields register const APTR __initTable asm("a1"); which is register void * const __initTable asm("a1"); (some might expect register const void * __initTable asm("a1"); but that's not the case). So __initTable is const which triggers the bogus optimization in the = parsers (c and c++ don't share the code - they reimplemented that bug). I patched the parsers to omit that optimization. There are many other = passes which handle const propagation without dropping the register = information. One could fix the headers to circumvent that bug, all 'const ' locations need a fix, but that's another story... Stefan