Is there any way to iterate in reverse on a LLVM Function. I've checked the docs but can't seem to find any member typedef for iterating Basic blocks ( in a function ) in reverse.
Any help will be appreciated.
Thanks, Malhar
Is there any way to iterate in reverse on a LLVM Function. I've checked the docs but can't seem to find any member typedef for iterating Basic blocks ( in a function ) in reverse.
Any help will be appreciated.
Thanks, Malhar
Sharing the working code snippet based on @arrowd suggestions:
auto bbList = &(func_ptr->getBasicBlockList()); //fetch the pointer of the list
errs()<<"reverse \n";
for(auto bb = bbList->rbegin(); bb != bbList->rend(); bb++) {
b = &(*bb);
errs() << b->getName()<<", ";
}
What is the sequence of printing the basic block names , in case there are multiple predecessors and successors ?
opposite of Reverse Post Order i.e Post - order (while iterating in reverse fashion)
I think you can call Function::getBasicBlockList() and then use
.rbegin()
andrend()
on that list.