1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-09-08 17:54:40 +00:00

Refactored unused var analysis to reuse VariableReferenceInfos

This commit is contained in:
jespergravgaard 2017-12-01 08:33:25 +01:00
parent 18c36a6ed9
commit 3023540e15
16 changed files with 401 additions and 459 deletions

View File

@ -81,6 +81,7 @@ public class Compiler {
new Pass1ExtractInlineStrings(program).execute(); new Pass1ExtractInlineStrings(program).execute();
new Pass1EliminateUncalledProcedures(program).execute(); new Pass1EliminateUncalledProcedures(program).execute();
new Pass1EliminateUnusedVars(program).execute(); new Pass1EliminateUnusedVars(program).execute();
new Pass1EliminateEmptyBlocks(program).execute(); new Pass1EliminateEmptyBlocks(program).execute();
log.append("CONTROL FLOW GRAPH"); log.append("CONTROL FLOW GRAPH");
log.append(program.getGraph().toString(program)); log.append(program.getGraph().toString(program));

View File

@ -9,6 +9,9 @@ import java.util.Map;
/** Cached information about which variables are defined/referenced/used in statements / blocks. */ /** Cached information about which variables are defined/referenced/used in statements / blocks. */
public class VariableReferenceInfos { public class VariableReferenceInfos {
/** The congtaining program. */
private Program program;
/** Variables referenced in each block. */ /** Variables referenced in each block. */
private Map<LabelRef, Collection<VariableRef>> blockReferenced; private Map<LabelRef, Collection<VariableRef>> blockReferenced;
@ -21,14 +24,27 @@ public class VariableReferenceInfos {
/** Variables defined in each statement. */ /** Variables defined in each statement. */
private Map<Integer, Collection<VariableRef>> stmtDefined; private Map<Integer, Collection<VariableRef>> stmtDefined;
/** The statement defining each variable. */
private Map<VariableRef, Integer> varDefinitions;
/** All statements referencing each variable . */
private Map<VariableRef, Collection<Integer>> varReferences;
public VariableReferenceInfos( public VariableReferenceInfos(
Map<LabelRef, Collection<VariableRef>> blockReferenced, Map<LabelRef, Collection<VariableRef>> blockReferenced,
Map<LabelRef, Collection<VariableRef>> blockUsed, Map<LabelRef, Collection<VariableRef>> blockUsed,
Map<Integer, Collection<VariableRef>> stmtReferenced, Map<Integer, Collection<VariableRef>> stmtDefined) { Map<Integer, Collection<VariableRef>> stmtReferenced,
Map<Integer, Collection<VariableRef>> stmtDefined,
Map<VariableRef, Integer> varDefinitions,
Map<VariableRef, Collection<Integer>> varReferences
) {
this.blockReferenced = blockReferenced; this.blockReferenced = blockReferenced;
this.blockUsed = blockUsed; this.blockUsed = blockUsed;
this.stmtDefined = stmtDefined; this.stmtDefined = stmtDefined;
this.stmtReferenced = stmtReferenced; this.stmtReferenced = stmtReferenced;
this.varDefinitions = varDefinitions;
this.varReferences = varReferences;
} }
/** /**
@ -79,7 +95,6 @@ public class VariableReferenceInfos {
return used; return used;
} }
/** /**
* Get all variables referenced in an rValue * Get all variables referenced in an rValue
* @param rValue The rValue * @param rValue The rValue
@ -89,4 +104,15 @@ public class VariableReferenceInfos {
return Pass3VariableReferenceInfos.getReferenced(rValue); return Pass3VariableReferenceInfos.getReferenced(rValue);
} }
/**
* Determines if a variable is unused
* @return true if the variable is defined but never referenced
*/
public boolean isUnused(VariableRef variableRef) {
Collection<Integer> refs = new LinkedHashSet<>(varReferences.get(variableRef));
refs.remove(varDefinitions.get(variableRef));
return refs.size()==0;
}
} }

View File

@ -14,8 +14,11 @@ public class Pass1EliminateUnusedVars extends Pass1Base {
} }
@Override @Override
boolean executeStep() { public boolean executeStep() {
Collection<RValue> allUsedVars = getAllVarUsage(); new Pass3StatementIndices(getProgram()).generateStatementIndices();
new Pass3VariableReferenceInfos(getProgram()).generateVariableReferenceInfos();
VariableReferenceInfos referenceInfos = getProgram().getVariableReferenceInfos();
boolean modified = false; boolean modified = false;
for (ControlFlowBlock block : getGraph().getAllBlocks()) { for (ControlFlowBlock block : getGraph().getAllBlocks()) {
@ -25,7 +28,7 @@ public class Pass1EliminateUnusedVars extends Pass1Base {
if (statement instanceof StatementAssignment) { if (statement instanceof StatementAssignment) {
StatementAssignment assignment = (StatementAssignment) statement; StatementAssignment assignment = (StatementAssignment) statement;
LValue lValue = assignment.getlValue(); LValue lValue = assignment.getlValue();
if (lValue instanceof VariableRef && !allUsedVars.contains(lValue)) { if (lValue instanceof VariableRef && referenceInfos.isUnused((VariableRef) lValue)) {
getLog().append("Eliminating unused variable "+ lValue.toString(getProgram()) + " and assignment "+ assignment.toString(getProgram(), false)); getLog().append("Eliminating unused variable "+ lValue.toString(getProgram()) + " and assignment "+ assignment.toString(getProgram(), false));
stmtIt.remove(); stmtIt.remove();
Variable variable = getScope().getVariable((VariableRef) lValue); Variable variable = getScope().getVariable((VariableRef) lValue);
@ -35,7 +38,7 @@ public class Pass1EliminateUnusedVars extends Pass1Base {
} else if(statement instanceof StatementCall) { } else if(statement instanceof StatementCall) {
StatementCall call = (StatementCall) statement; StatementCall call = (StatementCall) statement;
LValue lValue = call.getlValue(); LValue lValue = call.getlValue();
if(lValue instanceof VariableRef && !allUsedVars.contains(lValue)) { if(lValue instanceof VariableRef && referenceInfos.isUnused((VariableRef) lValue)) {
getLog().append("Eliminating unused variable - keeping the call "+ lValue.toString(getProgram())); getLog().append("Eliminating unused variable - keeping the call "+ lValue.toString(getProgram()));
Variable variable = getScope().getVariable((VariableRef) lValue); Variable variable = getScope().getVariable((VariableRef) lValue);
variable.getScope().remove(variable); variable.getScope().remove(variable);
@ -45,87 +48,12 @@ public class Pass1EliminateUnusedVars extends Pass1Base {
} }
} }
} }
getProgram().setVariableReferenceInfos(null);
new Pass3StatementIndices(getProgram()).clearStatementIndices();
return modified; return modified;
} }
/**
* Get all Variable or Constant usage in RValues.
*
* @return Collection containing VariableRef and ConstantRef for all used vars/constants.
*/
private Collection<RValue> getAllVarUsage() {
Collection<RValue> allRvalues = new LinkedHashSet<>();
for (ControlFlowBlock block : getGraph().getAllBlocks()) {
for (Statement statement : block.getStatements()) {
if (statement instanceof StatementAssignment) {
addLvalueUses(allRvalues, ((StatementAssignment) statement).getlValue());
addRvalueUses(allRvalues, ((StatementAssignment) statement).getrValue1());
addRvalueUses(allRvalues, ((StatementAssignment) statement).getrValue2());
} else if (statement instanceof StatementCall) {
addLvalueUses(allRvalues, ((StatementCall) statement).getlValue());
for (RValue param : ((StatementCall) statement).getParameters()) {
addRvalueUses(allRvalues, param);
}
} else if (statement instanceof StatementConditionalJump) {
addRvalueUses(allRvalues, ((StatementConditionalJump) statement).getrValue1());
addRvalueUses(allRvalues, ((StatementConditionalJump) statement).getrValue2());
} else if (statement instanceof StatementReturn) {
addRvalueUses(allRvalues, ((StatementReturn) statement).getValue());
} else if (statement instanceof StatementPhiBlock) {
for (StatementPhiBlock.PhiVariable phiVariable : ((StatementPhiBlock) statement).getPhiVariables()) {
addLvalueUses(allRvalues, phiVariable.getVariable());
for (StatementPhiBlock.PhiRValue phiRValue : phiVariable.getValues()) {
addRvalueUses(allRvalues, phiRValue.getrValue());
}
}
}
}
}
return allRvalues;
}
private void addLvalueUses(Collection<RValue> allUses, LValue lValue) {
if (lValue == null) {
return;
} else if (lValue instanceof VariableRef) {
return;
} else if (lValue instanceof LvalueLoHiByte) {
addRvalueUses(allUses, ((LvalueLoHiByte) lValue).getVariable());
} else if (lValue instanceof PointerDereferenceSimple) {
addRvalueUses(allUses, ((PointerDereference) lValue).getPointer());
} else if (lValue instanceof PointerDereferenceIndexed) {
addRvalueUses(allUses, ((PointerDereferenceIndexed) lValue).getPointer());
addRvalueUses(allUses, ((PointerDereferenceIndexed) lValue).getIndex());
} else {
throw new RuntimeException("Unknown LValue type " + lValue);
}
}
private void addRvalueUses(Collection<RValue> allUses, RValue rValue) {
if (rValue == null) {
return;
} else if (rValue instanceof VariableRef || rValue instanceof ConstantRef) {
allUses.add(rValue);
} else if (rValue instanceof LValue) {
addLvalueUses(allUses, (LValue) rValue);
} else if (rValue instanceof ConstantString || rValue instanceof ConstantInteger || rValue instanceof ConstantBool || rValue instanceof ConstantChar || rValue instanceof ConstantDouble) {
return;
} else if (rValue instanceof ConstantArray) {
for (ConstantValue constantValue : ((ConstantArray) rValue).getElements()) {
addRvalueUses(allUses, constantValue);
}
} else if (rValue instanceof ValueArray) {
for (RValue value : ((ValueArray) rValue).getList()) {
addRvalueUses(allUses, value);
}
} else if (rValue instanceof ConstantUnary) {
addRvalueUses(allUses, ((ConstantUnary) rValue).getOperand());
} else if (rValue instanceof ConstantBinary) {
addRvalueUses(allUses, ((ConstantBinary) rValue).getLeft());
addRvalueUses(allUses, ((ConstantBinary) rValue).getRight());
} else {
throw new RuntimeException("Unknown RValue type " + rValue);
}
}
} }

View File

@ -24,5 +24,16 @@ public class Pass3StatementIndices extends Pass2Base {
} }
} }
/**
* Clear index numbers for all statements in the control flow graph.
*/
public void clearStatementIndices() {
for (ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) {
for (Statement statement : block.getStatements()) {
statement.setIndex(null);
}
}
}
} }

