Re: Function Referencing in C

Dave Gillespie <synaptx!thymus!daveg@uunet.UU.NET>
Wed, 30 Jun 1993 18:10:17 GMT

          From comp.compilers

Related articles
Function Referencing in C (1993-06-29)
Re: Function Referencing in C (1993-06-30)
Re: Function Referencing in C synaptx!thymus!daveg@uunet.UU.NET (Dave Gillespie) (1993-06-30)
| List of all articles for this month |

Newsgroups: comp.compilers
From: Dave Gillespie <synaptx!thymus!daveg@uunet.UU.NET>
Keywords: C, tools
Organization: Compilers Central
References: 93-06-084
Date: Wed, 30 Jun 1993 18:10:17 GMT

Eric Martinson writes:
> We are looking for a tool that will allow us to scan many (very many) C
> source files to determine which functions are no longer used.
> [If you're compiling them on a Unix system, I've often hacked up a little
> cross-referencer which uses nm, sort, and some awk scripts ... -John]

GCC has a debug switch, "-dr" I believe, that tells it to dump its RTL
(intermediate code). I once wrote a call grapher in a few minutes that
ran GCC and then picked out the function-call cookies from the RTL.
If you look at a sample RTL file, you'll see that every function
call uses the same idiom. It's also easy to identify calls through
function pointers.

You'll need to find the set of functions whose address is taken.
You may be able to get that from prior knowledge; otherwise, look
for "symbol_ref" cookies whose arguments are function names and
which are not themselves the arguments of "call"s.

-- Dave

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.