pythonic
pythonic

Reputation: 21605

Identify enclosing loop of a block in 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.

Upvotes: 8

Views: 1691

Answers (1)

JohnTortugo
JohnTortugo

Reputation: 6625

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

Upvotes: 6

Related Questions