Code compaction passes?

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?

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.

Robert

Yes, definitely! This has been on my long-term to-do list for a while, but if you have the time/energy, go for it! Note that LLVM already has functionality for extracting single entry multiple exit regions into separate functions, so you really only need to implement the process of detecting equivalent regions, and let the extraction code do the rest.

--Owen

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.

-Chris