[LLVMdev] Code compaction passes?

Chris Lattner sabre at nondot.org
Thu Jan 17 22:00:59 PST 2008

On Jan 17, 2008, at 6:29 PM, Robert Zeh wrote:

> I'm inlining a bunch of C++ code, and I'm ending up with a bunch of
> basic blocks like this:
> filter441.i:		; preds = %unwind432.i
> 	call void @_ZSt9terminatev( )
> 	unreachable
> filter453.i:		; preds = %unwind444.i
> 	call void @_ZSt9terminatev( )
> 	unreachable
> It seems like I should be safe to merge these, but I can't find a pass
> to do so.  Going over the open projects page it looks like code
> compaction is still an open project. Is it?

Yep, for really simple stuff like this, it would probably be  
sufficient just to have a pass that unifies all of the 'unreachable'  
blocks.  Given this, existing passes like simplifycfg will probably  
merge trivially common code like this.

> I've read "Compiler Techniques for Code Compaction" and I was
> wondering if there would be any interest in a compaction pass that was
> a bit simpler then some of what's described in the paper.

That would be really great.  Code size is something that is  
increasingly important to some people, but noone (to my knowledge) has  
really tackled it or started measuring/experimenting yet.

One thing that has been on my todo list forever is to disable the tail  
duplication pass and see what performance regressions we get.  Almost  
everything that our current tail dup pass does can be done better in  
other places, and would provide more predictable code size results.


More information about the llvm-dev mailing list