RFR: 8348645: IGV: visualize live ranges

Roberto Castañeda Lozano rcastanedalo at openjdk.org
Tue Feb 11 10:30:29 UTC 2025


This changeset extends IGV with live range visualization. It introduces live ranges as first-class IGV entities and displays them along with the control-flow graph in the CFG view. Visualizing liveness information should hopefully make C2's register allocator easier to understand, diagnose, debug, and enhance.

Live ranges are visible in C2 phases where liveness information is available, that is, phases `Initial liveness` to `Fix up spills` at IGV print level 4 or greater. For example, running a debug build of the JVM as follows:


java -Xbatch -XX:CompileCommand=IGVPrintLevel,java.util.HashMap::newNode,4


produces the following visualization for the `Initial spilling` phase:

![initial-spilling](https://github.com/user-attachments/assets/1ecf74f5-92a8-4866-b1ec-2323bb0c428e)

Live ranges are first-class IGV entities, meaning that the user can:

- search, select, and extract them;

![search-extract](https://github.com/user-attachments/assets/8e0dfa59-457f-49cb-b2b5-1d202301c79d)

- examine their properties in the `Properties` window or via tooltips;

![properties](https://github.com/user-attachments/assets/68d2d23b-b986-4d2e-835c-b661bce0de23)

- navigate to related IGV entities via a pop-up menu; and

![popup](https://github.com/user-attachments/assets/21de2fef-d36a-42d5-b828-2696d87a18ea)

- program filters that act om them according to their properties.

![filters](https://github.com/user-attachments/assets/e993b067-d0b8-452c-a885-c4e601e31e1c)

Live ranges are connected to nodes by a use-def relation: a node can define zero or one live ranges, and use multiple live ranges; a live range can be defined and used by multiple nodes. Consequently, a live range in IGV is visible if and only if all its related nodes are visible (fully or semi-transparently). Generally, the start and end of a live range are vertically aligned with the nodes that first define and last use the live range. To reflect accurately the semantics of Phi nodes w.r.t. liveness, the visualization treats live ranges related by Phi nodes specially: live ranges used by a Phi node end at the bottom of the corresponding predecessor basic blocks, whereas live ranges defined by a Phi node start at the top of the node's basic block. The following screenshot shows an example of a Phi node (`48 Phi`) joining live ranges `L8` and `L13` into `L15`:

![phi](https://github.com/user-attachments/assets/0ef8aa1d-523d-4391-982e-6b74c2016a3c)

The changeset extends the IGV graph printing logic in HotSpot to emit basic block-level liveness information and live range properties such as associated register mask, score, and type. IGV propagates then the block-level liveness information down to individual nodes. Passing only basic block-level liveness information makes the graph serialization compact, limiting the size increase of the corresponding graphs to around 25%.

The IGV changes do not affect layout performance significantly in the sea-of-nodes view, and only introduce a moderate overhead (of around 10%) when displaying graphs with associated live ranges in the control-flow graph view.

Thanks to Damon Fenacci and Daniel Lundén for providing valuable feedback!

#### Testing

- tier1 (windows-x64, linux-x64, linux-aarch64, and macosx-x64; release and debug mode).

- Tested IGV manually on a few selected graphs. Tested automatically that displaying thousands of graphs using different views and filter combinations does not trigger any assertion failure (by enabling assertions, instrumenting IGV to display parsed graphs eagerly, and running `java -Xbatch -XX:-TieredCompilation -XX:PrintIdealGraphLevel=4`).

-------------

Commit messages:
 - Fix def live range printing in 'Show liveness information' filter
 - Ensure basic blocks with live ranges are always visible
 - Ensure live ranges to go to from pop-up menu become visible
 - Select all live range sements and not just a representative one
 - Remove comments that are no longer needed
 - Remove unused option to use definer node ids instead of live range ids
 - Update copyright headers
 - Let phi-defined live ranges start at the top of the basic block
 - Draw segments in empty blocks
 - Complete dump of live range properties
 - ... and 32 more: https://git.openjdk.org/jdk/compare/30f71622...c5e48e46

Changes: https://git.openjdk.org/jdk/pull/23558/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=23558&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8348645
  Stats: 2430 lines in 52 files changed: 2236 ins; 108 del; 86 mod
  Patch: https://git.openjdk.org/jdk/pull/23558.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/23558/head:pull/23558

PR: https://git.openjdk.org/jdk/pull/23558


More information about the hotspot-compiler-dev mailing list