mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-02 20:29:38 +00:00
make StatementInfos map control flow block objects instead of labelRef's (~5% compiler speedup)
This commit is contained in:
parent
1f54a91463
commit
b81349b3de
@ -276,9 +276,8 @@ public class LiveRangeVariablesEffective {
|
||||
* @return All variables effectively alive at the statement on the call-path
|
||||
*/
|
||||
public Collection<VariableRef> getEffectiveAliveAtStmt(CallPath callPath) {
|
||||
LinkedHashSet<VariableRef> effectiveAlive = new LinkedHashSet<>();
|
||||
// Add alive at call
|
||||
effectiveAlive.addAll(callPath.getAlive());
|
||||
LinkedHashSet<VariableRef> effectiveAlive = new LinkedHashSet<>(callPath.getAlive());
|
||||
// Clear out any variables referenced in the method
|
||||
effectiveAlive.removeAll(referencedInProcedure);
|
||||
// Add alive at statement
|
||||
|
@ -14,12 +14,12 @@ public class StatementInfos {
|
||||
private ControlFlowGraph graph;
|
||||
|
||||
/** Maps statement index to block label. */
|
||||
private Map<Integer, LabelRef> stmtBlocks;
|
||||
private Map<Integer, ControlFlowBlock> stmtBlocks;
|
||||
|
||||
/** Maps statement index to statement. */
|
||||
private Map<Integer, Statement> stmtIdx;
|
||||
|
||||
public StatementInfos(Program program, Map<Integer, LabelRef> stmtBlocks, Map<Integer, Statement> stmtIdx) {
|
||||
public StatementInfos(Program program, Map<Integer, ControlFlowBlock> stmtBlocks, Map<Integer, Statement> stmtIdx) {
|
||||
this.graph = program.getGraph();
|
||||
this.stmtBlocks = stmtBlocks;
|
||||
this.stmtIdx = stmtIdx;
|
||||
@ -32,7 +32,7 @@ public class StatementInfos {
|
||||
* @return The block label
|
||||
*/
|
||||
public LabelRef getBlockRef(Integer stmtIdx) {
|
||||
return stmtBlocks.get(stmtIdx);
|
||||
return stmtBlocks.get(stmtIdx).getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -42,7 +42,7 @@ public class StatementInfos {
|
||||
* @return The block label
|
||||
*/
|
||||
public LabelRef getBlockRef(Statement stmt) {
|
||||
return stmtBlocks.get(stmt.getIndex());
|
||||
return stmtBlocks.get(stmt.getIndex()).getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -52,7 +52,7 @@ public class StatementInfos {
|
||||
* @return The containing block
|
||||
*/
|
||||
public ControlFlowBlock getBlock(Statement stmt) {
|
||||
return graph.getBlock(getBlockRef(stmt));
|
||||
return stmtBlocks.get(stmt.getIndex());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,11 +24,11 @@ public class PassNStatementInfos extends Pass2SsaOptimization {
|
||||
*/
|
||||
@Override
|
||||
public boolean step() {
|
||||
LinkedHashMap<Integer, LabelRef> stmtBlocks = new LinkedHashMap<>();
|
||||
LinkedHashMap<Integer, ControlFlowBlock> stmtBlocks = new LinkedHashMap<>();
|
||||
LinkedHashMap<Integer, Statement> stmtIdx = new LinkedHashMap<>();
|
||||
for(ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) {
|
||||
for(Statement statement : block.getStatements()) {
|
||||
stmtBlocks.put(statement.getIndex(), block.getLabel());
|
||||
stmtBlocks.put(statement.getIndex(), block);
|
||||
stmtIdx.put(statement.getIndex(), statement);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user