From patchwork Tue Jun 17 07:18:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wohlferd X-Patchwork-Id: 360360 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 B9E4814007B for ; Tue, 17 Jun 2014 17:21:49 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=E6RtmhZS+kHfsiJlDueuXtWq0pmwCa81SUoRncXiMgi+U+ guHynro6/zpUoV9e8zSeueECF7fYZmZ/som4eWVkCmS740N5fAiHcTlomS8doku3 iY4JSJQjpWoqPcu9YB4SoHBV0iJt76zTnpiw6hLh552HphESIT9pP7T4sO4ug= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=TKA3qmrmhMmNqQfcyK+Fft61FwE=; b=u9r+6gHuBeNDkuutRAAZ Y4QNJQrYTbNg9KsQRgK76T1iZm/X2ZBLoEA9ji5rwKkfjguqnHQ4G7zU4FlpGZf3 U1ObudKzAmmzbcfA83riHp4MkOCWRhglT1Ac2uHIryTAJGpt5uxuM3ua8PyaB+lj 8dVxQmHWbulY4MvP6k0cLEw= Received: (qmail 15856 invoked by alias); 17 Jun 2014 07:21:41 -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 15732 invoked by uid 89); 17 Jun 2014 07:21:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_40, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: limegreensocks.com Received: from limegreensocks.com (HELO limegreensocks.com) (207.118.20.56) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Tue, 17 Jun 2014 07:21:38 +0000 Received: from [192.168.1.44] ([192.168.1.44]) by limegreensocks.com via TCP with ESMTPSA; Tue, 17 Jun 2014 00:18:29 -0700 Message-ID: <539FEBAD.20408@LimeGreenSocks.com> Date: Tue, 17 Jun 2014 00:18:05 -0700 From: David Wohlferd User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" , Gerald Pfeifer Subject: [DOC Patch] Attribute 'naked' X-IsSubscribed: yes I don't have permissions to commit this patch, but I do have a release on file with the FSF. Problem description: The docs for the function attribute 'naked' are confusing and self-contradictory. Also, discussion on this thread https://gcc.gnu.org/ml/gcc/2014-05/msg00100.html has lead to changing the text from the vague "avoid using" to the very clear "not supported" regarding the usage of Extended asm with 'naked.' Lastly, this attribute should be mentioned when describing the differences between Basic and Extended asm. ChangeLog: 2014-06-17 David Wohlferd * doc/extend.texi (Function Attributes): Update 'naked' attribute doc. dw Index: extend.texi =================================================================== --- extend.texi (revision 210624) +++ extend.texi (working copy) @@ -3332,16 +3332,15 @@ @item naked @cindex function without a prologue/epilogue code -Use this attribute on the ARM, AVR, MCORE, MSP430, NDS32, RL78, RX and SPU -ports to indicate that the specified function does not need prologue/epilogue -sequences generated by the compiler. -It is up to the programmer to provide these sequences. The -only statements that can be safely included in naked functions are -@code{asm} statements that do not have operands. All other statements, -including declarations of local variables, @code{if} statements, and so -forth, should be avoided. Naked functions should be used to implement the -body of an assembly function, while allowing the compiler to construct -the requisite function declaration for the assembler. +This attribute is available on the ARM, AVR, MCORE, MSP430, NDS32, +RL78, RX and SPU ports. It allows the compiler to construct the +requisite function declaration, while allowing the body of the +function to be assembly code. The specified function will not have +prologue/epilogue sequences generated by the compiler. Only Basic +@code{asm} statements can safely be included in naked functions +(@pxref{Basic Asm}). While using Extended @code{asm} or a mixture of +Basic @code{asm} and ``C'' code may appear to work, they cannot be +depended upon to work reliably and are not supported. @item near @cindex functions that do not handle memory bank switching on 68HC11/68HC12 @@ -6269,6 +6268,8 @@ efficient code, and in most cases it is a better solution. When writing inline assembly language outside of C functions, however, you must use Basic @code{asm}. Extended @code{asm} statements have to be inside a C function. +Functions declared with the @code{naked} attribute also require Basic +@code{asm} (@pxref{Function Attributes}). Under certain circumstances, GCC may duplicate (or remove duplicates of) your assembly code when optimizing. This can lead to unexpected duplicate @@ -6388,6 +6389,8 @@ Note that Extended @code{asm} statements must be inside a function. Only Basic @code{asm} may be outside functions (@pxref{Basic Asm}). +Functions declared with the @code{naked} attribute also require Basic +@code{asm} (@pxref{Function Attributes}). While the uses of @code{asm} are many and varied, it may help to think of an @code{asm} statement as a series of low-level instructions that convert input