public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56715] New: Explicit Reg Vars are being ignored for consts when using g++
@ 2013-03-24 23:25 goswin-v-b at web dot de
  2013-03-24 23:33 ` [Bug c++/56715] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: goswin-v-b at web dot de @ 2013-03-24 23:25 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56715
           Summary: Explicit Reg Vars are being ignored for consts when
                    using g++
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: goswin-v-b@web.de


Created attachment 29714
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29714
example source that experiences the bug

I'm trying to pass a value to an `asm' operand using a specific register for
arm with a freestanding compiler. Following the example from the info pages I
have the following code:

void foo() {
    register const int r4 asm("r4") = 0x1000;
    asm volatile("swi #1" : : "r"(r4));
}

void bar() {
    register int r4 asm("r4") = 0x1000;
    asm volatile("swi #1" : : "r"(r4));
}

Both foo() and bar() compile correct when using gcc. But when using g++ the
foo() function suddenly uses the "r3" register instead of "r4". The bar()
function remains correct.

% arm-none-eabi-g++ -v 
Using built-in specs.
COLLECT_GCC=arm-none-eabi-g++
COLLECT_LTO_WRAPPER=/usr/local/cross/libexec/gcc/arm-none-eabi/4.7.2/lto-wrapper
Target: arm-none-eabi
Configured with: ../gcc-4.7.2/configure --target=arm-none-eabi
--prefix=/usr/local/cross --disable-nls --enable-languages=c,c++
--without-headers
Thread model: single
gcc version 4.7.2 (GCC) 

% arm-none-eabi-gcc -O2 -save-temps -S bug.c         good code
% arm-none-eabi-g++ -O2 -save-temps -S bug.c         bad code

------------------------------------------------------------------
_Z3foov:
        .fnstart
.LFB0:
        @ Function supports interworking.
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        mov     r3, #4096
@ 3 "bug.c" 1
        swi #1
@ 0 "" 2
        bx      lr
------------------------------------------------------------------
The source explicitly asked for "r4" but g++ uses r3 instead.


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

end of thread, other threads:[~2013-03-25 11:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-24 23:25 [Bug c++/56715] New: Explicit Reg Vars are being ignored for consts when using g++ goswin-v-b at web dot de
2013-03-24 23:33 ` [Bug c++/56715] " pinskia at gcc dot gnu.org
2013-03-25  0:07 ` goswin-v-b at web dot de
2013-03-25  8:50 ` jakub at gcc dot gnu.org
2013-03-25 10:18 ` rguenth at gcc dot gnu.org
2013-03-25 11:11 ` goswin-v-b at web dot de
2013-03-25 11:23 ` 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).