title: How to use "graph" option on gcc's -fdump-tree?
body: <p>I'm trying to see if gcc can provide more information that I can use to create Control Flow Graph from a C source code and then use it to check which path is taken by an executed test case from Gcov <code>.gcov</code> output. So far my best candidate is using <code>-fdump-tree-cfg</code> with <code>lineno</code> option (<code>-fdump-tree-cfg-lineno</code>) but the resulting file is still limiting for me since node informations are separated for each function. Something like this:</p>
  
  <pre><code>;; Function main (main, funcdef_no=13, decl_uid=3054, cgraph_uid=13, symbol_order=13)
  
  Removing basic block 7
  Merging blocks 5 and 6
  ;; 1 loops found
  ;;
  ;; Loop 0
  ;;  header 0, latch 1
  ;;  depth 0, outer -1
  ;;  nodes: 0 1 2 3 4 5 6
  ;; 2 succs { 3 4 }
  ;; 3 succs { 5 }
  ;; 4 succs { 5 }
  ;; 5 succs { 6 }
  ;; 6 succs { 1 }
  main ()
  {
    int number;
    int D.3066;
  
    &lt;bb 2&gt; [0.00%]:
    [evenodd.c:7:5] printf ([evenodd.c:7:12] "\nEnter a number: ");
    [evenodd.c:8:5] scanf ([evenodd.c:8:11] "%d", [evenodd.c:8:5] &amp;number);
    [evenodd.c:10:2] number.0_1 = number;
    [evenodd.c:10:2] checkNegative (number.0_1);
    [evenodd.c:12:17] number.1_2 = number;
    [evenodd.c:12:17] number.2_3 = (unsigned int) number.1_2;
    [evenodd.c:12:17] _4 = number.2_3 &amp; 1;
    [evenodd.c:12:7] if (_4 == 0)
      goto &lt;bb 3&gt;; [0.00%]
    else
      goto &lt;bb 4&gt;; [0.00%]
  
    &lt;bb 3&gt; [0.00%]:
    [evenodd.c:13:9] number.3_5 = number;
    [evenodd.c:13:9] printf ([evenodd.c:13:16] "%d is Even\n", number.3_5);
    [0:0] goto &lt;bb 5&gt;; [0.00%]
  
    &lt;bb 4&gt; [0.00%]:
    [evenodd.c:15:9] number.4_6 = number;
    [evenodd.c:15:9] printf ([evenodd.c:15:16] "%d is Odd\n", number.4_6);
  
    &lt;bb 5&gt; [0.00%]:
    [evenodd.c:18:9] D.3066 = 0;
    number = {CLOBBER};
  
  &lt;L4&gt; [0.00%]:
    return D.3066;
  
  }
  
  
  
  ;; Function checkNegative (checkNegative, funcdef_no=14, decl_uid=3057, cgraph_uid=14, symbol_order=14)
  
  ;; 1 loops found
  ;;
  ;; Loop 0
  ;;  header 0, latch 1
  ;;  depth 0, outer -1
  ;;  nodes: 0 1 2 3 4 5
  ;; 2 succs { 3 4 }
  ;; 3 succs { 5 }
  ;; 4 succs { 5 }
  ;; 5 succs { 1 }
  checkNegative (int number)
  {
    &lt;bb 2&gt; [0.00%]:
    [evenodd.c:23:4] if (number &lt; 0)
      goto &lt;bb 3&gt;; [0.00%]
    else
      goto &lt;bb 4&gt;; [0.00%]
  
    &lt;bb 3&gt; [0.00%]:
    [evenodd.c:24:9] printf ([evenodd.c:24:16] "%d is Negative\n", number);
    [0:0] goto &lt;bb 5&gt;; [0.00%]
  
    &lt;bb 4&gt; [0.00%]:
    [evenodd.c:26:9] printf ([evenodd.c:26:16] "%d is Positive\n", number);
  
    &lt;bb 5&gt; [0.00%]:
    [evenodd.c:28:1] return;
  
  }
  </code></pre>
  
  <p>This means that my parser need to recognize each function call inside the <code>main</code> function and then merge their node information which is a pretty daunting task for me.</p>
  
  <p>So I came accross the <code>-graph</code> option for <code>-fdump-tree</code> from <a href="https://gcc.gnu.org/onlinedocs/gcc/Developer-Options.html#Developer-Options" rel="nofollow noreferrer">this documentation</a> but I have no idea how to use it. As the doc describe it: </p>
  
  <pre><code>‘graph’
  
      For each of the other indicated dump files (-fdump-rtl-pass),
    dump a representation of the control flow graph suitable for 
    viewing with GraphViz to file.passid.pass.dot. Each function in
    the file is pretty-printed as a subgraph, so that GraphViz can
    render them all in a single plot.
  
      This option currently only works for RTL dumps, and the RTL
    is always dumped in slim form.
  </code></pre>
  
  <p>I don't know how GraphViz works but since it's able to render all function's subgraph as a single plot (I assume that it means all subgraph is merged with the main graph as a single graph), it means that the information provided by <code>-graph</code> is more complete and ease the process of creating the Control Flow Graph.</p>
  
  <p>Since I can't understand what it means, I tried using the option as it is (<code>-fdump-tree-cfg-lineno-graph</code>) but the result is still the same as <code>-fdump-tree-cfg-lineno</code>'s result.</p>
  
  <p>How do I use it?</p>