View File

@ -19,16 +19,32 @@ public class Pass3VariableReferenceInfos extends Pass2Base {
LinkedHashMap<LabelRef, Collection<VariableRef>> blockUsed = new LinkedHashMap<>(); LinkedHashMap<LabelRef, Collection<VariableRef>> blockUsed = new LinkedHashMap<>();
LinkedHashMap<Integer, Collection<VariableRef>> stmtReferenced = new LinkedHashMap<>(); LinkedHashMap<Integer, Collection<VariableRef>> stmtReferenced = new LinkedHashMap<>();
LinkedHashMap<Integer, Collection<VariableRef>> stmtDefined = new LinkedHashMap<>(); LinkedHashMap<Integer, Collection<VariableRef>> stmtDefined = new LinkedHashMap<>();
LinkedHashMap<VariableRef, Integer> varDefines = new LinkedHashMap<>();
LinkedHashMap<VariableRef, Collection<Integer>> varReferences = new LinkedHashMap<>();
for (ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) { for (ControlFlowBlock block : getProgram().getGraph().getAllBlocks()) {
LabelRef blockLabel = block.getLabel(); LabelRef blockLabel = block.getLabel();
blockReferenced.put(blockLabel, getReferenced(blockLabel, new ArrayList<LabelRef>())); blockReferenced.put(blockLabel, getReferenced(blockLabel, new ArrayList<>()));
blockUsed.put(blockLabel, getUsed(blockLabel, new ArrayList<LabelRef>())); blockUsed.put(blockLabel, getUsed(blockLabel, new ArrayList<>()));
for (Statement statement : block.getStatements()) { for (Statement statement : block.getStatements()) {
stmtDefined.put(statement.getIndex(), getDefined(statement)); Collection<VariableRef> defined = getDefined(statement);
stmtReferenced.put(statement.getIndex(), getReferenced(statement)); Collection<VariableRef> referenced = getReferenced(statement);
stmtDefined.put(statement.getIndex(), defined);
stmtReferenced.put(statement.getIndex(), referenced);
for (VariableRef variableRef : defined) {
varDefines.put(variableRef, statement.getIndex());
}
for (VariableRef variableRef : referenced) {
Collection<Integer> stmts = varReferences.get(variableRef);
if(stmts==null) {
stmts = new LinkedHashSet<>();
varReferences.put(variableRef, stmts);
}
stmts.add(statement.getIndex());
}
} }
} }
getProgram().setVariableReferenceInfos(new VariableReferenceInfos(blockReferenced, blockUsed, stmtReferenced, stmtDefined)); getProgram().setVariableReferenceInfos(new VariableReferenceInfos(blockReferenced, blockUsed, stmtReferenced, stmtDefined, varDefines, varReferences));
} }
@ -113,6 +129,12 @@ public class Pass3VariableReferenceInfos extends Pass2Base {
defined.add(phiVariable.getVariable()); defined.add(phiVariable.getVariable());
} }
return defined; return defined;
} else if (stmt instanceof StatementCall) {
List<VariableRef> defined = new ArrayList<>();
if(((StatementCall) stmt).getlValue() instanceof VariableRef) {
defined.add((VariableRef) ((StatementCall) stmt).getlValue());
}
return defined;
} }
return new ArrayList<>(); return new ArrayList<>();
} }
@ -191,11 +213,16 @@ public class Pass3VariableReferenceInfos extends Pass2Base {
return used; return used;
} else if (rValue instanceof VariableRef) { } else if (rValue instanceof VariableRef) {
return Arrays.asList((VariableRef) rValue); return Arrays.asList((VariableRef) rValue);
} else if (rValue instanceof ValueArray) {
LinkedHashSet<VariableRef> used = new LinkedHashSet<>();
for (RValue value : ((ValueArray) rValue).getList()) {
used.addAll(getReferenced(value));
}
return used;
} else { } else {
throw new RuntimeException("Unhandled RValue type " + rValue); throw new RuntimeException("Unhandled RValue type " + rValue);
} }
} }
} }

