https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68002

            Bug ID: 68002
           Summary: retaining unused static functions at -O1
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Joost.VandeVondele at mat dot ethz.ch
  Target Milestone: ---

There are uses for retaining unused static functions even if optimising, e.g.
coverage testing. Right now these function are removed at -O1 and there is no
flag to keep them. 

In https://gcc.gnu.org/ml/gcc-help/2015-10/msg00110.html Marc Glisse suggested
to introduce a flag similar to -fkeep-inline-functions.

c testcase:
> cat test.c
static void foo() { }

> gcc -c -O0 test.c ; nm test.o
0000000000000000 t foo
> gcc -c -O1 test.c ; nm test.o

Fortran testcase:

> cat test.f90
MODULE foo
 PRIVATE
CONTAINS
 SUBROUTINE bar()
 END SUBROUTINE bar
END MODULE

I'll try to come up with a patch based on Marc's suggestion

Reply via email to