[cfe-dev] Elimination of dead globals (functions/variables)
Christopher Lamb
christopher.lamb at gmail.com
Mon Nov 26 00:02:29 PST 2007
With llvm-gcc the following test case
static int alive, dead;
void foo(int v) { glob_alive = v; }
int FOO() { return glob_alive; }
static void bar(int v) { gdead = v; }
static int BAR() { return dead; }
is correctly pruned down to only foo, FOO, and alive, but with the
following warnings:
warning: 'bar' defined but not used
warning: 'BAR' defined but not used
clang with -emit-llvm currently emits everything (with no warnings)
and opt isn't able to reduce it. What needs to be done by clang to
get the non-visible parts of the module stripped out? In addition to
diagnostics is clang responsible for not generating code for unused
functions, or is it simply responsible for passing some sort of
information so that opt can do the chopping?
--
Christopher Lamb
More information about the cfe-dev
mailing list