Skip to content

Commit

Permalink
[GR-52596] Restrict applicability of RemoveOpaqueValuePhase.
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosaner committed Mar 11, 2024
1 parent 95cb384 commit ac2a5f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ public final class GraphState {
private static final EnumSet<StageFlag> LOW_TIER_MANDATORY_STAGES = EnumSet.of(
StageFlag.LOW_TIER_LOWERING,
StageFlag.EXPAND_LOGIC,
StageFlag.ADDRESS_LOWERING);
StageFlag.ADDRESS_LOWERING,
StageFlag.REMOVE_OPAQUE_VALUES);
private static final EnumSet<StageFlag> ENTERPRISE_MID_TIER_MANDATORY_STAGES = EnumSet.of(
StageFlag.OPTIMISTIC_ALIASING,
StageFlag.GUARD_LOWERING,
Expand Down Expand Up @@ -629,6 +630,7 @@ public enum StageFlag {
PARTIAL_REDUNDANCY_SCHEDULE,
ADDRESS_LOWERING,
FINAL_CANONICALIZATION,
REMOVE_OPAQUE_VALUES,
TARGET_VECTOR_LOWERING,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ public boolean mustApply(GraphState graphState) {

@Override
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
return NotApplicable.unlessRunBefore(this, StageFlag.FINAL_CANONICALIZATION, graphState);
return NotApplicable.ifAny(
NotApplicable.unlessRunBefore(this, StageFlag.FINAL_CANONICALIZATION, graphState),
NotApplicable.unlessRunBefore(this, StageFlag.REMOVE_OPAQUE_VALUES, graphState));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import jdk.graal.compiler.nodes.GraphState;
import jdk.graal.compiler.nodes.StructuredGraph;
import jdk.graal.compiler.nodes.GraphState.StageFlag;
import jdk.graal.compiler.nodes.extended.OpaqueValueNode;
import jdk.graal.compiler.nodes.spi.CoreProviders;
import jdk.graal.compiler.phases.BasePhase;
Expand All @@ -38,7 +39,9 @@
public class RemoveOpaqueValuePhase extends BasePhase<CoreProviders> {
@Override
public Optional<NotApplicable> notApplicableTo(GraphState graphState) {
return ALWAYS_APPLICABLE;
return NotApplicable.ifAny(
NotApplicable.unlessRunAfter(this, StageFlag.LOW_TIER_LOWERING, graphState),
NotApplicable.ifApplied(this, StageFlag.REMOVE_OPAQUE_VALUES, graphState));
}

@Override
Expand All @@ -52,4 +55,10 @@ protected void run(StructuredGraph graph, CoreProviders context) {
opaque.replaceAtUsagesAndDelete(opaque.getValue());
}
}

@Override
public void updateGraphState(GraphState graphState) {
super.updateGraphState(graphState);
graphState.setAfterStage(StageFlag.REMOVE_OPAQUE_VALUES);
}
}

0 comments on commit ac2a5f8

Please sign in to comment.