RFR: 8271202: C1: assert(false) failed: live_in set of first block must be empty

Yi Yang yyang at openjdk.java.net
Wed Jul 28 07:13:41 UTC 2021


Hi, I'm trying to fix [JDK-8271202](https://bugs.openjdk.java.net/browse/JDK-8271202). A local variable(smallinvoc) is defined in B3 and only used in B14, so it oughts to have a short lifetime. But its lifetime has been unconditionally extended since -XX:+DeoptimizeALot(**Just removing this may be also a simpler and safer fix? Not sure if it's acceptable**), making it propagate to almost the whole remaing IR.

https://github.com/openjdk/jdk/blob/ecd445562f8355704a041f9eca0e87dc85a7f44c/src/hotspot/share/ci/ciMethod.cpp#L373-L379

![image](https://user-images.githubusercontent.com/5010047/127277954-2a64d87e-2981-4d74-8001-c7efeb000a10.png)


A virtual register(v603) that represents this variable is located in B13 live_in set, which propagated to B1 live_out set.

When B1 merges state with B16 and B19, it found that this variable in new_state(B16) was empty, so B1 invalidates the corresponding local slot.

https://github.com/openjdk/jdk/blob/ecd445562f8355704a041f9eca0e87dc85a7f44c/src/hotspot/share/c1/c1_Instruction.cpp#L826-L838

I think we should invalidate this slot only when their types are mismatched. Otherwise, Phi will not be generated, B19 live_gen set will not contain this variable, because of which this variable is alive in B1 live_in. B1 live_in will eventually backward propagate to B20 live_in set, it avoids being killed by B19 live_gen, which causes the crash.


Block 1
live_in:
603 616 617 618 619 620 621 622 
live_out:
603 616 617 618 619 620 621 622 
live_gen:
620 
live_kill:
648 649 650

Block 16
live_in:
603 616 617 618 619 620 621 622 
live_out:
603 616 617 618 619 620 621 622 
live_gen:
616 617 618 619 620 621 622 
live_kill:
620 654 655 656 657 

Block 19
live_in:
603 
live_out:
603 616 617 618 619 620 621 622 
live_gen:

live_kill:
0 1 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 


Block 20
live_in:
603 
live_out:
603 
live_gen:

live_kill:
577 578

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

Commit messages:
 - whitespace
 - try

Changes: https://git.openjdk.java.net/jdk/pull/4916/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=4916&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8271202
  Stats: 92 lines in 3 files changed: 86 ins; 0 del; 6 mod
  Patch: https://git.openjdk.java.net/jdk/pull/4916.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/4916/head:pull/4916

PR: https://git.openjdk.java.net/jdk/pull/4916


More information about the hotspot-compiler-dev mailing list