I am using the ObjectWeb ASM library found here to parse jar files and read the bytecode of methods. I have already written code to generate a control flow graph from the bytecode instruction lists.
However, after I perform some operations on the control flow graph I want to be able to "export" the control flow graph back to a (simple) list of instructions. In theory, I should be able to iterate through all of the basic blocks and print out the instructions that are stored in each one. However, doing this will most likely result in the instructions being in a very bizarre order because there is no ordering to the list of basic blocks.
I have read that forming a "dominator tree" can help figure out the best (most logical) ordering of the basic blocks. I'm not sure how to calculate the dominator tree and how to use it to sort the basic blocks.
Does anyone have any knowledge on this topic that they could share?
Thanks.