<div dir="ltr"><div>Hi,<br><br></div><div>   I am trying to prune some uninteresting llvm ir branches, corresponding to the *if-else* condition in the source code. And here is the procedures:<br><br></div><div>   1. Get the BasicBlock containing the BranchInst which has 2 successors(in order to keep consistent with the source code I am using the llvm ir without any optimizations, so SelectInst/SwitchInst/PHINode is absent), one of which should be pruned; let's name these 2 branches bb1 and bb2 and bb2 is to be pruned.<br>
</div><div>   2. Find their nearest common post dominator, bb_join<br></div><div>   3. Create a new branInst bb_new whose successors are bb1 and bb_join; replace the original BranchInst with bb_new<br></div><div>   4. For bb2, dropAllReferences && eraseFromParent<br>
</div><div><br></div><div>However since bb2 also has several successors(before bb_join), which are not pruned together with bb2. Is there any existing API to remove them as well?<br><br></div><div>Also, in Step 4, could I just call bb2->eraseFromParent() without dropping any references? I am a bit confused with the function dropAllReferences.<br>
<br></div><div>Thanks,<br></div><div>Hongxu Chen<br></div><br>   <br></div>