You can iterate over all the basic blocks in a Loop
object. So if you want the number statically, you can use something like this:
bool runOnLoop(Loop * L, LPPassManager &LPM) {
int Count = 0;
for (auto Iter = L->block_begin(), End = L->block_end(); Iter != End; ++Iter) {
Count += Iter->size();
}
// Do something with Count
return false;
}
If you want the dynamic count of instructions, you'd have to assign each loop a counter and then have each block in the loop increment that counter according to its size. Notice that that may lead to a block having multiple counters in case the loop is nested.