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

Chandler Carruth chandlerc at gmail.com
Sun Mar 25 03:48:00 PDT 2012


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.

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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120325/96c764ca/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: inliner-nuke-dead-bbs.diff
Type: text/x-patch
Size: 4339 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120325/96c764ca/attachment.bin>


More information about the llvm-commits mailing list