Trevor Harmon
2010-Mar-15 23:22 UTC
[LLVMdev] CFG as DOT: where do node addresses come from?
Hi, The -dot-cfg option of opt will write a diagram of an analyzed function's CFG to DOT format. If you then open the DOT file, you will see that the BasicBlocks are uniquely identified with hexadecimal addresses. For example, an edge from one block to another may look like: Node0x10026b0:s0 -> Node0x1004c20; I've been trying to figure out where these hexadecimal addresses come from. I've been up and down the code but remain at a loss. I can see where GraphWriter.h is actually writing the strings to the DOT file, and I can see that some of the DOT data is coming from DOTGraphTraits in CFGPrinter.h. But the hexadecimal addresses are a mystery. I thought perhaps a BasicBlock method, such as getName, might be producing the addresses, but no. Can anyone shed some light on this for me? Thanks, Trevor
Jakob Stoklund Olesen
2010-Mar-16 00:57 UTC
[LLVMdev] CFG as DOT: where do node addresses come from?
On Mar 15, 2010, at 4:22 PM, Trevor Harmon wrote:> Hi, > > The -dot-cfg option of opt will write a diagram of an analyzed > function's CFG to DOT format. If you then open the DOT file, you will > see that the BasicBlocks are uniquely identified with hexadecimal > addresses. For example, an edge from one block to another may look like: > > Node0x10026b0:s0 -> Node0x1004c20; > > I've been trying to figure out where these hexadecimal addresses come > from. I've been up and down the code but remain at a loss. I can see > where GraphWriter.h is actually writing the strings to the DOT file, > and I can see that some of the DOT data is coming from DOTGraphTraits > in CFGPrinter.h. But the hexadecimal addresses are a mystery. I > thought perhaps a BasicBlock method, such as getName, might be > producing the addresses, but no.>From GraphWriter.h:O << "\tNode" << static_cast<const void*>(Node) << " [shape=record,"; Printing a pointer on a raw_ostream produces a hexadecimal address.