I guess I didn't have a clear question.<br><br>Suppose we have BB1 and BB2 both point to BB3.<br>BB1 has variable x. BB2 also as variable x.<br>BB3 will have PHINode for x with 2 value from BB1 and BB2.<br>BB1   BB2<br>
   \       /<br>     BB3 <br><br>Now if BB1 and BB2 is extracted into a function<br>(using ExtractCodeRegion), they will be replaced by<br>a basic block called codeRepl (which has a call to the extracted<br>function).<br>
codeRepl<br>     |<br>    BB3<br><br>The problem is that the PHINode in BB3 still has 2 values x, <br>both from codeRepl. That's wrong because BB3 has only 1 successors,<br>which is codeRepl. In fact, there is NO way to update PhiNode, <br>
because all the x are from ONE node, codeRepl.<br>So the function ExtractCodeRegion doesn't work in this example.<br><br>My solution for this is before extracting BB1 and BB2, I split the PHINode<br>in BB3 into another basic block<br>
BB1   BB2<br>
   \       /<br>
   PhiBB<br>      
|<br>      BB<br>And extract BB1, BB2 and PhiBB.<br>If you have any ideas or if you think this will not work, please let me know.<br>Thanks.<br>Vu<br><br><br><div class="gmail_quote">On Tue, Jan 25, 2011 at 12:33 AM, Vu Le <span dir="ltr"><<a href="mailto:vmle@ucdavis.edu">vmle@ucdavis.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi all,<br>I have problem with ExtractCodeRegion (CodeExtractor.cpp).<br>My original program is as follows.<br>
bb:<br>  ...<br>  %tmp.15 = load %struct.MYSQL_ROWS** %3, align 4<br>  ...<br>bb1:<br>  ...<br>  %tmp.1 = load %struct.MYSQL_ROWS** %6, align 4<br>
  ...<br>bb4:                                              ; preds = %bb1, %bb, %entry<br>  %tmp.0 = phi %struct.MYSQL_ROWS* [ null, %entry ], [ %tmp.15, %bb ], [ %tmp.1, %bb1 ]<br><br>%tmp.0 is the PHINode whose value is from entry, bb and bb1.<br>

After extracting bb and bb1 into new function, the program becomes<br><br>codeRepl:                                         ; preds = %entry<br>  call void @mysql_data_seek_bb(%struct.MYSQL_DATA* %1, i64 %row, %struct.MYSQL_ROWS** %tmp.15.loc, %struct.MYSQL_ROWS** %tmp.1.loc)<br>

<b>  %tmp.15.reload = load %struct.MYSQL_ROWS** %tmp.15.loc<br>  %tmp.1.reload = load %struct.MYSQL_ROWS** %tmp.1.loc<br></b>  br label %bb4<br><br>bb4:                                              ; preds = %codeRepl, %entry<br>

<b>  %tmp.0 = phi %struct.MYSQL_ROWS* [ null, %entry ], [ %tmp.15.reload, %codeRepl ], [ %tmp.1.reload, %codeRepl ]<br><br></b>bb4 now has only 2 predecessors since bb and bb1 are replaced by codeRepl.<br>The PHINode in bb4, on the other hand, still has 3 incoming values and that make the assertion failed.<br>

I do want to extract this code region into function. Does anyone have a solution for this?<br>Thanks a lot.<br><font color="#888888">Vu<br><br><br><br><br><br>
</font></blockquote></div><br>