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 afterJDK-8293541 which enables more allocations to be checked and removed by can_eliminate_allocation().
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
- relates to
-
JDK-8293541 [lworld] IR verification fails for TestLWorld::test109_sharp and test110_sharp
- Resolved