mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 08:32:39 +00:00
Fixed problem where unused parameters were eliminated.
This commit is contained in:
parent
25279aead3
commit
2427720581
@ -146,8 +146,8 @@ public class Compiler {
|
|||||||
|
|
||||||
if(variableBuilderConfig == null) {
|
if(variableBuilderConfig == null) {
|
||||||
VariableBuilderConfig config = new VariableBuilderConfig();
|
VariableBuilderConfig config = new VariableBuilderConfig();
|
||||||
VariableBuilderConfig.defaultPreConfig(config, program.getLog());
|
VariableBuilderConfig.defaultPreConfig(config, getLog());
|
||||||
VariableBuilderConfig.defaultPostConfig(config, program.getLog());
|
VariableBuilderConfig.defaultPostConfig(config, getLog());
|
||||||
this.variableBuilderConfig = config;
|
this.variableBuilderConfig = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ import dk.camelot64.kickc.model.values.ProcedureRef;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/** Symbol describing a procedure/function */
|
/** Symbol describing a procedure/function */
|
||||||
public class Procedure extends Scope {
|
public class Procedure extends Scope {
|
||||||
@ -233,19 +234,19 @@ public class Procedure extends Scope {
|
|||||||
if(this == o) return true;
|
if(this == o) return true;
|
||||||
if(o == null || getClass() != o.getClass()) return false;
|
if(o == null || getClass() != o.getClass()) return false;
|
||||||
if(!super.equals(o)) return false;
|
if(!super.equals(o)) return false;
|
||||||
|
|
||||||
Procedure procedure = (Procedure) o;
|
Procedure procedure = (Procedure) o;
|
||||||
|
return declaredInline == procedure.declaredInline &&
|
||||||
if(returnType != null ? !returnType.equals(procedure.returnType) : procedure.returnType != null) return false;
|
Objects.equals(returnType, procedure.returnType) &&
|
||||||
return parameterNames != null ? parameterNames.equals(procedure.parameterNames) : procedure.parameterNames == null;
|
Objects.equals(parameterNames, procedure.parameterNames) &&
|
||||||
|
interruptType == procedure.interruptType &&
|
||||||
|
Objects.equals(comments, procedure.comments) &&
|
||||||
|
Objects.equals(reservedZps, procedure.reservedZps) &&
|
||||||
|
Objects.equals(codeSegment, procedure.codeSegment) &&
|
||||||
|
callingConvention == procedure.callingConvention;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = super.hashCode();
|
return Objects.hash(super.hashCode(), returnType, parameterNames, declaredInline, interruptType, comments, reservedZps, codeSegment, callingConvention);
|
||||||
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
|
|
||||||
result = 31 * result + (parameterNames != null ? parameterNames.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,10 @@ public class PassNEliminateUnusedVars extends Pass2SsaOptimization {
|
|||||||
// Do not eliminate return variables in pass 1
|
// Do not eliminate return variables in pass 1
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(variable.getScope() instanceof Procedure && ((Procedure) variable.getScope()).getParameters().contains(variable)) {
|
||||||
|
// Do not eliminate parameters
|
||||||
|
return false;
|
||||||
|
}
|
||||||
final boolean unused = referenceInfos.isUnused(variable.getRef());
|
final boolean unused = referenceInfos.isUnused(variable.getRef());
|
||||||
if(!unused)
|
if(!unused)
|
||||||
// Do not eliminate is not unused
|
// Do not eliminate is not unused
|
||||||
|
Loading…
Reference in New Issue
Block a user