Reputation: 2737
How can I check whether there are array accesses in a basic block?
For example, I want to find a[i] in the following example.
Eg:
for(i=0;i<n;i++)
a[i]=a[i+1]+i;
Upvotes: 1
Views: 316
Reputation: 578
Array accesses are modeled by getelementptr
instructions.
So you could iterate over the Basic Block with something like:
for (BasicBlock::iterator i = blk->begin(), e = blk->end(); i != e; ++i) {
if(isa<GetElementPtrInst>(i)) {
// process it here
}
}
Upvotes: 1