title: Good algorithm for generating call graphs?
body: <p>I am writing some code to generate call graphs for a particular intermediate representation <strong>without executing it by statically scanning the IR code</strong>. The IR code itself is not too complex and I have a good understanding of what function call sequences look like so all I need to do is trace the calls. I am currently doing it the obvious way:</p>
  
  <ul>
  <li>Keep track of where we are</li>
  <li>If we encounter a function call, branch to that location, execute and come back</li>
  <li>While branching put an edge between the caller and the callee</li>
  </ul>
  
  <p>I am satisfied with where I am getting at but I want to make sure that I am not reinventing the wheel here and face corner cases. I am wondering if there are any accepted good algorithms (and/or design patterns) that do this efficiently? </p>
  
  <p><strong>UPDATE:</strong>
  The IR code is a byte-code disassembly from a homebrewn Java-like language and looks like the <a href="http://jasmin.sourceforge.net/guide.html" rel="nofollow">Jasmine specification</a>.</p>