I have some problems of getting the index of a basic block.
for (Function::iterator II = F.begin(), EE = F.end(); II != EE; ++II, ++ii)
{ BasicBlock* BB=II;
I have segfaults or cannot use complex structures of several methods that I found in LLVM. Do you know how to use as simply as possible the methods found at :
http://llvm.org/doxygen/Instructions_8h_source.html#l02136
http://llvm.org/doxygen/EdgeBundles_8cpp_source.html#l00078
Or something equivalent? I just want to get an ID of the basic blocks.
Thank you !
As Eli Bendersky pointed out in the comment above, it depends on your interpretation of index. If you are just interested in unique identifier for the basic block, basic block's name is unique in a Function. You can get that using
BB->getName()
There are other types of IDs associated with basic blocks that are dependent on the nature of your algorithm. For example, if you are writing a dominator tree construction algorithm using the iterative finger algorithm by Keith Cooper, you will associate each basic block with an incremental ID in inverse depth first order. This ID is not a part of the BasicBlock struct and should be maintained by you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With