This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/11830] New: Unnecessary call to an empty function


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Unnecessary call to an empty function
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alga at rgai dot hu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-unknown-elf

If a (non-virtual) function doesn't have any instructions or the caller
function(s) are not dependent on the result of the called function
(which is hard to identify), then the function call instruction is
unnecessary at the caller.
The unit-at-a-time algorithm doesn't solve this problem either.

--- c example ---
int a,b;
int get(int i)
{
  return i;
}
void foo()
{
  a=10;
  b=get(a);
}

--- arm code ---
get:
 mov pc, lr <- RETURN
foo:
 ldr r2, .L3
 mov r3, #10
 mov ip, sp
 stmfd sp!, {fp, ip, lr, pc}
 mov r0, r3
 str r3, [r2, #0]
 sub fp, ip, #4
 bl get <- OLD
 ldr r3, .L3+4
 str r0, [r3, #0]
 ldmea fp, {fp, sp, pc} 

--- possible solution ---
get:
 mov pc, lr <- RETURN
foo:
 ldr r2, .L3
 mov r3, #10
 mov ip, sp
 stmfd sp!, {fp, ip, lr, pc}
 mov r0, r3
 str r3, [r2, #0]
 sub fp, ip, #4
 ldr r3, .L3+4
 str r0, [r3, #0]
 ldmea fp, {fp, sp, pc}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]