Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Identify enclosing loop of a block in LLVM

Tags:

c++

c

llvm

For LLVM Basic Blocks, represented by class BasicBlock, how can I identify which nearest loop (if any) contains that block . And I want to identify this inside a runOnModule pass.

like image 341
pythonic Avatar asked Aug 23 '12 12:08

pythonic


1 Answers

You can register an LoopInfo dependency and use getLoopFor(BasicBlock *BB):

Loop* llvm::LoopInfo::getLoopFor(const BasicBlock *BB) const 

You can check the documentation in: http://llvm.org/doxygen/classllvm_1_1LoopInfo.html#a4abca289c73cd09487e05d11d9f7d877

like image 77
JohnTortugo Avatar answered Nov 19 '22 18:11

JohnTortugo