From 514797897e9c2512e96b89400ed540e45a1a65b2 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Fri, 10 Nov 2017 00:12:34 +0100 Subject: [PATCH] Optimized effective live ranges further to improce uplift speed --- .../kickc/model/LiveRangeVariablesEffective.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/dk/camelot64/kickc/model/LiveRangeVariablesEffective.java b/src/main/java/dk/camelot64/kickc/model/LiveRangeVariablesEffective.java index 845eb99dc..bc7651684 100644 --- a/src/main/java/dk/camelot64/kickc/model/LiveRangeVariablesEffective.java +++ b/src/main/java/dk/camelot64/kickc/model/LiveRangeVariablesEffective.java @@ -21,10 +21,8 @@ public class LiveRangeVariablesEffective { */ private Map procedureCallPaths; - /** - * Normal variable live ranges. - */ - private LiveRangeVariables liveRangeVariables; + /** Variables (normally) alive at each statement by index. */ + private Map> statementsLiveVariables; /** * Information about which procedures reference which variables. @@ -34,8 +32,13 @@ public class LiveRangeVariablesEffective { public LiveRangeVariablesEffective(Program program, Map procedureCallPaths, LiveRangeVariables liveRangeVariables, VariableReferenceInfos referenceInfo) { this.program = program; this.procedureCallPaths = procedureCallPaths; - this.liveRangeVariables = liveRangeVariables; this.referenceInfo = referenceInfo; + this.statementsLiveVariables = new LinkedHashMap<>(); + for (ControlFlowBlock block : program.getGraph().getAllBlocks()) { + for (Statement statement : block.getStatements()) { + statementsLiveVariables.put(statement.getIndex(), liveRangeVariables.getAlive(statement)); + } + } } /** @@ -163,7 +166,7 @@ public class LiveRangeVariablesEffective { * @return All combinations of variables alive at the statement */ public AliveCombinations getAliveCombinations(Statement statement) { - List aliveAtStmt = liveRangeVariables.getAlive(statement); + Collection aliveAtStmt = statementsLiveVariables.get(statement.getIndex()); CallPaths callPaths; Collection referencedInProcedure; ControlFlowBlock block = program.getStatementBlocks().getBlock(statement);