[cfe-dev] Refactoring the dominators patch for Clang
Ted Kremenek
kremenek at apple.com
Mon Nov 7 19:05:53 PST 2011
On Nov 5, 2011, at 8:10 PM, Guoping Long wrote:
> To deal with the iterator issue, either changing Clang or LLVM to use the other's iterator is too intrusive. The approach I am using is simply an interface method. On the Clang side, add this method to the CFG class:
> CFGBlock * getBlock(iterator I) { return *I; }
> While on the LLVM side, adding this method to both Function and MachineFunction classes:
> BasicBlock * getBlock(iterator I) { return I; }
> This fixes the issue.
While well intentioned, I'm not a fan of this approach. The problem is really that the dominators implementation is not generic enough. Further, should any graph structure we choose to run dominators on be required to provide a "getBlock()" method? What if we want to run dominators on a graph where there is no such notion of a "block"?
Dominators is a generic graph algorithm. Compilers are just one application of the dominator algorithm, but not the only one. Embedding the notion of basic blocks into the dominators algorithm violates the generality of the original algorithm itself.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111107/fd32cee4/attachment.html>
More information about the cfe-dev
mailing list