From patchwork Thu Mar 17 05:23:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wohlferd X-Patchwork-Id: 598896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qQcH917sfz9sCj for ; Thu, 17 Mar 2016 16:24:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=m/iJJg0Z; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=AvmJYxWM3cvGoNP7M M97rGQwq913F8NkzgdycdultHbR25UC2tpUhubgKst/bR9B6jrcTYjatLzvWa7Ad pO3apoAQIx51lCcUWMXGjX/U/MeY70vZudQh/XoTtaclqz+Irho77fo4n7qkR3UI 9ngFjUtNer/wFESieKV9Zw+zco= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=3sBpQD4CIoX5prmNl3H03DB 0P8U=; b=m/iJJg0ZVhnX4kxn4zfuyZ8Jjo5+rXs7sdf3P5wYsW4SOaZCFO1ooTg mm5pYIJKJgvGD4lQ3qyX/LoXT8wsBPr0hu1UZAXEyZ6sdMYGAG+42LSwVlJ63gwE FnjUwkPqpsOmi4zYOF1LLOxka6ywhhiuiL7kTn5a++I3gBvPrmlM= Received: (qmail 113611 invoked by alias); 17 Mar 2016 05:24:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 113559 invoked by uid 89); 17 Mar 2016 05:24:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_40, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=Doc, sk:bschmid, U*bschmidt, bschmidt@redhat.com X-HELO: bosmailout08.eigbox.net Received: from bosmailout08.eigbox.net (HELO bosmailout08.eigbox.net) (66.96.187.8) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 17 Mar 2016 05:24:17 +0000 Received: from bosmailscan05.eigbox.net ([10.20.15.5]) by bosmailout08.eigbox.net with esmtp (Exim) id 1agQPt-0000yL-Ie for gcc-patches@gcc.gnu.org; Thu, 17 Mar 2016 01:24:13 -0400 Received: from [10.115.3.33] (helo=bosimpout13) by bosmailscan05.eigbox.net with esmtp (Exim) id 1agQPt-0003fb-Bx for gcc-patches@gcc.gnu.org; Thu, 17 Mar 2016 01:24:13 -0400 Received: from bosauthsmtp03.yourhostingaccount.com ([10.20.18.3]) by bosimpout13 with id WtQ61s00K03yW7601tQ9Hi; Thu, 17 Mar 2016 01:24:13 -0400 X-Authority-Analysis: v=2.1 cv=Abo/HhnG c=1 sm=1 tr=0 a=6uKCkKhFq2wXOH2GoQX8aA==:117 a=sZx1nW7oDdbgogxTPqu5Xw==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=88b2x-oFWvEA:10 a=7OsogOcEt9IA:10 a=r77TgQKjGQsHNAKrUKIA:9 a=C8F9KGFtAAAA:8 a=20KFwNOVAAAA:8 a=aHp852StzpH450QZ8joA:9 a=pILNOxqGKmIA:10 a=mDV3o1hIAAAA:8 a=yDX13npoj1CGXRd0mq0A:9 Received: from [207.118.20.56] (port=50657 helo=[192.168.1.160]) by bosauthsmtp03.eigbox.net with esmtpa (Exim) id 1agQPm-0003JH-Gw; Thu, 17 Mar 2016 01:24:06 -0400 Subject: Re: Wonly-top-basic-asm To: Bernd Schmidt , Bernd Edlinger , Sandra Loosemore , "gcc-patches@gcc.gnu.org" References: <56A54EF9.8060006@LimeGreenSocks.com> <56A61442.3090803@redhat.com> <56A9C134.1030500@LimeGreenSocks.com> <56B80F57.9020606@LimeGreenSocks.com> <56BBCC90.9020001@LimeGreenSocks.com> <56BCAB73.20506@redhat.com> <56BD8427.4050405@LimeGreenSocks.com> <56BDD550.3050908@redhat.com> <56BE80F4.6060803@codesourcery.com> <56BFFBD9.7010202@LimeGreenSocks.com> <56C7BB50.4000909@LimeGreenSocks.com> <56C99113.7090602@LimeGreenSocks.com> <56D06AC1.7090607@redhat.com> <56D3ECEE.4050503@LimeGreenSocks.com> <56E21779.4020804@LimeGreenSocks.com> <56E6D8BB.3060507@redhat.com> Cc: Richard Henderson , "jason@redhat.com" , "segher@kernel.crashing.org" , "Paul_Koning@Dell.com" , Jeff Law , Andrew Haley , "hubicka@ucw.cz" , David Wohlferd From: David Wohlferd Message-ID: <56EA3F55.7050103@LimeGreenSocks.com> Date: Wed, 16 Mar 2016 22:23:33 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56E6D8BB.3060507@redhat.com> X-EN-UserInfo: 97390230d6758ac7ebdf93f8c6197d31:931c98230c6409dcc37fa7e93b490c27 X-EN-AuthUser: dw@limegreensocks.com X-EN-OrigIP: 207.118.20.56 X-EN-OrigHost: unknown On 3/14/2016 8:28 AM, Bernd Schmidt wrote: > The example is not good, as discussed previously, and IMO the best > option is to remove it. Otherwise I have no objections to the latest > variant. Despite the problems I have with the existing sample, adding the information/warnings is more important to me, and more valuable to users. Perhaps we can revisit the sample when pr24414 gets addressed. I have removed my changes to the sample in the attached patch. ChangeLog: 2016-03-16 David Wohlferd Bernd Schmidt * doc/extend.texi: Doc basic asm behavior re clobbers. dw Index: extend.texi =================================================================== --- extend.texi (revision 234245) +++ extend.texi (working copy) @@ -7441,7 +7441,8 @@ @end table @subsubheading Remarks -Using extended @code{asm} typically produces smaller, safer, and more +Using extended @code{asm} (@pxref{Extended Asm}) typically produces smaller, +safer, and more efficient code, and in most cases it is a better solution than basic @code{asm}. However, there are two situations where only basic @code{asm} can be used: @@ -7481,10 +7482,25 @@ symbol errors during compilation if your assembly code defines symbols or labels. -Since GCC does not parse the @var{AssemblerInstructions}, it has no -visibility of any symbols it references. This may result in GCC discarding -those symbols as unreferenced. +@strong{Warning:} The C standards do not specify semantics for @code{asm}, +making it a potential source of incompatibilities between compilers. These +incompatibilities may not produce compiler warnings/errors. +GCC does not parse basic @code{asm}'s @var{AssemblerInstructions}, which +means there is no way to communicate to the compiler what is happening +inside them. GCC has no visibility of symbols in the @code{asm} and may +discard them as unreferenced. It also does not know about side effects of +the assembler code, such as modifications to memory or registers. Unlike +some compilers, GCC assumes that no changes to either memory or registers +occur. This assumption may change in a future release. + +To avoid complications from future changes to the semantics and the +compatibility issues between compilers, consider replacing basic @code{asm} +with extended @code{asm}. See +@uref{https://gcc.gnu.org/wiki/ConvertBasicAsmToExtended, How to convert +from basic asm to extended asm} for information about how to perform this +conversion. + The compiler copies the assembler instructions in a basic @code{asm} verbatim to the assembly language output file, without processing dialects or any of the @samp{%} operators that are available with