[llvm-commits] PATCH: Teach the function cloner to prune dead basic blocks

Chris Lattner clattner at apple.com
Sun Mar 25 12:17:39 PDT 2012


On Mar 25, 2012, at 3:48 AM, Chandler Carruth wrote:

> After r153410, the function cloner started to fold some constants in the cloned code after all of the basic blocks had been cloned into the new function. As a consequence, this folding could form dead basic blocks that need to actually be pruned (rather than simply avoiding cloning them in the first place).
> 
> Doing this requires changing the value map used by the cloner to use WeakVHs rather than TrackingVHs. It seems this more closely matches the intended semantics any ways, as several clients of these value maps check for null mapped values as a way of detected deleted entities. With WeakVH this "just works". Without it, it requires an expensive update of the value mapping in order to delete code from it.

WeakVH is *substantially* more expensive than AssertingVH.  The later is just a raw pointer when assertions are disabled.  The former requires densemap operations when a WeakVH is modified.

Why is it expensive to update the value mapping?

-Chris

> I've attached a patch which does this, and adds the necessary code to fold terminators and prune dead blocks in the function cloner. I suspect there are a few other simplifications that can be made due tho the WeakVH model, but I've not looked for them aggressively. Everything seems to work with this. What do others think?
> <inliner-nuke-dead-bbs.diff>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list