View File

@ -1134,13 +1134,13 @@ init_screen::@return: scope:[init_screen] from init_screen::@4
to:@end to:@end
@end: scope:[] from @10 @end: scope:[] from @10
Eliminating unused variable (byte*) COLS and assignment (byte*) COLS ← ((byte*)) (word) 55296 Eliminating unused variable (byte*) COLS and assignment [0] (byte*) COLS ← ((byte*)) (word) 55296
Eliminating unused variable (byte*) SCROLL and assignment (byte*) SCROLL ← ((byte*)) (word) 53270 Eliminating unused variable (byte*) SCROLL and assignment [3] (byte*) SCROLL ← ((byte*)) (word) 53270
Eliminating unused variable (byte) RST8 and assignment (byte) RST8 ← (byte/word/signed word) 128 Eliminating unused variable (byte) RST8 and assignment [6] (byte) RST8 ← (byte/word/signed word) 128
Eliminating unused variable (byte) ECM and assignment (byte) ECM ← (byte/signed byte/word/signed word) 64 Eliminating unused variable (byte) ECM and assignment [7] (byte) ECM ← (byte/signed byte/word/signed word) 64
Eliminating unused variable (byte*) D016 and assignment (byte*) D016 ← ((byte*)) (word) 53270 Eliminating unused variable (byte*) D016 and assignment [11] (byte*) D016 ← ((byte*)) (word) 53270
Eliminating unused variable (byte) MCM and assignment (byte) MCM ← (byte/signed byte/word/signed word) 16 Eliminating unused variable (byte) MCM and assignment [12] (byte) MCM ← (byte/signed byte/word/signed word) 16
Eliminating unused variable (byte) CSEL and assignment (byte) CSEL ← (byte/signed byte/word/signed word) 8 Eliminating unused variable (byte) CSEL and assignment [13] (byte) CSEL ← (byte/signed byte/word/signed word) 8
Eliminating unused variable - keeping the call (void~) main::$3 Eliminating unused variable - keeping the call (void~) main::$3
Eliminating unused variable - keeping the call (void~) main::$4 Eliminating unused variable - keeping the call (void~) main::$4
Eliminating unused variable - keeping the call (void~) main::$5 Eliminating unused variable - keeping the call (void~) main::$5

