Skip to content

Commit

Permalink
Removing dead statements with the script
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@19956 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Apr 3, 2014
1 parent 1a84f6f commit b0c8f3e
Show file tree
Hide file tree
Showing 26 changed files with 53 additions and 51 deletions.
1 change: 0 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -4907,7 +4907,6 @@ algorithm
tmpEqns = BackendEquation.listEquation(eqnlst);
(explst,_) = BackendDAEUtil.getEqnSysRhs(tmpEqns,BackendVariable.listVar1(varlst),SOME(funcs));
((_,tpl)) = Expression.traverseExpList(explst,countOperationsExp,tpl);
(i1,i2,i3,i4) = tpl;
then
countOperationstraverseComps(rest,isyst,ishared,tpl);
case ((comp as BackendDAE.TORNSYSTEM(tearingvars=vlst, otherEqnVarTpl=eqnvartpllst, linear=false))::rest,_,BackendDAE.SHARED(functionTree=funcs),_)
Expand Down
3 changes: 0 additions & 3 deletions Compiler/BackEnd/BackendQSS.mo
Expand Up @@ -461,9 +461,6 @@ algorithm
then stringAppend(stringAppend("x[",intString(p+1)),"]");
case (DAE.CREF_QUAL(ident,identType,subscriptLst,r),_,_,_)
equation
ident=DAE.derivativeNamePrefix;
identType=DAE.T_REAL_DEFAULT;
subscriptLst={};
p = List.positionOnTrue(r,states,ComponentReference.crefEqual);
then stringAppend(stringAppend("der(x[",intString(p+1)),"])");
case (_,_,_,_)
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/EvaluateFunctions.mo
Expand Up @@ -186,7 +186,6 @@ algorithm
(eq,(shared,addEqs,idx+1));
else
equation
(shared,addEqs,idx) = tplIn;
then
(eqIn,tplIn);
end matchcontinue;
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -306,7 +306,6 @@ algorithm

case (v, _, ((e as BackendDAE.SOLVED_EQUATION(componentRef = cref, exp = e1, source= source_, differentiated=diffed))::xs), eq_count, {}, _, countRelations, countMathFunctions, zcs, relationsLst, sampleLst, eqnsAccum, whenClauseAccum)
equation
eq_count_1 = eq_count + 1;
(eres1, countRelations, countMathFunctions, res, relationsLst, sampleLst) = findZeroCrossings3(e1, zcs, relationsLst, sampleLst, countRelations, countMathFunctions, eq_count, -1, v, knvars);
eqnsAccum = listAppend({BackendDAE.SOLVED_EQUATION(cref, eres1, source_, diffed)}, eqnsAccum);
(res1, eq_reslst, wc_reslst, countRelations, countMathFunctions, relationsLst, sampleLst) = findZeroCrossings2(v, knvars, xs, eq_count, {}, 0, countRelations, countMathFunctions, res, relationsLst, sampleLst, eqnsAccum, whenClauseAccum);
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/HpcOmEqSystems.mo
Expand Up @@ -755,7 +755,6 @@ algorithm
mapIncRowEqn = listArray(List.intRange(nEqs));
mapEqnIncRow = Util.arrayMap(mapIncRowEqn,List.create);
(sysTmp,compsTmp) = BackendDAETransform.strongComponentsScalar(sysTmp,shared,mapEqnIncRow,mapIncRowEqn);
sysTmp = BackendDAE.EQSYSTEM(vars,eqArr,SOME(m),SOME(mt),matching,{});
compsTmp = listAppend(compsIn,compsTmp);
matchingTmp = BackendDAE.MATCHING(ass1, ass2, compsTmp);
then
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/HpcOmSimCode.mo
Expand Up @@ -173,7 +173,6 @@ algorithm
Real graphCosts;
Integer graphOps;
case (BackendDAE.DAE(eqs=eqs), _, _, _, _, _, _, _, _, _, _, _) equation
uniqueEqIndex = 1;

