corert/Documentation/how-to-debug-compiler-depen...

3.1 KiB

Debugging Compiler Dependency Analysis

The general technique is to identify what node is missing from the graph or is erroneously present in the graph, and change the dependency analysis logic to adjust the graph. This document describes the various ways of debugging to identify what's happening.

Analysis techniques for the dependency graph.

  1. Use the ILCompiler-DependencyGraph-Viewer tool (if running on Windows). This tool is located in src\ILCompiler.DependencyAnalysisFramework\ILCompiler-DependencyGraph-Viewer
  • This is the only convenient way to examine the graph while also simultaneously debugging the compiler.
  • While this is currently Windows only due to use of WinForms, it would be fairly straightforward to make a command line based tool.
  1. Pass command line switches to the compiler to generate a dependency graph dgml file. This will produce the same data as is viewable in the viewer tool, but in a textual xml format.
  • Future efforts may make the xml file loadable by the viewer tool.
  1. Instrument the compiler dependency analysis. (This may be necessary in cases where the viewer is unable to provide sufficient information about why the graph is structured as it is.)

ILCompiler-DependencyGraph-Viewer

This application allows viewing the dependency graph produced by the CoreRT compilation.

Usage instructions:

  1. Launch the process as an administrator
  2. Run the compiler
  • The compiler can be run to completion, or stopped.
  1. Explore through the graph

Graphs View

  • Choose one of the graphs that appears in the Dependency Graphs view to explore. As compilers execute, new graphs will automatically appear here.
  • The set of graphs loaded into the process is limited by available memory space. To clear the used memory, close all windows of the application.

Graph View

  • In the Dependency Graph view, enter a regular expression in the text box, and then press ""Filter"". This will display a list of the nodes in the graph which have names which match the regular expression.
  • Commonly, if there is a object file symbol associated with the node it should be used as part of the regular expression. See the various implementations of GetName in the compiler for naming behavior.
  • Additionally, the event source marking mode assigns an Id to each node, and that is found as the mark object on the node, so if a specific id is known, just type that in, and it will appear in the window. (This is for use when using this tool in parallel with debugging the compiler.

Single Node Exploration

Once the interesting node(s) have been identified in the dependency graph window, select one of them, and then press Explore.

  • In the Node Explorer window, the Dependent nodes (the ones which dependend on the current node are the nodes displayed above, and the Dependee nodes (the nodes that this node depends on) are displayed below. Each node in the list is paired with a textual reason as to why that edge in the graph exists.
  • Select a node to explore further and press the corresponding button to make it happen.