View File

@ -530,12 +530,12 @@ init_screen::@return: scope:[init_screen] from init_screen::@4
to:@end to:@end
@end: scope:[] from @5 @end: scope:[] from @5
Eliminating unused variable (byte) RST8 and assignment (byte) RST8 ← (byte/word/signed word) 128 Eliminating unused variable (byte) RST8 and assignment [1] (byte) RST8 ← (byte/word/signed word) 128
Eliminating unused variable (byte) ECM and assignment (byte) ECM ← (byte/signed byte/word/signed word) 64 Eliminating unused variable (byte) ECM and assignment [2] (byte) ECM ← (byte/signed byte/word/signed word) 64
Eliminating unused variable (byte*) D016 and assignment (byte*) D016 ← ((byte*)) (word) 53270 Eliminating unused variable (byte*) D016 and assignment [7] (byte*) D016 ← ((byte*)) (word) 53270
Eliminating unused variable (byte) MCM and assignment (byte) MCM ← (byte/signed byte/word/signed word) 16 Eliminating unused variable (byte) MCM and assignment [8] (byte) MCM ← (byte/signed byte/word/signed word) 16
Eliminating unused variable (byte) CSEL and assignment (byte) CSEL ← (byte/signed byte/word/signed word) 8 Eliminating unused variable (byte) CSEL and assignment [9] (byte) CSEL ← (byte/signed byte/word/signed word) 8
Eliminating unused variable (byte*) COLS and assignment (byte*) COLS ← ((byte*)) (word) 55296 Eliminating unused variable (byte*) COLS and assignment [13] (byte*) COLS ← ((byte*)) (word) 55296
Eliminating unused variable - keeping the call (void~) main::$3 Eliminating unused variable - keeping the call (void~) main::$3
Eliminating unused variable - keeping the call (void~) main::$4 Eliminating unused variable - keeping the call (void~) main::$4
Eliminating unused variable - keeping the call (void~) main::$6 Eliminating unused variable - keeping the call (void~) main::$6

View File

@ -336,7 +336,7 @@ main::@return: scope:[main] from main::@12
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Eliminating unused variable (byte*) CHARSET and assignment (byte*) CHARSET ← ((byte*)) (word/signed word) 8192 Eliminating unused variable (byte*) CHARSET and assignment [1] (byte*) CHARSET ← ((byte*)) (word/signed word) 8192
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
(byte*) SCREEN ← ((byte*)) (word/signed word) 1024 (byte*) SCREEN ← ((byte*)) (word/signed word) 1024

View File