//Setup
//-----
Expand Down
6 changes: 0 additions & 6 deletions Compiler/BackEnd/HpcOmTaskGraph.mo
Expand Up @@ -683,7 +683,6 @@ algorithm
eqDescLst = stringListStringChar(eqString);
eqDescLst = List.map(eqDescLst,prepareXML);
eqString = stringCharListString(eqDescLst);
descLst = eqString::iEqDesc;
//get the variable string
varLst = BackendVariable.varList(orderedVars);
//var = listGet(varLst,arrayGet(ass2,i));
Expand All @@ -702,7 +701,6 @@ algorithm
eqDescLst = stringListStringChar(eqString);
eqDescLst = List.map(eqDescLst,prepareXML);
eqString = stringCharListString(eqDescLst);
descLst = eqString::iEqDesc;
//get the variable string
varLst = BackendVariable.varList(orderedVars);
//var = listGet(varLst,arrayGet(ass2,i));
Expand Down Expand Up @@ -739,7 +737,6 @@ algorithm
eqDescLst = stringListStringChar(eqString);
eqDescLst = List.map(eqDescLst,prepareXML);
eqString = stringCharListString(eqDescLst);
descLst = eqString::iEqDesc;
//get the variable string
varLst = BackendVariable.varList(orderedVars);
//var = listGet(varLst,arrayGet(ass2,i));
Expand Down Expand Up @@ -4723,7 +4720,6 @@ algorithm
costValue2 = costValueParent +. costValue2;
costValue2 = realMax(costValue1,costValue2);
levelValue2 = intMax(levelValueParent+1,levelValue1);
parentCount2 = parentCount1-1;
rootInfo = (levelValue2,costValue2,parentCount1);
nodeInfoTmp = arrayUpdate(nodeInfoIn,rootNode,rootInfo);
childNodes = arrayGet(graphIn,rootNode);
Expand All @@ -4750,7 +4746,6 @@ algorithm
costValue2 = costValueParent +. costValue2;
costValue2 = realMax(costValue1,costValue2);
levelValue2 = intMax(levelValueParent+1,levelValue1);
parentCount2 = parentCount1-1;
rootInfo = (levelValue2,costValue2,parentCount1-1);
nodeInfoTmp = arrayUpdate(nodeInfoIn,rootNode,rootInfo);
childNodes = arrayGet(graphIn,rootNode);
Expand All @@ -4761,7 +4756,6 @@ algorithm
foldTmp;
else
equation
(childNodesIn,nodeInfoIn) = foldIn;
(rootNodes,rootParents) = rootNodeInfo;
rootNode = listGet(rootNodes,rootIdx);
rootParent = listGet(rootParents,rootIdx);
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/OnRelaxation.mo
Expand Up @@ -2901,7 +2901,6 @@ algorithm
case (c::rest,_,_,_,_,_,_,_,_,_,_,_,_)
equation
r = ass2[c];
b = queuemark[c];
// print("Process Colum " +& intString(c) +& " Rows " +& stringDelimitList(List.map(r,intString),", ") +& " " +& boolString(b) +&"\n");
(colums1,b2) = getIndexQueque1(r,c,mT,mark,rowmarks,{},false);
// BackendDump.debuglst((colums1,intString,", ","\n"));
Expand Down
1 change: 0 additions & 1 deletion Compiler/BackEnd/SimCodeUtil.mo
Expand Up @@ -10056,7 +10056,6 @@ algorithm
equation
(_, indx) = get1(key, hashTable);
// print("adding when present, indx =" );print(intString(indx));print("\n");
indx_1 = indx - 1;
varr_1 = valueArraySetnth(varr, indx, newv);
then SimCode.HASHTABLE(hashvec, varr_1, bsize, n);
case (_, _)
Expand Down
2 changes: 0 additions & 2 deletions Compiler/BackEnd/Tearing.mo
Expand Up @@ -3590,7 +3590,6 @@ algorithm
equation
true = List.isNotEmpty(currLoop);
true = indxCol == listLength(arrayGet(aIn,indxRow));
parent = indxRow;
child = listGet(arrayGet(aIn,indxRow),indxCol);
currLoop = child::currLoop;
print("append loop and jump to next vertex "+&stringDelimitList(List.map(currLoop,intString),",")+&"\n");
Expand All @@ -3600,7 +3599,6 @@ algorithm
equation
true = indxCol < listLength(arrayGet(aIn,indxRow));
print("now we have more loops\n");
parent = indxRow;
row = arrayGet(aIn,indxRow);
unfinLoops = traceMooreLoops(unfinLoops,currLoop,row,2);
child = listGet(arrayGet(aIn,indxRow),indxCol);
Expand Down
2 changes: 0 additions & 2 deletions Compiler/BackEnd/Uncertainties.mo
Expand Up @@ -2697,7 +2697,6 @@ algorithm
case(-1,DAE.CREF(_,_))
equation
tp=Expression.typeof(eIn);
e=DAE.UNARY(DAE.UMINUS(tp),eIn);
then eIn;
case(1,DAE.CREF(_,_))
then eIn;
Expand Down Expand Up @@ -2877,7 +2876,6 @@ algorithm
case (_,_,_,e1 as DAE.CREF(componentRef = cr1),e2 as DAE.CREF(componentRef = cr2))
equation
source=getSourceIfApproximated(eqn);
tp = DAE.T_REAL_DEFAULT; //Assume is real
new_sets=pushToSetList(sets,cr1,e1,1,cr2,e2,1,source);
then (new_sets,eqn_acc);
// a = -b;
Expand Down
1 change: 0 additions & 1 deletion Compiler/FrontEnd/ExpressionSimplify.mo
Expand Up @@ -2881,7 +2881,6 @@ algorithm
case (DAE.BINARY(exp1 = e1,operator = DAE.POW(ty = _),exp2 = DAE.UNARY(operator = DAE.UMINUS(ty = tp),exp = DAE.ICONST(integer = icoeff))))
equation
coeff_1 = intReal(icoeff);
coeff_2 = 0.0 -. coeff_1;
then
(e1,coeff_1);

Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/InnerOuter.mo
Expand Up @@ -1939,7 +1939,6 @@ algorithm
equation
(_,indx) = get1(key, hashTable);
//print("adding when present, indx =" );print(intString(indx));print("\n");
indx_1 = indx - 1;
varr_1 = valueArraySetnth(varr, indx, newv);
// print("Updated NEW to IH: key:" +& ComponentReference.printComponentRefStr(key) +& " value: " +& printInnerDefStr(value) +& "\n");
then HASHTABLE(hashvec,varr_1,bsize,n);
Expand Down Expand Up @@ -2010,7 +2009,6 @@ algorithm
case (_,HASHTABLE(hashvec,varr,bsize,n))
equation
(_,indx) = get1(key, hashTable);
indx_1 = indx - 1;
varr_1 = valueArrayClearnth(varr, indx);
then HASHTABLE(hashvec,varr_1,bsize,n);
else
Expand Down
1 change: 0 additions & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -1883,7 +1883,6 @@ algorithm
equation
false = numIter < Global.recursionDepthLimit;
n = Env.printEnvPathStr(env);
strDepth = intString(Global.recursionDepthLimit);
// print("partialInstClassIn recursion depth... " +& n +& "\n");
Error.addSourceMessage(Error.RECURSION_DEPTH_REACHED,{n},SCode.elementInfo(c));
then fail();
Expand Down
1 change: 0 additions & 1 deletion Compiler/FrontEnd/InstExtends.mo
Expand Up @@ -695,7 +695,6 @@ algorithm
equation
str1 = SCodeDump.unparseElementStr(inClass,SCodeDump.defaultOptions);
str2 = Env.printEnvPathStr(inEnv);
strDepth = intString(Global.recursionDepthLimit);
// print("instDerivedClassesWork recursion depth... " +& str1 +& " " +& str2 +& "\n");
Error.addSourceMessage(Error.RECURSION_DEPTH_DERIVED,{str1,str2},inInfo);
then fail();
Expand Down
1 change: 0 additions & 1 deletion Compiler/FrontEnd/Lookup.mo
Expand Up @@ -2594,7 +2594,6 @@ algorithm
case(expl,dims)
equation
str2 = intString(dims);
exp = DAE.ARRAY(DAE.T_INTEGER_DEFAULT,false,expl);
str1 = stringDelimitList(List.map(expl,ExpressionDump.printExpStr)," and position " );
Error.addMessage(Error.ARRAY_INDEX_OUT_OF_BOUNDS,{str1,str2});
then
Expand Down
12 changes: 10 additions & 2 deletions Compiler/FrontEnd/Patternm.mo
Expand Up @@ -1089,7 +1089,7 @@ algorithm
// TODO: Can skip matchcontinue and failure if there was an AvlTree.exists(key)
_ = AvlTreeString.avlTreeGet(localsTree,name);
failure(_ = AvlTreeString.avlTreeGet(useTree,name));
Error.assertionOrAddSourceMessage(not Flags.isSet(Flags.PATTERNM_ALL_INFO),Error.META_UNUSED_AS_BINDING,{name},info);
Error.assertionOrAddSourceMessage(not Flags.isSet(Flags.PATTERNM_ALL_INFO),Error.META_UNUSED_ASSIGNMENT,{name},info);
then ((DAE.CREF(DAE.WILD(),ty),extra));
case ((DAE.PATTERN(pattern=pat),extra))
equation
Expand Down Expand Up @@ -2590,7 +2590,7 @@ protected function statementListFindDeadStoreRemoveEmptyStatements
output AvlTreeString.AvlTree useTree;
algorithm
(body,useTree) := List.map1Fold(listReverse(inBody),statementFindDeadStore,localsTree,inUseTree);
body := List.select(body,Algorithm.isNotDummyStatement);
body := List.select(body,isNotDummyStatement);
body := listReverse(body);
end statementListFindDeadStoreRemoveEmptyStatements;

