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

             Bug #: 51447
           Summary: global register variable definition incorrectly
                    removed as dead code
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: pitchuman...@atmel.com


Global register variable assignment(ptr = func) in the test case below seem to
be removed as dead code during CSE. As per the gcc manual, global register
variable should not be removed even if it appears to be dead. 

http://gcc.gnu.org/onlinedocs/gcc/Global-Reg-Vars.html

Discussion in gcc mailing list:
http://gcc.gnu.org/ml/gcc-help/2011-12/msg00057.html


Test case:

register void *ptr asm("rbx") ;

void testfn1(void* func)
{
  ptr = func;
  goto *(ptr);
}

Options: -S -O1

-- snip of assembly generated --
        .globl  testfn1
        .type   testfn1, @function
testfn1:
.LFB0:
        jmp     *%rdi
.LFE0:
        .size   testfn1, .-testfn1
-- snip end --

Reply via email to