public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/13552] New: gcc 'optimizes' position of label
@ 2004-01-03  1:45 jbemmel at zonnet dot nl
  2004-01-03  1:56 ` [Bug optimization/13552] " pinskia at gcc dot gnu dot org
  2004-01-03 11:15 ` jbemmel at zonnet dot nl
  0 siblings, 2 replies; 3+ messages in thread
From: jbemmel at zonnet dot nl @ 2004-01-03  1:45 UTC (permalink / raw)
  To: gcc-bugs

Compile this code, with or without '-Os' flag:

#include <string.h>

static int initialStack[1024];

void f()
{
   memcpy( initialStack, &&stackcode, 16 );
   __asm__ volatile ( "jmp *%0" : : "r"(initialStack) : "memory" );
stackcode:
   __asm__ volatile ( "movl %0, %%cr3" :  : "a"(0) : "memory" );
}

In the assembly listing generated with '-Os' the stackcode label (L2) is moved 
to the beginning of the function, instead of the 'movl %0, %%cr3' instruction.
Without '-Os' it works as expected

-- 
           Summary: gcc 'optimizes' position of label
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbemmel at zonnet dot nl
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: 3.3.1 (mingw32 special 20030804-1)
GCC target triplet: 3.3.1 (mingw32 special 20030804-1)


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug optimization/13552] gcc 'optimizes' position of label
  2004-01-03  1:45 [Bug optimization/13552] New: gcc 'optimizes' position of label jbemmel at zonnet dot nl
@ 2004-01-03  1:56 ` pinskia at gcc dot gnu dot org
  2004-01-03 11:15 ` jbemmel at zonnet dot nl
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-03  1:56 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-03 01:56 -------
The code is invalid as you cannot jump out of an asm.
Also you cannot depend on the optimizing compilers not moving labels.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug optimization/13552] gcc 'optimizes' position of label
  2004-01-03  1:45 [Bug optimization/13552] New: gcc 'optimizes' position of label jbemmel at zonnet dot nl
  2004-01-03  1:56 ` [Bug optimization/13552] " pinskia at gcc dot gnu dot org
@ 2004-01-03 11:15 ` jbemmel at zonnet dot nl
  1 sibling, 0 replies; 3+ messages in thread
From: jbemmel at zonnet dot nl @ 2004-01-03 11:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jbemmel at zonnet dot nl  2004-01-03 11:15 -------
Subject: Re:  gcc 'optimizes' position of label

> ------- Additional Comments From pinskia at gcc dot gnu dot org
2004-01-03 01:56 -------
> The code is invalid as you cannot jump out of an asm.

OK, but the case is also valid without the 'jmp' instruction. For the sake
of discussion let's assume valid ASM

> Also you cannot depend on the optimizing compilers not moving labels.

Well, then perhaps this is a feature request and not a bug: I would like gcc
to not move user-defined labels beyond 'asm volatile' statements, especially
ones of which the address is taken





-- 


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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-01-03 11:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-03  1:45 [Bug optimization/13552] New: gcc 'optimizes' position of label jbemmel at zonnet dot nl
2004-01-03  1:56 ` [Bug optimization/13552] " pinskia at gcc dot gnu dot org
2004-01-03 11:15 ` jbemmel at zonnet dot nl

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).