Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8328470

[lworld] C2: can_eliminate_allocation() wrongly removes allocation by skipping over phi merging an InlineTypeNode

XMLWordPrintable

      PhaseMacroExpand::can_eliminate_allocation() checks if an allocation can be removed. There is some special code for inline types which checks if an InlineTypeNode is only used in flat fields of another InlineTypeNode:

      https://github.com/openjdk/valhalla/blob/9b79f47af28ca02f380fd32786a8d3d75d7a1937/src/hotspot/share/opto/macro.cpp#L698-L713

      If that is the case, we can eliminate the allocation. If the InlineTypeNode has other usages, we need to continue to check them. However, instead of pushing `use` to the list, we directly push the use `u` of the InlineTypeNode. When re-iterating the while-loop, we continue with the use of `u` and skip processing `u` entirely which could lead to the situation of wrongly removing an allocation which is still required. This can lead to null pointer accesses.

      This was discovered after JDK-8293541 which enables more allocations to be checked and removed by can_eliminate_allocation().

            chagedorn Christian Hagedorn
            chagedorn Christian Hagedorn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: