On Nov 26, 2007, at 12:02 AM, Christopher Lamb wrote:

> 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?

clang should mark static functions as internal functions to help  
optimizer identify dead code.

llvm-gcc emits
        define internal void @bar(i32 %v) { ... }
where as clang emits
        define void @bar(i32 %v) { ... }

        
-
Devang



_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

Reply via email to