Expand Down Expand Up @@ -2731,4 +2731,12 @@ algorithm
end match;
end elseFindDeadStore;

protected function isNotDummyStatement
input DAE.Statement statement;
output Boolean b;
algorithm
b := Algorithm.isNotDummyStatement(statement);
Error.assertionOrAddSourceMessage(b or not Flags.isSet(Flags.PATTERNM_ALL_INFO),Error.META_DEAD_CODE,{"Statement optimised away"},DAEUtil.getElementSourceFileInfo(Algorithm.getStatementSource(statement)));
end isNotDummyStatement;

end Patternm;
1 change: 0 additions & 1 deletion Compiler/FrontEnd/Static.mo
Expand Up @@ -7500,7 +7500,6 @@ algorithm

case (cache,env,fn,args,nargs,impl,_,st,pre,_)
equation
t4 = args;
failure((_,_,_) = Lookup.lookupType(cache,env, fn, NONE())) "msg" ;
scope = Env.printEnvPathStr(env) +& " (looking for a function or record)";
fn_str = Absyn.pathString(fn);
Expand Down
2 changes: 0 additions & 2 deletions Compiler/FrontEnd/Types.mo
Expand Up @@ -4389,7 +4389,6 @@ algorithm
ty2 = arrayElementType(ty2);
ety1 = simplifyType(ty2);
ty2 = liftArrayListDims(ty2, dims);
exp = DAE.ARRAY(DAE.T_ARRAY(ety1, dims, DAE.emptyTypeSource), sc, elist_1);
//TODO: Verify correctness of return value.
then
(DAE.ARRAY(DAE.T_ARRAY(ety1, dims, DAE.emptyTypeSource),sc,elist_1), ty2);
Expand Down Expand Up @@ -4588,7 +4587,6 @@ algorithm
case (DAE.TUPLE(elist),DAE.T_TUPLE(tupleType = tys1),ty2 as DAE.T_METABOXED(ty = DAE.T_UNKNOWN(source =_), source = ts2),_)
equation
true = Config.acceptMetaModelicaGrammar();
e_1 = DAE.META_TUPLE(elist);
tys2 = List.fill(ty2, listLength(tys1));
(elist_1,tys_1) = matchTypeTuple(elist, tys1, tys2, printFailtrace);
then
Expand Down
2 changes: 0 additions & 2 deletions Compiler/Main/Main.mo
Expand Up @@ -255,7 +255,6 @@ algorithm
else
equation
true = Util.isSome(inStatements) or Util.isSome(inProgram);
_ = setStackOverflowSignal(false);
Error.addMessage(Error.STACK_OVERFLOW, {inCommand});
then ("", inSymbolTable);

