How can the total number of arrays be counted in a C program ?
The array declarations in LLVM IR correspond to alloca type of operation. So
int a[10];
corresponds to
%a = alloca [10 x i32], align 4
in LLVM IR.
But I also noticed that
int j = 0;
also corresponds to an alloca instruction
%j = alloca i32, align 4
So how to count the number of alloca instructions that correspond only to arrays ?
EDIT:
for (Function::iterator i = F.begin(), e = F.end(); i != e; ++i)
{
for (BasicBlock::iterator ii =(*i).begin(), ii_e = (*i).end(); ii != ii_e; ++ii)
{
Instruction *n = dyn_cast<Instruction>(&*ii);
for( int num = 0; num < n->getNumOperands(); ++num)
if(isa<ArrayType>(n->getOperand(num)->getType()))
{
// doesn't work
errs()<<"yayayayay Array\n";
}
}
}