<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>