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) {
|
||||
VariableBuilderConfig config = new VariableBuilderConfig();
|
||||
VariableBuilderConfig.defaultPreConfig(config, program.getLog());
|
||||
VariableBuilderConfig.defaultPostConfig(config, program.getLog());
|
||||
VariableBuilderConfig.defaultPreConfig(config, getLog());
|
||||
VariableBuilderConfig.defaultPostConfig(config, getLog());
|
||||
this.variableBuilderConfig = config;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import dk.camelot64.kickc.model.values.ProcedureRef;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/** Symbol describing a procedure/function */
|
||||
public class Procedure extends Scope {
|
||||
@ -233,19 +234,19 @@ public class Procedure extends Scope {
|
||||
if(this == o) return true;
|
||||
if(o == null || getClass() != o.getClass()) return false;
|
||||
if(!super.equals(o)) return false;
|
||||
|
||||
Procedure procedure = (Procedure) o;
|
||||
|
||||
if(returnType != null ? !returnType.equals(procedure.returnType) : procedure.returnType != null) return false;
|
||||
return parameterNames != null ? parameterNames.equals(procedure.parameterNames) : procedure.parameterNames == null;
|
||||
return declaredInline == procedure.declaredInline &&
|
||||
Objects.equals(returnType, procedure.returnType) &&
|
||||
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
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (returnType != null ? returnType.hashCode() : 0);
|
||||
result = 31 * result + (parameterNames != null ? parameterNames.hashCode() : 0);
|
||||
return result;
|
||||
return Objects.hash(super.hashCode(), returnType, parameterNames, declaredInline, interruptType, comments, reservedZps, codeSegment, callingConvention);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -161,6 +161,10 @@ public class PassNEliminateUnusedVars extends Pass2SsaOptimization {
|
||||
// Do not eliminate return variables in pass 1
|
||||
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());
|
||||
if(!unused)
|
||||
// Do not eliminate is not unused
|
||||
|
Loading…
Reference in New Issue
Block a user