Expand Down Expand Up @@ -1160,7 +1159,6 @@ algorithm
print(" Most OpenModelica release distributions have scripts that set OPENMODELICAHOME for you.\n\n");

// Functions used by external code that needs to be included for linking
_ = Absyn.isDerCref;
then fail();
end matchcontinue;
end main2;
Expand Down
1 change: 0 additions & 1 deletion Compiler/Script/CevalScript.mo
Expand Up @@ -4942,7 +4942,6 @@ algorithm
Debug.fprintln(Flags.DYN_LOAD, "buildModel: Compiling done.");
// SimCodegen.generateMakefileBeast(makefilename, filenameprefix, libs, file_dir);
win1 = getWithinStatement(classname);
p2 = Absyn.PROGRAM({cdef},win1,ts);
compileModel(filenameprefix, libs, file_dir,method_str);
// (p as Absyn.PROGRAM(globalBuildTimes=Absyn.TIMESTAMP(r1,r2))) = Interactive.updateProgram2(p2,p,false);
st2 = st; // Interactive.replaceSymbolTableProgram(st,p);
Expand Down
2 changes: 0 additions & 2 deletions Compiler/Script/Interactive.mo
Expand Up @@ -1352,7 +1352,6 @@ algorithm
Absyn.CLASS(name,false,false,false,Absyn.R_MODEL(),Absyn.dummyParts,Absyn.dummyInfo)
}, Absyn.WITHIN(path_1),Absyn.dummyTimeStamp), p);
newst = setSymbolTableAST(st, newp);
resstr = stringAppend(name, "\n");
then
("true",newst);

