At 2013-08-25 02:10:02,"Tobias Grosser" <tobias@grosser.es> wrote:<br>>On 08/23/2013 08:25 AM, Star Tan wrote:<br>>> Hi all,<br>>><br>>><br>>> I have attached a patch file to fix up the CodeGen assert fail, which is also reported in a recent bug  http://llvm.org/bugs/show_bug.cgi?id=16944<br>><br>>Hi Star Tan,<br>><br>>thanks for looking into this bug. The patch itself looks good and the <br>>testcase is nicely small.<br>><br>>However, when running the test with 'opt' I get:<br>><br>>PHINode should have one entry for each predecessor of its parent basic <br>>block!<br>>   %indvar = phi i64 [ 0, %entry ], [ %0, %for.inc ]<br>><br>>So the IR in the test case itself is already incorrect.<br><br>Sorry for the stupid mistake. I have attached a new patch file!>Also, I am a little unhappy with the fact that we need to run <br><br>>-polly-opt-isl to reproduce this bug. I would very much prefer to find a <br>>test case that only runs 'opt %loadPolly -polly-codegen  < %s'. This ensures<br>>that changes in -polly-opt-isl can not accidentally stop this test case <br>>from testing the code path you fixed in this patch.<br><br>Yes, you are right. But it seems difficult to construct a testcase that will show this bug using only "opt %loadPolly -polly-codegen".<br>Our testcase fails with the following command:<br>$ opt %loadPolly -basicaa -polly-opt-isl -polly-codegen test.ll<br><br>but it works well with the following commands:<br>$ opt %loadPolly -basicaa -polly-opt-isl -S -o test_1.ll test.ll<br>$ opt %loadPolly -basicaa -polly-codegen test_1.ll<br><br>The key of producing the bug is to construct a stmt_guard statment, so it will call codegen((clast_guard *)). Preliminary investigation shows that the  'stmt_guard' occurs only if we run opt-isl before codegen.  Sorry I have not found such a testcase by now.<br><br>Can anyone provide some hints about the stmt_guard as used in lib/CodeGen/CodeGeneration.cpp:955<br>  if (CLAST_STMT_IS_A(stmt, stmt_root))<br>    assert(false && "No second root statement expected");<br>  else if (CLAST_STMT_IS_A(stmt, stmt_ass))<br>    codegen((const clast_assignment *)stmt);<br>  else if (CLAST_STMT_IS_A(stmt, stmt_user))<br>    codegen((const clast_user_stmt *)stmt);<br>  else if (CLAST_STMT_IS_A(stmt, stmt_block))<br>    codegen((const clast_block *)stmt);<br>  else if (CLAST_STMT_IS_A(stmt, stmt_for))<br>    codegen((const clast_for *)stmt);<br>  else if (CLAST_STMT_IS_A(stmt, stmt_guard))<br>    codegen((const clast_guard *)stmt);    // this is the branch we want to go.<br><br>>> The assert fail is caused by those LoopInfo updates added in r181987.<br>>> Note that the LoopInfo of MergeBlock has been updated in the function "SplitBlock", so it should not be updated again in CodeGen.<br>>><br><br>Star Tan