<div dir="ltr"><div>Hi,</div><div><br></div><div>I have the following CFG. <br></div><div><div><img src="cid:ii_kgirxy5t0" alt="Screenshot from 2020-10-20 22-24-45.png" style="margin-right: 0px;" width="290" height="278"><br></div><div>Regions for this CFG are.</div><div>[0] entry => if.end12<br>  [1] if.else => if.end</div></div><div>An optimization pass I am working on requires if.then block to be a LLVM region. Therefore I used the SplitEdge function (in BasicBlockUtils) to split the edge if.then -> if.end12. Now I have the following CFG,</div><div><div><img src="cid:ii_kgis3y4p1" alt="Screenshot from 2020-10-20 22-25-07.png" style="margin-right: 0px;" width="212" height="273"></div><div>However my regions are still,</div><div>[0] entry => if.end12<br>  [1] if.else => if.end</div><div><br></div><div>if.then=>if.then.split is not a region. Can someone explain why this is not a LLVM region? It's a single entry single exit control flow. Why is it not a region?</div><div><br></div><div><br></div><div>Also what is the correct way to recalculate LLVM regions after modifying the controlflow?</div><div><br></div><div>Following approach gave me a  runtime error when run on the function after splitting the  if.then -> if.end12 ,</div><div><br></div><div>    RegionInfo &RI = getAnalysis<RegionInfoPass>().getRegionInfo();<br>    DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();<br>    DominanceFrontier &DF = getAnalysis<DominanceFrontierWrapperPass>().getDominanceFrontier();<br>    PostDominatorTree &PDT = getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree();<br><br>     DT.recalculate(F);<br>     PDT.recalculate(F);<br>     RI.recalculate(F, &DT, &PDT, &DF);<br>    </div><div>Runtime error,</div><div><br></div><div>Stack dump:<br>0.      Program arguments: /home/charitha/workspace/llvm_install/bin/opt -load /home/charitha/workspace/llvm-project/build/lib/LLVMCFMerger.so -cfmerger -view-cfg-only <br>1.    Running pass 'Function Pass Manager' on module '<stdin>'.<br>2.     Running pass 'Merge similar control flow for divergence reduction' on function '@foo'<br> #0 0x000056094798307a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/charitha/workspace/llvm_install/bin/opt+0x299407a)<br> #1 0x0000560947980df4 llvm::sys::RunSignalHandlers() (/home/charitha/workspace/llvm_install/bin/opt+0x2991df4)<br> #2 0x0000560947980f43 SignalHandler(int) (/home/charitha/workspace/llvm_install/bin/opt+0x2991f43)<br> #3 0x00007fc487be33c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0)<br> #4 0x0000560946b7a6a0 llvm::RegionInfoBase<llvm::RegionTraits<llvm::Function> >::isRegion(llvm::BasicBlock*, llvm::BasicBlock*) const</div><div><br></div><div>Thanks,</div><div>Charitha<br></div><div></div></div></div>