RFR: 8290850: C2: create_new_if_for_predicate() does not clone pinned phi input nodes resulting in a broken graph

Tobias Hartmann thartmann at openjdk.org
Tue Dec 6 09:09:48 UTC 2022


On Thu, 1 Dec 2022 12:26:56 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

> The test cases of this bug reveal the same problem with `PhaseIdealLoop::create_new_if_for_predicate()` as in [JDK-8271954](https://bugs.openjdk.org/browse/JDK-8271954) (reusing pinned data nodes for different UCT paths into the UCT phi - see PR description of https://github.com/openjdk/jdk/pull/5185). While JDK-8271954 only fixed the usage of `PhaseIdealLoop::create_new_if_for_predicate()` for one specific case in loop unswitching, we now need this fix for other usages of `PhaseIdealLoop::create_new_if_for_predicate()` as well. I've found failing cases for most of the usages but I think we should always do a proper cloning as originally added with JDK-8271954. This is what a propose with this patch.
> 
> To always do this cloning, I've replaced the `UnswitchingAction` by a `rewire_uncommon_proj_phi_inputs` bool that is false by default but can be set if we should only do a rewiring (we can still do the rewiring for the slow loop as previously done with `UnswitchingAction::SlowLoopRewiring`, also see https://github.com/openjdk/jdk/pull/5185 for more details). However, the current fix does not update ctrl for the slow loop nodes - I've fixed that.
> 
> I've reused the implementation of `clone_data_nodes_for_fast_loop()` but refactored and split that method into multiple methods to reuse some of them for the ctrl update of the slow loop nodes.
> 
> Thanks,
> Christian

Great job in finding tests for (most of) theses cases! The fix looks reasonable to me.

Since this is a regression from [JDK-8252372](https://bugs.openjdk.org/browse/JDK-8252372), the bug should have affects version 17, right?

src/hotspot/share/opto/loopPredicate.cpp line 244:

> 242: // Recursively find all input nodes with the same ctrl.
> 243: Unique_Node_List PhaseIdealLoop::find_nodes_with_same_ctrl(Node* node, const ProjNode* ctrl) {
> 244:   Unique_Node_List nodes_with_same_ctrl;

Did you check if there is a `ResourceMark` close by?

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

Marked as reviewed by thartmann (Reviewer).

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


More information about the hotspot-compiler-dev mailing list