public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/24332]  New: asm label declaration may be missing aliasing info
@ 2005-10-12 15:33 cbowler at ca dot ibm dot com
  2005-10-12 16:08 ` [Bug middle-end/24332] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: cbowler at ca dot ibm dot com @ 2005-10-12 15:33 UTC (permalink / raw)
  To: gcc-bugs

sparky% gcc -v
Reading specs from
/.../torolab.ibm.com/fs/projects/vabld/run/gcc/aix/gcc-3.3.2/aix52/bin/../lib/gcc-lib/powerpc-ibm-aix5.1.0.0/3.3.2/specs
Configured with: ../gcc-3.3.2/configure --disable-nls
Thread model: aix
gcc version 3.3.2

t.c:

int j asm("i");
int i;

int main() {
  i = 5;
  j = 6;
  int k = i;
  j = 7;
  return k;
}

sparky% gcc t.c
sparky% a.out
sparky% echo $?
6
sparky% gcc t.c -O
sparky% a.out
sparky% echo $?
5

In the opt case I expect a result of 6.

The problem, I suspect, is that the compiler is not aliasing 'i' and 'j' to
each other for the optimizer.  The write 'j=6' appears dead in this case, and
the optimizer is likely to remove it.

You may consider this user error, however, the compiler is able to detect this
problem because it knows 'i' and 'j' have the same symbol name.  Consequently I
suggest either an error diagnostic be issued, or the symbols should be aliased
together for the optimizer.


-- 
           Summary: asm label declaration may be missing aliasing info
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cbowler at ca dot ibm dot com


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


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

* [Bug middle-end/24332] asm label declaration may be missing aliasing info
  2005-10-12 15:33 [Bug c/24332] New: asm label declaration may be missing aliasing info cbowler at ca dot ibm dot com
@ 2005-10-12 16:08 ` pinskia at gcc dot gnu dot org
  2005-10-12 23:22 ` wilson at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-12 16:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2005-10-12 16:08 -------
This is a weird case as both are in common space.

If we do the following:
int j asm("i") = 0;
int i = 0;

We cannot assemble the source at all.

I don't know what to say about this case.  Someone else will have to comment on
it.

But IIRC asm("xxx"); just renames the variable and gives no other information
to GCC.


-- 


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


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

* [Bug middle-end/24332] asm label declaration may be missing aliasing info
  2005-10-12 15:33 [Bug c/24332] New: asm label declaration may be missing aliasing info cbowler at ca dot ibm dot com
  2005-10-12 16:08 ` [Bug middle-end/24332] " pinskia at gcc dot gnu dot org
@ 2005-10-12 23:22 ` wilson at gcc dot gnu dot org
  2009-09-26 11:30 ` rguenth at gcc dot gnu dot org
  2010-05-09 16:51 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: wilson at gcc dot gnu dot org @ 2005-10-12 23:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from wilson at gcc dot gnu dot org  2005-10-12 23:22 -------
It isn't true that variable i and variable j have the same symbol name.  The
asm means that the symbol name of j will be "i" always.  However, the symbol
name of i will be the string "i" with various target dependent and command line
option dependent transformations applied.

The easiest way to see this is to compile with -fleading-underscore and note
that we now have two variables "i" and "_i", and there is no aliasing. 
-fleading-underscore is the default for some targets.

Since these symbol name string transformations are applied late, when emitting
assembly language, it currently isn't possible for the compiler to do anything
useful here.

Also, like most GCC extensions, no one probably considered the implications of
what should happen with an input like this, so we can't really do much more
than say that it is undefined, and that you can't expect any particular
behaviour here.

Ideally we should emit an error message, but it is probably not possible with
current sources, and probably not worth the trouble to rewrite to make it
possible.


-- 


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


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

* [Bug middle-end/24332] asm label declaration may be missing aliasing info
  2005-10-12 15:33 [Bug c/24332] New: asm label declaration may be missing aliasing info cbowler at ca dot ibm dot com
  2005-10-12 16:08 ` [Bug middle-end/24332] " pinskia at gcc dot gnu dot org
  2005-10-12 23:22 ` wilson at gcc dot gnu dot org
@ 2009-09-26 11:30 ` rguenth at gcc dot gnu dot org
  2010-05-09 16:51 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-09-26 11:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2009-09-26 11:30 -------
Undefined / invalid.

There is no sensible way to deal with aliasing here without pessimizing every
legitimate use.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org


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


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

* [Bug middle-end/24332] asm label declaration may be missing aliasing info
  2005-10-12 15:33 [Bug c/24332] New: asm label declaration may be missing aliasing info cbowler at ca dot ibm dot com
                   ` (2 preceding siblings ...)
  2009-09-26 11:30 ` rguenth at gcc dot gnu dot org
@ 2010-05-09 16:51 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-05-09 16:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-05-09 16:51 -------
If we'd have a symbol table we could detect the clash and emit a diagnostic.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hubicka at gcc dot gnu dot
                   |                            |org
           Keywords|                            |accepts-invalid


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


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

* [Bug middle-end/24332] asm label declaration may be missing aliasing info
       [not found] <bug-24332-4@http.gcc.gnu.org/bugzilla/>
@ 2012-01-11 14:49 ` rguenth at gcc dot gnu.org
  0 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-11 14:49 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2012-01-11
     Ever Confirmed|0                           |1

--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-11 14:49:16 UTC ---
Confirmed.  Though

int j asm("i");
int i;

is probably as valid as

int i;
int i;

if we decide so.  With two initializers it gets invalid (same with
-fno-common?).


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

end of thread, other threads:[~2012-01-11 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-12 15:33 [Bug c/24332] New: asm label declaration may be missing aliasing info cbowler at ca dot ibm dot com
2005-10-12 16:08 ` [Bug middle-end/24332] " pinskia at gcc dot gnu dot org
2005-10-12 23:22 ` wilson at gcc dot gnu dot org
2009-09-26 11:30 ` rguenth at gcc dot gnu dot org
2010-05-09 16:51 ` rguenth at gcc dot gnu dot org
     [not found] <bug-24332-4@http.gcc.gnu.org/bugzilla/>
2012-01-11 14:49 ` rguenth at gcc dot gnu.org

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