[LLVMdev] Byte code libraries and linking

Chris Lattner sabre at nondot.org
Wed Nov 15 10:15:22 PST 2006


On Wed, 15 Nov 2006, [ISO-8859-1] Pertti Kellomäki wrote:
> To follow up on my own post:
>> The only concern here is that this brings in all of libc, but I
>> suppose it should be easy enough to run dead code elimination on
>> linked.bc to shake out the unused bits?
>
> Cursory browsing of LLVM optimization passes did not turn up
> anything directly applicable, at least "opt -adce" and "opt -globaldce"
> did not reduce the size of the byte code file much.
>
> What I am looking for is a transformation that would take a
> starting point in a byte code file (e.g. %main()), determine
> the transitive closure of the functions and globals that can be reached
> from there, and drop everything else. In the Lisp world it would
> be called a tree shaker, I don't know how you guys would call it.
>
> If such a pass does not exist, it would seem like a perfect candidate
> for playing around with pass writing, so I would be happy to
> implement it if need be.

try running opt -internalize -globaldce.

In particular, the internalize pass will tell LLVM that you have the 
"whole program" (i.e. it can mark all functions as static other than 
main).  This allows the globaldce pass to be more aggressive.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/


More information about the llvm-dev mailing list