public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "anitha dot boyapati at atmel dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/42240] wrong epilogue on naked function
Date: Thu, 22 Jul 2010 11:26:00 -0000	[thread overview]
Message-ID: <20100722112619.30932.qmail@sourceware.org> (raw)
In-Reply-To: <bug-42240-18514@http.gcc.gnu.org/bugzilla/>



------- Comment #9 from anitha dot boyapati at atmel dot com  2010-07-22 11:26 -------
I think the bug is not due to 'naked' function. When the naked attribute is
removed for __init_seed(void), the following diff can be observed in the
assembly file.

====================================================
--- test_without_naked.s        2010-07-22 15:53:13.178956400 +0530
+++ test_with_naked.s           2010-07-22 15:52:52.474373900 +0530
@@ -14,10 +14,11 @@
 .L2:
        rjmp .L2
        .size   main, .-main
+       .section        .init8,"ax",@progbits
 .global        __init_seed
        .type   __init_seed, @function
 __init_seed:
-/* prologue: function */
+/* prologue: naked */
 /* frame size = 0 */
        ldi r24,lo8(__noinit_start+2)
        ldi r25,hi8(__noinit_start+2)
@@ -41,7 +42,6 @@
        sts (seedram)+1,r19
        sts seedram,r18
 /* epilogue start */
-       ret
 .L11:
        ldi r18,lo8(0)
        ldi r19,hi8(0)

=======================================================

It can be seen that in case of naked function, 'ret' is not generated. Hence
the execution goes into infinite loop. The code generated for epilogue is wrong
in few cases for either for naked/normal functions with -O2 enabled. However
incase of normal functions, execution is not affected as 'ret' is executed
before entering into block labelled .L11 (of main.s).

.L11:
        ldi r18,lo8(0)
        ldi r19,hi8(0)
        rjmp .L6


-- 

anitha dot boyapati at atmel dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anitha dot boyapati at atmel
                   |                            |dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42240


  parent reply	other threads:[~2010-07-22 11:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-01 16:18 [Bug c/42240] New: wrong Epilog on nacked function stefan dot dreyer at yahoo dot de
2009-12-01 16:19 ` [Bug c/42240] " stefan dot dreyer at yahoo dot de
2009-12-01 16:44 ` stefan dot dreyer at yahoo dot de
2009-12-01 16:45 ` stefan dot dreyer at yahoo dot de
2009-12-01 16:46 ` stefan dot dreyer at yahoo dot de
2009-12-01 16:58 ` [Bug target/42240] " j at uriah dot heep dot sax dot de
2009-12-01 19:21 ` [Bug target/42240] wrong epilogue on naked function a dot kaiser at gmx dot net
2009-12-01 19:38 ` a dot kaiser at gmx dot net
2009-12-01 22:50 ` a dot kaiser at gmx dot net
2010-07-22 11:26 ` anitha dot boyapati at atmel dot com [this message]
2010-07-26  6:49 ` anitha dot boyapati at atmel dot com
2010-07-26 17:37 ` eric dot weddington at atmel dot com
2010-07-26 17:41 ` [Bug target/42240] [4.3/4.4 Regression, avr] " eric dot weddington at atmel dot com
2010-07-27 11:35 ` anitha dot boyapati at atmel dot com
2010-07-31 10:22 ` [Bug target/42240] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100722112619.30932.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).