Expand Down Expand Up @@ -10146,7 +10145,6 @@ algorithm
newp;
case ((model_ as Absyn.CREF_IDENT(name = _)),nargs,p as Absyn.PROGRAM(globalBuildTimes=ts))
equation
exp = Absyn.CALL(model_,Absyn.FUNCTIONARGS({},nargs));
modelpath = Absyn.crefToPath(model_) "Class on top level" ;
cdef = getPathedClassInProgram(modelpath, p);
cdef_1 = addClassAnnotationToClass(cdef, nargs);
Expand Down
1 change: 0 additions & 1 deletion Compiler/Template/TplAbsyn.mo
Expand Up @@ -3811,7 +3811,6 @@ algorithm
case ( (ident, mexp) :: fms, _, _, usedLocals, astDefs)
equation
failure( _ = lookupTupleList(fields, ident) );
reason = "#Error - unresolved type - cannot find field '" +& ident +& "'#";
//locals = addLocalValue(ident, UNRESOLVED_TYPE(reason), locals);
Debug.fprint(Flags.FAILTRACE, "Error - rewriteMatchExpByLocalNamesRecord failed to find field '" +& ident +& "'\n");
(fms, usedLocals) = rewriteMatchExpByLocalNamesRecord(fms, fields, inLocalNames, usedLocals, astDefs);
Expand Down
2 changes: 0 additions & 2 deletions Compiler/Util/BaseHashSet.mo
Expand Up @@ -152,7 +152,6 @@ algorithm
equation
(_,indx) = get1(key, hashSet);
//print("adding when present, indx =" );print(intString(indx));print("\n");
indx_1 = indx - 1;
varr_1 = valueArraySetnth(varr, indx, key);
then ((hashvec,varr_1,bsize,n,fntpl));

Expand Down Expand Up @@ -264,7 +263,6 @@ algorithm
case (_,(hashvec,varr,bsize,n,fntpl))
equation
(_,indx) = get1(key, hashSet);
indx_1 = indx - 1;
varr_1 = valueArrayClearnth(varr, indx);
then ((hashvec,varr_1,bsize,n,fntpl));
case (_,_)
Expand Down
4 changes: 3 additions & 1 deletion Compiler/Util/Error.mo
Expand Up @@ -646,7 +646,6 @@ public constant Message GENERATE_SEPARATE_CODE_DEPENDENCIES_FAILED = MESSAGE(242
public constant Message CYCLIC_DEFAULT_VALUE = MESSAGE(243, SCRIPTING(), ERROR(),
Util.gettext("The default value of %s causes a cyclic dependency."));


public constant Message UNBOUND_PARAMETER_WITH_START_VALUE_WARNING = MESSAGE(499, TRANSLATION(), WARNING(),
Util.gettext("Parameter %s has no value, and is fixed during initialization (fixed=true), using available start value (start=%s) as default value."));
public constant Message UNBOUND_PARAMETER_WARNING = MESSAGE(500, TRANSLATION(), WARNING(),
Expand Down Expand Up @@ -786,6 +785,9 @@ public constant Message FOUND_NON_NUMERIC_TYPES = MESSAGE(5032, TRANSLATION(), E
Util.gettext("Operator %s expects numeric types as operands, but got '%s and %s'."));
public constant Message STRUCTURAL_PARAMETER_OR_CONSTANT_WITH_NO_BINDING = MESSAGE(5033, TRANSLATION(), ERROR(),
Util.gettext("Could not evaluate structural parameter (or constant): %s which gives dimensions of array: %s. Array dimensions must be known at compile time."));
public constant Message META_UNUSED_ASSIGNMENT = MESSAGE(5034, TRANSLATION(), NOTIFICATION(),
Util.gettext("Removing unused assignment to: %s."));

public constant Message COMPILER_ERROR = MESSAGE(5999, TRANSLATION(), ERROR(),
Util.notrans("%s"));
public constant Message COMPILER_WARNING = MESSAGE(6000, TRANSLATION(), WARNING(),
Expand Down

0 comments on commit b0c8f3e

Please sign in to comment.