Search in sources :

Example 21 with DeadCodeEliminationPhase

use of org.graalvm.compiler.phases.common.DeadCodeEliminationPhase in project graal by oracle.

the class PolymorphicInliningTest method getGraph.

@SuppressWarnings("try")
private StructuredGraph getGraph(final String snippet, final boolean eagerInfopointMode) {
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("InliningTest", new DebugDumpScope(snippet, true))) {
        ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
        Builder builder = builder(method, AllowAssumptions.YES, debug);
        StructuredGraph graph = eagerInfopointMode ? parse(builder, getDebugGraphBuilderSuite()) : parse(builder, getEagerGraphBuilderSuite());
        try (DebugContext.Scope s2 = debug.scope("Inlining", graph)) {
            PhaseSuite<HighTierContext> graphBuilderSuite = eagerInfopointMode ? getCustomGraphBuilderSuite(GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withFullInfopoints(true)) : getDefaultGraphBuilderSuite();
            HighTierContext context = new HighTierContext(getProviders(), graphBuilderSuite, OptimisticOptimizations.ALL);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
            new CanonicalizerPhase().apply(graph, context);
            new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "Graph");
            new CanonicalizerPhase().apply(graph, context);
            new DeadCodeEliminationPhase().apply(graph);
            return graph;
        }
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) Builder(org.graalvm.compiler.nodes.StructuredGraph.Builder) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 22 with DeadCodeEliminationPhase

use of org.graalvm.compiler.phases.common.DeadCodeEliminationPhase in project graal by oracle.

the class GraalCompiler method emitFrontEnd.

/**
 * Builds the graph, optimizes it.
 */
@SuppressWarnings("try")
public static void emitFrontEnd(Providers providers, TargetProvider target, StructuredGraph graph, PhaseSuite<HighTierContext> graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, Suites suites) {
    DebugContext debug = graph.getDebug();
    try (DebugContext.Scope s = debug.scope("FrontEnd");
        DebugCloseable a = FrontEnd.start(debug)) {
        HighTierContext highTierContext = new HighTierContext(providers, graphBuilderSuite, optimisticOpts);
        if (graph.start().next() == null) {
            graphBuilderSuite.apply(graph, highTierContext);
            new DeadCodeEliminationPhase(DeadCodeEliminationPhase.Optionality.Optional).apply(graph);
            debug.dump(DebugContext.BASIC_LEVEL, graph, "After parsing");
        } else {
            debug.dump(DebugContext.INFO_LEVEL, graph, "initial state");
        }
        suites.getHighTier().apply(graph, highTierContext);
        graph.maybeCompress();
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After high tier");
        MidTierContext midTierContext = new MidTierContext(providers, target, optimisticOpts, profilingInfo);
        suites.getMidTier().apply(graph, midTierContext);
        graph.maybeCompress();
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After mid tier");
        LowTierContext lowTierContext = new LowTierContext(providers, target);
        suites.getLowTier().apply(graph, lowTierContext);
        debug.dump(DebugContext.BASIC_LEVEL, graph, "After low tier");
        debug.dump(DebugContext.BASIC_LEVEL, graph.getLastSchedule(), "Final HIR schedule");
        graph.logInliningTree();
    } catch (Throwable e) {
        throw debug.handle(e);
    } finally {
        graph.checkCancellation();
    }
}
Also used : MidTierContext(org.graalvm.compiler.phases.tiers.MidTierContext) LowTierContext(org.graalvm.compiler.phases.tiers.LowTierContext) DebugContext(org.graalvm.compiler.debug.DebugContext) DebugCloseable(org.graalvm.compiler.debug.DebugCloseable) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)

Example 23 with DeadCodeEliminationPhase

use of org.graalvm.compiler.phases.common.DeadCodeEliminationPhase in project graal by oracle.

the class EATestBase method prepareGraph.

@SuppressWarnings("try")
protected void prepareGraph(String snippet, boolean iterativeEscapeAnalysis) {
    ResolvedJavaMethod method = getResolvedJavaMethod(snippet);
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope(getClass(), method, getCodeCache())) {
        graph = parseEager(method, AllowAssumptions.YES, debug);
        context = getDefaultHighTierContext();
        new InliningPhase(new CanonicalizerPhase()).apply(graph, context);
        new DeadCodeEliminationPhase().apply(graph);
        canonicalizeGraph();
        new PartialEscapePhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(), null, graph.getOptions()).apply(graph, context);
        postEACanonicalizeGraph();
        returnNodes = graph.getNodes(ReturnNode.TYPE).snapshot();
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : PartialEscapePhase(org.graalvm.compiler.virtual.phases.ea.PartialEscapePhase) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) InliningPhase(org.graalvm.compiler.phases.common.inlining.InliningPhase) DeadCodeEliminationPhase(org.graalvm.compiler.phases.common.DeadCodeEliminationPhase) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

DeadCodeEliminationPhase (org.graalvm.compiler.phases.common.DeadCodeEliminationPhase)23 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)16 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)16 DebugContext (org.graalvm.compiler.debug.DebugContext)11 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)10 InliningPhase (org.graalvm.compiler.phases.common.inlining.InliningPhase)9 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)8 Node (org.graalvm.compiler.graph.Node)6 Invoke (org.graalvm.compiler.nodes.Invoke)4 HashMap (java.util.HashMap)3 FrameState (org.graalvm.compiler.nodes.FrameState)3 LoweringPhase (org.graalvm.compiler.phases.common.LoweringPhase)3 InstalledCode (jdk.vm.ci.code.InstalledCode)2 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)2 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)2 LoopsData (org.graalvm.compiler.loop.LoopsData)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)2 Builder (org.graalvm.compiler.nodes.StructuredGraph.Builder)2