[PATCH] D48383: [Dominators] Add the DomTreeUpdater class

Chijun Sima via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 11:31:59 PDT 2018


NutshellySima created this revision.
NutshellySima added reviewers: kuhar, brzycki, dmgreen, grosser, davide.
Herald added subscribers: llvm-commits, mgorny.

This patch is the first in a series of patches related to the RFC - A new dominator tree updater for LLVM <http://lists.llvm.org/pipermail/llvm-dev/2018-June/123883.html>.

This patch introduces the DomTreeUpdater class, which provides a cleaner API to perform updates on available dominator trees (none, only DomTree, only PostDomTree, both) using different update strategies (eagerly or lazily) to simplify the updating process.

—Prior to the patch—

1. The current API is quite fragmented and different functions using these APIs need to write redundant code to manually deal with various kinds of update strategies which makes code hard to maintain.
  - Directly calling update functions of DominatorTree updates the data structure eagerly while DeferredDominance does updates lazily.
  - DeferredDominance class cannot be used when a PostDominatorTree also needs to be updated.
  - Functions receiving DT/DDT need to branch a lot which is currently necessary.
  - Functions using both DomTree and PostDomTree need to call the update function separately on both trees.
  - People need to construct an additional DeferredDominance class to use functions only receiving DDT.
2. We need to manually decide whether to erase a BasicBlock from the dominator tree when one is removed from the CFG.
3. When using lazy updating methods, the BasicBlock waiting to delete will be deleted in an unforeseeable time after being removed from the Function so the user cannot do further actions on it.
4. When we have both trees (DomTree and PostDomTree), we can try using the update information of one of them to prune updates of another to accelerate the updating process.

—After the patch—

1. The abilities of the DeferredDominance are subsumed by the new updater class. And the API user can use an enum to specify which update strategy to use.
2. The new updater class can update all the data structures it holds when the user calls the update function.
3. The new updater class will first check whether these BasicBlocks still act as a node in the holding trees then call delete to prevent further manual checks.
4. The updater class has a callbackDeleteBB function which accepts a callable to let users do additional operations on the BasicBlock before deletion.


Repository:
  rL LLVM

https://reviews.llvm.org/D48383

Files:
  include/llvm/IR/DomTreeUpdater.h
  lib/IR/CMakeLists.txt
  lib/IR/DomTreeUpdater.cpp
  unittests/IR/CMakeLists.txt
  unittests/IR/DomTreeUpdaterTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48383.152110.patch
Type: text/x-patch
Size: 53251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/c283d9df/attachment-0001.bin>


More information about the llvm-commits mailing list