<div dir="ltr"><div><br></div>The way I have used SplitBlockAndInsertIfThen() throws this assertion error: "Assertion `IDomNode && "Not immediate dominator specified for block!"' failed". Consider the following abstraction:<div><br></div><div>=======================<br></div><div>I1</div><div>I2</div><div>=======================<br></div><div>What I am trying to achieve is:</div><div>=======================<br></div><div>I1</div><div>I_cond</div><div> I_then1</div><div> I_then2</div><div>I_new1</div><div>I_new2</div><div>I2</div><div>=======================<br></div><div><br></div><div>In plain English</div><div> - Split the block between I1 and I2</div><div> - Insert an ICMP at the end of first block</div><div> - Add a couple of instructions (I_then1, I_then2) to the THEN block</div><div> - Add a couple of instruction at the beginning of the last block preceding I2 (I_new1, I_new2)</div><div><br></div><div><br></div><div>My code roughly looks like:</div><div><br class="gmail-Apple-interchange-newline">=======================<br></div><div><div> Instruction *I2 = I1->getNextNode(); // Next instruction</div><div> TerminatorInst *then_inst;</div><div><br></div><div> if(condition) {</div><div> Value *I_cond = builder.CreateICmpNE(_, _);</div><div><br></div><div> // Split the basic block</div><div> then_inst = SplitBlockAndInsertIfThen(I_cond, I2, false);</div><div><br></div><div> // Set the insert point before terminator of THEN block</div><div> builder.SetInsertPoint(then_inst);</div><div><br></div><div> // Add new instructions</div><div> I_then1</div><div> I_then2</div><div> }</div><div><br></div><div> // Set the insert point before the next instruction</div><div> builder.SetInsertPoint(I2);</div><div><br></div><div> // Add new instructions<br></div><div> I_new1</div><div> I_new2</div><div><br></div><div>=======================<br></div><div><br></div><div>What's wrong with my approach? How to fix it?</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span><div><div dir="ltr"><p>Thanks & Regards,</p>
<div>Dipanjan</div></div></div></span></div></div>
</div></div>