Charitha Saumya via llvm-dev
2020-Oct-21 02:38 UTC
[llvm-dev] LLVM Regions after SplitEdge
Hi, I have the following CFG. [image: Screenshot from 2020-10-20 22-24-45.png] Regions for this CFG are. [0] entry => if.end12 [1] if.else => if.end 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, [image: Screenshot from 2020-10-20 22-25-07.png] However my regions are still, [0] entry => if.end12 [1] if.else => if.end 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? Also what is the correct way to recalculate LLVM regions after modifying the controlflow? Following approach gave me a runtime error when run on the function after splitting the if.then -> if.end12 , RegionInfo &RI = getAnalysis<RegionInfoPass>().getRegionInfo(); DominatorTree &DT getAnalysis<DominatorTreeWrapperPass>().getDomTree(); DominanceFrontier &DF getAnalysis<DominanceFrontierWrapperPass>().getDominanceFrontier(); PostDominatorTree &PDT getAnalysis<PostDominatorTreeWrapperPass>().getPostDomTree(); DT.recalculate(F); PDT.recalculate(F); RI.recalculate(F, &DT, &PDT, &DF); Runtime error, Stack dump: 0. Program arguments: /home/charitha/workspace/llvm_install/bin/opt -load /home/charitha/workspace/llvm-project/build/lib/LLVMCFMerger.so -cfmerger -view-cfg-only 1. Running pass 'Function Pass Manager' on module '<stdin>'. 2. Running pass 'Merge similar control flow for divergence reduction' on function '@foo' #0 0x000056094798307a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/charitha/workspace/llvm_install/bin/opt+0x299407a) #1 0x0000560947980df4 llvm::sys::RunSignalHandlers() (/home/charitha/workspace/llvm_install/bin/opt+0x2991df4) #2 0x0000560947980f43 SignalHandler(int) (/home/charitha/workspace/llvm_install/bin/opt+0x2991f43) #3 0x00007fc487be33c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x153c0) #4 0x0000560946b7a6a0 llvm::RegionInfoBase<llvm::RegionTraits<llvm::Function>>::isRegion(llvm::BasicBlock*, llvm::BasicBlock*) constThanks, Charitha -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201020/78d998c0/attachment-0001.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2020-10-20 22-24-45.png Type: image/png Size: 25919 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201020/78d998c0/attachment-0002.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: Screenshot from 2020-10-20 22-25-07.png Type: image/png Size: 25391 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201020/78d998c0/attachment-0003.png>