<div>Hi, Anna</div><div><br></div><div> First, thank your for your time for commenting this code!</div><div> There is one more subtle difference. This is the major one that ended up the code this way. It is the difference between CFGBlock::iterator and Function::iterator, as shown in the code excerpt below.</div>
<div><br></div><div>Function::iterator. Each iterator I is used directly as BasicBlock * here.</div><div> // Initialize the roots list</div><div> for (typename FT::iterator I = F.begin(), E = F.end(); I != E; ++I) {</div>
<div> if (std::distance(GraphTraits<FT*>::child_begin(I),</div><div> GraphTraits<FT*>::child_end(I)) == 0)</div><div> addRoot(I);</div><div><br></div><div>CFG::iterator. Each iterator has the CFGBlock ** type. In this case we need a pointer indirection here.</div>
<div><div> // Initialize the roots list</div><div> for (typename FT::iterator I = F.begin(), E = F.end(); I != E; ++I) {</div><div> if (std::distance(GraphTraits<FT*>::child_begin(*I),</div><div> GraphTraits<FT*>::child_end(*I)) == 0)</div>
<div> addRoot(*I);</div></div><div><br></div><div>One approach is to change CFG or Function implementation to make them have the same interface. But I am afraid this may cause two many changes to the code base. I would love to hear your comments. Is there a decent solution that does not require too many changes to the code?</div>
<div><br></div><div>--</div><div>Guoping</div><div><br></div><br><div class="gmail_quote">2011/11/2 Anna Zaks <span dir="ltr"><<a href="mailto:ganna@apple.com">ganna@apple.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Guoping,<br>
<br>
It seems that the only reason why you need to copy the recalculate function is that the names for the entry block in the clang CFG and LLVM function are different. Is that correct? (The bool parameter does not seem to be used..)<br>
<br>
A simple solution to that would be to make sure that we have the same name in both. I suggest using getEntryBlock().<br>
<br>
On llvm's side, it would involve changing the recalculate function to use getEntryBlock instead of front(). Looks like they are the same thing.<br>
<br>
On Clang's side, we could just rename CFG::getEntry() -> CFG::getEntryBlock().<br>
<br>
Thanks!<br>
Anna.<br>
<div><div class="h5">On Oct 29, 2011, at 3:58 PM, Guoping Long wrote:<br>
<br>
> Hi, Ted<br>
><br>
> The preliminary refactoring of the dominators patch for clang based on the more efficient LLVM core implementation is done. Attached is the patch. I am not very satisfied with this version because it relies a ugly hack to deal with the subtle differences between LLVM Function and Clang CFG. Since this version requires some modifications to include/llvm/Analysis/Dominators.h, so there is also a patch for llvm.<br>
><br>
> While I believe there should be a cleaner way to do this, I do not know how to achieve that. Please let me know your comments. I shall continue to improve until it become satisfactory.<br>
> Regards.<br>
><br>
> ----<br>
> Guoping<br>
</div></div>> <dominators-clang.patch><dominators-llvm.patch>_______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote></div><br>