@ -180,14 +180,14 @@ main::@return: scope:[main] from main::@4
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Eliminating unused variable (byte) main::a and assignment (byte) main::a ← *((byte*~) main::$0) Eliminating unused variable (byte) main::a and assignment [2] (byte) main::a ← *((byte*~) main::$0)
Eliminating unused variable (byte*~) main::$14 and assignment (byte*~) main::$14 ← ((byte*)) (word) 53280 Eliminating unused variable (byte*~) main::$14 and assignment [28] (byte*~) main::$14 ← ((byte*)) (word) 53280
Eliminating unused variable (byte*~) main::$15 and assignment (byte*~) main::$15 ← ((byte*)) (word) 53280 Eliminating unused variable (byte*~) main::$15 and assignment [29] (byte*~) main::$15 ← ((byte*)) (word) 53280
Eliminating unused variable (byte*~) main::$19 and assignment (byte*~) main::$19 ← ((byte*)) (word~) main::$18 Eliminating unused variable (byte*~) main::$19 and assignment [34] (byte*~) main::$19 ← ((byte*)) (word~) main::$18
Eliminating unused variable (byte*~) main::$21 and assignment (byte*~) main::$21 ← ((byte*)) (word~) main::$20 Eliminating unused variable (byte*~) main::$21 and assignment [36] (byte*~) main::$21 ← ((byte*)) (word~) main::$20
Eliminating unused variable (byte*~) main::$0 and assignment (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word) 80 Eliminating unused variable (byte*~) main::$0 and assignment [1] (byte*~) main::$0 ← (byte*) main::screen + (byte/signed byte/word/signed word) 80
Eliminating unused variable (word~) main::$18 and assignment (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33 Eliminating unused variable (word~) main::$18 and assignment [30] (word~) main::$18 ← (word) 53248 + (byte/signed byte/word/signed word) 33
Eliminating unused variable (word~) main::$20 and assignment (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33 Eliminating unused variable (word~) main::$20 and assignment [31] (word~) main::$20 ← (word) 53248 + (byte/signed byte/word/signed word) 33
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from
to:@1 to:@1

View File

@ -44,8 +44,6 @@ rvaluevar: {
bcc b2 bcc b2
rts rts
b2: b2:
ldy #0
lda (screen),y
inc screen inc screen
bne !+ bne !+
inc screen+1 inc screen+1

View File

@ -54,37 +54,36 @@ rvaluevar::@return: scope:[rvaluevar] from rvaluevar::@1
[23] return [ ] ( main:2::rvaluevar:9 [ ] ) [23] return [ ] ( main:2::rvaluevar:9 [ ] )
to:@return to:@return
rvaluevar::@2: scope:[rvaluevar] from rvaluevar::@1 rvaluevar::@2: scope:[rvaluevar] from rvaluevar::@1
[24] (byte) rvaluevar::b#0 ← *((byte*) rvaluevar::screen#2) [ rvaluevar::i#2 rvaluevar::screen#2 ] ( main:2::rvaluevar:9 [ rvaluevar::i#2 rvaluevar::screen#2 ] ) [24] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#1 ] ( main:2::rvaluevar:9 [ rvaluevar::i#2 rvaluevar::screen#1 ] )
[25] (byte*) rvaluevar::screen#1 ← ++ (byte*) rvaluevar::screen#2 [ rvaluevar::i#2 rvaluevar::screen#1 ] ( main:2::rvaluevar:9 [ rvaluevar::i#2 rvaluevar::screen#1 ] ) [25] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] ( main:2::rvaluevar:9 [ rvaluevar::i#1 rvaluevar::screen#1 ] )
[26] (byte) rvaluevar::i#1 ← ++ (byte) rvaluevar::i#2 [ rvaluevar::i#1 rvaluevar::screen#1 ] ( main:2::rvaluevar:9 [ rvaluevar::i#1 rvaluevar::screen#1 ] )
to:rvaluevar::@1 to:rvaluevar::@1
rvalue: scope:[rvalue] from main::@1 rvalue: scope:[rvalue] from main::@1
[27] (byte) rvalue::b#0 ← *((const byte[1024]) rvalue::SCREEN#0) [ ] ( main:2::rvalue:7 [ ] ) [26] (byte) rvalue::b#0 ← *((const byte[1024]) rvalue::SCREEN#0) [ ] ( main:2::rvalue:7 [ ] )
[28] (byte) rvalue::b#1 ← * (const byte[1024]) rvalue::SCREEN#0+(byte/signed byte/word/signed word) 1 [ ] ( main:2::rvalue:7 [ ] ) [27] (byte) rvalue::b#1 ← * (const byte[1024]) rvalue::SCREEN#0+(byte/signed byte/word/signed word) 1 [ ] ( main:2::rvalue:7 [ ] )
to:rvalue::@1 to:rvalue::@1
rvalue::@1: scope:[rvalue] from rvalue rvalue::@2 rvalue::@1: scope:[rvalue] from rvalue rvalue::@2
[29] (byte) rvalue::i#2 ← phi( rvalue/(byte/signed byte/word/signed word) 2 rvalue::@2/(byte) rvalue::i#1 ) [ rvalue::i#2 ] ( main:2::rvalue:7 [ rvalue::i#2 ] ) [28] (byte) rvalue::i#2 ← phi( rvalue/(byte/signed byte/word/signed word) 2 rvalue::@2/(byte) rvalue::i#1 ) [ rvalue::i#2 ] ( main:2::rvalue:7 [ rvalue::i#2 ] )
[30] if((byte) rvalue::i#2<(byte/signed byte/word/signed word) 10) goto rvalue::@2 [ rvalue::i#2 ] ( main:2::rvalue:7 [ rvalue::i#2 ] ) [29] if((byte) rvalue::i#2<(byte/signed byte/word/signed word) 10) goto rvalue::@2 [ rvalue::i#2 ] ( main:2::rvalue:7 [ rvalue::i#2 ] )
to:rvalue::@return to:rvalue::@return
rvalue::@return: scope:[rvalue] from rvalue::@1 rvalue::@return: scope:[rvalue] from rvalue::@1
[31] return [ ] ( main:2::rvalue:7 [ ] ) [30] return [ ] ( main:2::rvalue:7 [ ] )
to:@return to:@return
rvalue::@2: scope:[rvalue] from rvalue::@1 rvalue::@2: scope:[rvalue] from rvalue::@1
[32] (byte) rvalue::b#2 ← (const byte[1024]) rvalue::SCREEN#0 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] ( main:2::rvalue:7 [ rvalue::i#2 ] ) [31] (byte) rvalue::b#2 ← (const byte[1024]) rvalue::SCREEN#0 *idx (byte) rvalue::i#2 [ rvalue::i#2 ] ( main:2::rvalue:7 [ rvalue::i#2 ] )
[33] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] ( main:2::rvalue:7 [ rvalue::i#1 ] ) [32] (byte) rvalue::i#1 ← ++ (byte) rvalue::i#2 [ rvalue::i#1 ] ( main:2::rvalue:7 [ rvalue::i#1 ] )
to:rvalue::@1 to:rvalue::@1
lvalue: scope:[lvalue] from main lvalue: scope:[lvalue] from main
[34] *((const byte[1024]) lvalue::SCREEN#0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:2::lvalue:5 [ ] ) [33] *((const byte[1024]) lvalue::SCREEN#0) ← (byte/signed byte/word/signed word) 1 [ ] ( main:2::lvalue:5 [ ] )
[35] *((const byte[1024]) lvalue::SCREEN#0+(byte/signed byte/word/signed word) 1) ← (byte/signed byte/word/signed word) 2 [ ] ( main:2::lvalue:5 [ ] ) [34] *((const byte[1024]) lvalue::SCREEN#0+(byte/signed byte/word/signed word) 1) ← (byte/signed byte/word/signed word) 2 [ ] ( main:2::lvalue:5 [ ] )
to:lvalue::@1 to:lvalue::@1
lvalue::@1: scope:[lvalue] from lvalue lvalue::@2 lvalue::@1: scope:[lvalue] from lvalue lvalue::@2
[36] (byte) lvalue::i#2 ← phi( lvalue/(byte/signed byte/word/signed word) 2 lvalue::@2/(byte) lvalue::i#1 ) [ lvalue::i#2 ] ( main:2::lvalue:5 [ lvalue::i#2 ] ) [35] (byte) lvalue::i#2 ← phi( lvalue/(byte/signed byte/word/signed word) 2 lvalue::@2/(byte) lvalue::i#1 ) [ lvalue::i#2 ] ( main:2::lvalue:5 [ lvalue::i#2 ] )
[37] if((byte) lvalue::i#2<(byte/signed byte/word/signed word) 10) goto lvalue::@2 [ lvalue::i#2 ] ( main:2::lvalue:5 [ lvalue::i#2 ] ) [36] if((byte) lvalue::i#2<(byte/signed byte/word/signed word) 10) goto lvalue::@2 [ lvalue::i#2 ] ( main:2::lvalue:5 [ lvalue::i#2 ] )
to:lvalue::@return to:lvalue::@return
lvalue::@return: scope:[lvalue] from lvalue::@1 lvalue::@return: scope:[lvalue] from lvalue::@1
[38] return [ ] ( main:2::lvalue:5 [ ] ) [37] return [ ] ( main:2::lvalue:5 [ ] )
to:@return to:@return
lvalue::@2: scope:[lvalue] from lvalue::@1 lvalue::@2: scope:[lvalue] from lvalue::@1
[39] *((const byte[1024]) lvalue::SCREEN#0 + (byte) lvalue::i#2) ← (byte/signed byte/word/signed word) 3 [ lvalue::i#2 ] ( main:2::lvalue:5 [ lvalue::i#2 ] ) [38] *((const byte[1024]) lvalue::SCREEN#0 + (byte) lvalue::i#2) ← (byte/signed byte/word/signed word) 3 [ lvalue::i#2 ] ( main:2::lvalue:5 [ lvalue::i#2 ] )
[40] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] ( main:2::lvalue:5 [ lvalue::i#1 ] ) [39] (byte) lvalue::i#1 ← ++ (byte) lvalue::i#2 [ lvalue::i#1 ] ( main:2::lvalue:5 [ lvalue::i#1 ] )
to:lvalue::@1 to:lvalue::@1

File diff suppressed because it is too large Load Diff

View File

@ -44,11 +44,9 @@
(label) rvaluevar::@1 (label) rvaluevar::@1
(label) rvaluevar::@2 (label) rvaluevar::@2
(label) rvaluevar::@return (label) rvaluevar::@return
(byte) rvaluevar::b
(byte) rvaluevar::b#0 reg byte a 110.0
(byte) rvaluevar::i (byte) rvaluevar::i
(byte) rvaluevar::i#1 reg byte x 22.0 (byte) rvaluevar::i#1 reg byte x 22.0
(byte) rvaluevar::i#2 reg byte x 8.25 (byte) rvaluevar::i#2 reg byte x 11.0
(byte*) rvaluevar::screen (byte*) rvaluevar::screen
(byte*) rvaluevar::screen#1 screen zp ZP_PTR_BYTE:2 11.0 (byte*) rvaluevar::screen#1 screen zp ZP_PTR_BYTE:2 11.0
(byte*) rvaluevar::screen#2 screen zp ZP_PTR_BYTE:2 11.0 (byte*) rvaluevar::screen#2 screen zp ZP_PTR_BYTE:2 11.0
@ -58,7 +56,6 @@ zp ZP_PTR_BYTE:2 [ lvaluevar::screen#2 lvaluevar::screen#1 rvaluevar::screen#2 r
reg byte x [ rvaluevar::i#2 rvaluevar::i#1 ] reg byte x [ rvaluevar::i#2 rvaluevar::i#1 ]
reg byte x [ rvalue::i#2 rvalue::i#1 ] reg byte x [ rvalue::i#2 rvalue::i#1 ]
reg byte x [ lvalue::i#2 lvalue::i#1 ] reg byte x [ lvalue::i#2 lvalue::i#1 ]
reg byte a [ rvaluevar::b#0 ]
reg byte a [ rvalue::b#0 ] reg byte a [ rvalue::b#0 ]
reg byte a [ rvalue::b#1 ] reg byte a [ rvalue::b#1 ]
reg byte a [ rvalue::b#2 ] reg byte a [ rvalue::b#2 ]

View File

@ -80,9 +80,9 @@ main::@return: scope:[main] from main::@3
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Eliminating unused variable (byte) main::b and assignment (byte) main::b ← (byte~) main::$1 Eliminating unused variable (byte) main::b and assignment [5] (byte) main::b ← (byte~) main::$1
Eliminating unused variable (byte~) main::$1 and assignment (byte~) main::$1 ← (byte[1024]) main::SCREEN *idx (byte) main::i Eliminating unused variable (byte~) main::$1 and assignment [4] (byte~) main::$1 ← (byte[1024]) main::SCREEN *idx (byte) main::i
Eliminating unused variable (byte[1024]) main::SCREEN and assignment (byte[1024]) main::SCREEN ← ((byte*)) (word/signed word) 1024 Eliminating unused variable (byte[1024]) main::SCREEN and assignment [0] (byte[1024]) main::SCREEN ← ((byte*)) (word/signed word) 1024
Removing empty block main::@4 Removing empty block main::@4
Removing empty block main::@3 Removing empty block main::@3
Removing empty block main::@5 Removing empty block main::@5

View File

@ -94,7 +94,7 @@ main::@return: scope:[main] from main::@4
to:@end to:@end
@end: scope:[] from @1 @end: scope:[] from @1
Eliminating unused variable (byte*) SCROLL and assignment (byte*) SCROLL ← ((byte*)) (word) 53270 Eliminating unused variable (byte*) SCROLL and assignment [1] (byte*) SCROLL ← ((byte*)) (word) 53270
Removing empty block main::@4 Removing empty block main::@4
CONTROL FLOW GRAPH CONTROL FLOW GRAPH
@begin: scope:[] from @begin: scope:[] from

View File

@ -178,25 +178,25 @@ s::@1: scope:[s] from
to:@end to:@end
@end: scope:[] from @2 @end: scope:[] from @2
Eliminating unused variable (byte*) BGCOL and assignment (byte*) BGCOL ← ((byte*)) (word) 53281 Eliminating unused variable (byte*) BGCOL and assignment [3] (byte*) BGCOL ← ((byte*)) (word) 53281
Eliminating unused variable (byte[]) msg and assignment (byte[]) msg ← (string) "hello world@" Eliminating unused variable (byte[]) msg and assignment [4] (byte[]) msg ← (string) "hello world@"
Eliminating unused variable (byte[]) arr and assignment (byte[]) arr ← { (byte/signed byte/word/signed word) 7, (byte/signed byte/word/signed word) 8, (byte/signed byte/word/signed word) 9 } Eliminating unused variable (byte[]) arr and assignment [5] (byte[]) arr ← { (byte/signed byte/word/signed word) 7, (byte/signed byte/word/signed word) 8, (byte/signed byte/word/signed word) 9 }
Eliminating unused variable (byte) c and assignment (byte) c ← (byte/signed byte/word/signed word) 1 Eliminating unused variable (byte) c and assignment [6] (byte) c ← (byte/signed byte/word/signed word) 1
Eliminating unused variable (byte) c2 and assignment (byte) c2 ← (byte/signed byte/word/signed word) 1 Eliminating unused variable (byte) c2 and assignment [7] (byte) c2 ← (byte/signed byte/word/signed word) 1
Eliminating unused variable (byte) main::e and assignment (byte) main::e ← (byte~) main::$3 Eliminating unused variable (byte) main::e and assignment [15] (byte) main::e ← (byte~) main::$3
Eliminating unused variable (word) main::f and assignment (word) main::f ← (word~) main::$6 Eliminating unused variable (word) main::f and assignment [19] (word) main::f ← (word~) main::$6
Eliminating unused variable (byte[]) main::g and assignment (byte[]) main::g ← { (byte/signed byte/word/signed word) 4, (byte/signed byte/word/signed word) 5, (byte/signed byte/word/signed word) 6 } Eliminating unused variable (byte[]) main::g and assignment [21] (byte[]) main::g ← { (byte/signed byte/word/signed word) 4, (byte/signed byte/word/signed word) 5, (byte/signed byte/word/signed word) 6 }
Eliminating unused variable (byte[]) main::h and assignment (byte[]) main::h ← (string) "goodbye sky " Eliminating unused variable (byte[]) main::h and assignment [22] (byte[]) main::h ← (string) "goodbye sky "
Eliminating unused variable (signed byte) main::x and assignment (signed byte) main::x ← (signed byte/signed word~) main::$7 Eliminating unused variable (signed byte) main::x and assignment [25] (signed byte) main::x ← (signed byte/signed word~) main::$7
Eliminating unused variable (byte~) main::$3 and assignment (byte~) main::$3 ← (byte~) main::$1 + (byte~) main::$2 Eliminating unused variable (byte~) main::$3 and assignment [9] (byte~) main::$3 ← (byte~) main::$1 + (byte~) main::$2
Eliminating unused variable (word~) main::$6 and assignment (word~) main::$6 ← (word~) main::$5 + (byte) b Eliminating unused variable (word~) main::$6 and assignment [12] (word~) main::$6 ← (word~) main::$5 + (byte) b
Eliminating unused variable (signed byte/signed word~) main::$7 and assignment (signed byte/signed word~) main::$7 ← - (byte/signed byte/word/signed word) 13 Eliminating unused variable (signed byte/signed word~) main::$7 and assignment [15] (signed byte/signed word~) main::$7 ← - (byte/signed byte/word/signed word) 13
Eliminating unused variable (byte~) main::$1 and assignment (byte~) main::$1 ← (byte/signed byte/word/signed word~) main::$0 + (byte/signed byte/word/signed word) 3 Eliminating unused variable (byte~) main::$1 and assignment [7] (byte~) main::$1 ← (byte/signed byte/word/signed word~) main::$0 + (byte/signed byte/word/signed word) 3
Eliminating unused variable - keeping the call (byte~) main::$2 Eliminating unused variable - keeping the call (byte~) main::$2
Eliminating unused variable (word~) main::$5 and assignment (word~) main::$5 ← (word/signed word~) main::$4 + (word) d Eliminating unused variable (word~) main::$5 and assignment [10] (word~) main::$5 ← (word/signed word~) main::$4 + (word) d
Eliminating unused variable (word) d and assignment (word) d ← (word/signed word) 1000 Eliminating unused variable (word) d and assignment [3] (word) d ← (word/signed word) 1000
Eliminating unused variable (byte/signed byte/word/signed word~) main::$0 and assignment (byte/signed byte/word/signed word~) main::$0 ← (byte/signed byte/word/signed word) 3 + (byte/signed byte/word/signed word) 3 Eliminating unused variable (byte/signed byte/word/signed word~) main::$0 and assignment [6] (byte/signed byte/word/signed word~) main::$0 ← (byte/signed byte/word/signed word) 3 + (byte/signed byte/word/signed word) 3
Eliminating unused variable (word/signed word~) main::$4 and assignment (word/signed word~) main::$4 ← (word/signed word) 2000 + (word/signed word) 2000 Eliminating unused variable (word/signed word~) main::$4 and assignment [8] (word/signed word~) main::$4 ← (word/signed word) 2000 + (word/signed word) 2000
Removing empty block main::@2 Removing empty block main::@2
Removing empty block @1 Removing empty block @1
Removing empty block s::@1 Removing empty block s::@1