<div dir="ltr"><div>I wrote earlier:<br><br>>I'm having a circular dependency problem with LLVMBuildPhi.<br>><br>>The short explanation:<br>><br>>The
 compiler is complaining when I build the LLVMValueRef array for<br>> LLVMAddIncoming that one of the values is undefined, because it's 
actually assigned <br>> later in the basic block.<br><br>I think I just realized the correct solution: move LLVMAddIncoming() to the  end of basic block?<br><br></div>Toshi<br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 15, 2017 at 5:08 PM, Toshiyasu Morita <span dir="ltr"><<a href="mailto:toshi@tensyr.com" target="_blank">toshi@tensyr.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div>I'm having a circular dependency problem with LLVMBuildPhi.<br><br></div>The short explanation:<br><br></div>The compiler is complaining when I build the LLVMValueRef array for LLVMAddIncoming that one of the values is undefined, because it's actually assigned later in the basic block.<br><br></div>The long explanation:<br><br></div>I have a loop init basic block which contains:<br><br>// Initialize loop counter<br>        counter_init = LLVMConstInt(LLVMInt64Type(), count, 0);<br>..<br></div>The loop body basic block contains:<br><br>// Set the counter<br>        sprintf(tmp_name, "tmp%d", *tmp_num++);<br>        counter = LLVMBuildPhi(builder, LLVMInt64Type(), tmp_name);<br>        phi_values[0] = counter_init;<br>        phi_values[1] = counter_next;<br>        phi_basic_blocks[0] = loop_init;<br>        phi_basic_blocks[1] = loop_body;<br>        LLVMAddIncoming(data3_pntr, phi_values, phi_basic_blocks, 2);<br><br>// Decrement the counter<br>        sprintf(tmp_name, "tmp%d", *tmp_num++);<br>        counter_next = LLVMBuildAdd(builder, counter, LLVMConstInt(LLVMInt64Type(), -1, 1), tmp_name);<br><br></div>When this code is compiled, a warning is issued:<br><br>capi_test.c:1520:16: error: ‘counter_next’ is used uninitialized in this function [-Werror=uninitialized]<br>  phi_values[1] = counter_next;<br><br></div>What is the correct way to break this circular dependency?<br><br></div>Toshi<br><br><div><div><div><br><br></div></div></div></div>
</blockquote></div><br></div>