public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/60214] New: Variables with same DECL_ASSEMBLER_NAME are treated as different variables
@ 2014-02-15 19:25 johannespfau at gmail dot com
  2014-02-17 12:25 ` [Bug middle-end/60214] " rguenth at gcc dot gnu.org
  2014-02-17 16:09 ` jakub at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: johannespfau at gmail dot com @ 2014-02-15 19:25 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60214
           Summary: Variables with same DECL_ASSEMBLER_NAME are treated as
                    different variables
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johannespfau at gmail dot com

This bug was first found in GDC, the D frontend for GCC, but it's also
reproducable with GCC. Consider the following test case:

------------------------
int test9_1 asm ("test_эльфийские_письмена_9") = 0;
extern int test9_1_e asm ("test_эльфийские_письмена_9");

int main()
{
    test9_1 = 42;
    return test9_1_e == 42;
}
------------------------

compile on ARM with 'gcc -O2 test.c' and run the test program. It returns '0',
indicating test9_1_e is not 42. It works on ARM without optimization and on
x86_64 with or without optimization. I'm not sure if this is ARM specific or
only specific to architectures with section anchors. 'gcc -O2 test.c
-fno-section-anchors' works as expected.

What happens is that the first store to test9_1 is moved after the read from
test9_1_e.

I guess it's suspicious that test9_1_e is read directly from
test_эльфийские_письмена_9 but the store to test9_1 evolves a section anchor.

Here's the relevant generated ASM:
------------------------
ldr    r2, .L2
ldr    r3, .L2+4
ldr    r0, [r2]
mov    r2, #42
subs    r1, r0, r2
rsbs    r0, r1, #0
adcs    r0, r0, r1
str    r2, [r3]
bx    lr
[...]
.word    test_эльфийские_письмена_9
.word    .LANCHOR0
[...]
.LANCHOR0 = . + 0
    .type    test_эльфийские_письмена_9, %object
    .size    test_эльфийские_письмена_9, 4
test_эльфийские_письмена_9:
    .space    4
------------------------


In case the C code is invalid / unspecified please advise how we could get the
desired behaviour for the GDC frontend. Currently we emit the VAR_DECLS in the
same way as without the 'asm ("test_эльфийские_письмена_9")' part except we set
DECL_ASSEMBLER_NAME accordingly.
>From gcc-bugs-return-443663-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Feb 15 19:27:28 2014
Return-Path: <gcc-bugs-return-443663-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12758 invoked by alias); 15 Feb 2014 19:27:28 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12740 invoked by uid 48); 15 Feb 2014 19:27:25 -0000
From: "johannespfau at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/60214] Variables with same DECL_ASSEMBLER_NAME are treated as different variables
Date: Sat, 15 Feb 2014 19:27:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: johannespfau at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60214-4-pP0uCXV2HF@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60214-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60214-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg01420.txt.bz2
Content-length: 300

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`214

--- Comment #1 from Johannes Pfau <johannespfau at gmail dot com> ---
Sorry, I forgot to add that this only happens if the test9_1 variable has got
an initializer. However this is almost always the case for GDC/D as we have
default initialization.


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

* [Bug middle-end/60214] Variables with same DECL_ASSEMBLER_NAME are treated as different variables
  2014-02-15 19:25 [Bug middle-end/60214] New: Variables with same DECL_ASSEMBLER_NAME are treated as different variables johannespfau at gmail dot com
@ 2014-02-17 12:25 ` rguenth at gcc dot gnu.org
  2014-02-17 16:09 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-02-17 12:25 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Yes, that's a know "deficiency" in alias-analysis.

*** This bug has been marked as a duplicate of bug 25140 ***


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

* [Bug middle-end/60214] Variables with same DECL_ASSEMBLER_NAME are treated as different variables
  2014-02-15 19:25 [Bug middle-end/60214] New: Variables with same DECL_ASSEMBLER_NAME are treated as different variables johannespfau at gmail dot com
  2014-02-17 12:25 ` [Bug middle-end/60214] " rguenth at gcc dot gnu.org
@ 2014-02-17 16:09 ` jakub at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-02-17 16:09 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Well, the question is if we want to change the status quo here at all, looking
through the asm redirects breaks quite a lot of things as well, consider
PR59626 etc.  I'd say it is a user error to refer to the same underlying
variable through different variables.


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

end of thread, other threads:[~2014-02-17 16:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-15 19:25 [Bug middle-end/60214] New: Variables with same DECL_ASSEMBLER_NAME are treated as different variables johannespfau at gmail dot com
2014-02-17 12:25 ` [Bug middle-end/60214] " rguenth at gcc dot gnu.org
2014-02-17 16:09 ` jakub 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).