Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit ef1458e

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Only print we remove variables actually removed
The problem is loops have 1 extra call to find dead stores, and notifications from this step should not be visible.
1 parent 86c3226 commit ef1458e

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Compiler/FrontEnd/Patternm.mo

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import ElementSource;
6565
import Expression;
6666
import ExpressionDump;
6767
import Error;
68+
import ErrorExt;
6869
import Flags;
6970
import FGraph;
7071
import Inst;
@@ -1284,7 +1285,7 @@ protected function checkDefUsePattern
12841285
output DAE.Pattern outPat;
12851286
output tuple<AvlSetString.Tree,AvlSetString.Tree,SourceInfo> outTpl=inTpl;
12861287
algorithm
1287-
outPat := matchcontinue (inPat,inTpl)
1288+
outPat := match (inPat,inTpl)
12881289
local
12891290
AvlSetString.Tree localsTree,useTree;
12901291
String name;
@@ -1294,7 +1295,6 @@ algorithm
12941295
tuple<AvlSetString.Tree,AvlSetString.Tree,SourceInfo> extra;
12951296
case ((DAE.PAT_AS(id=name,pat=pat),extra as (localsTree,useTree,info)))
12961297
equation
1297-
// TODO: Can skip matchcontinue and failure if there was an AvlTree.exists(key)
12981298
if AvlSetString.hasKey(localsTree,name) and not AvlSetString.hasKey(useTree,name) then
12991299
Error.assertionOrAddSourceMessage(not Flags.isSet(Flags.PATTERNM_ALL_INFO),Error.META_UNUSED_AS_BINDING,{name},info);
13001300
else
@@ -1303,7 +1303,6 @@ algorithm
13031303
then pat;
13041304
case ((DAE.PAT_AS_FUNC_PTR(id=name,pat=pat),extra as (localsTree,useTree,info)))
13051305
equation
1306-
// TODO: Can skip matchcontinue and failure if there was an AvlTree.exists(key)
13071306
if AvlSetString.hasKey(localsTree,name) and not AvlSetString.hasKey(useTree,name) then
13081307
Error.assertionOrAddSourceMessage(not Flags.isSet(Flags.PATTERNM_ALL_INFO),Error.META_UNUSED_AS_BINDING,{name},info);
13091308
else
@@ -1314,7 +1313,7 @@ algorithm
13141313
algorithm
13151314
(pat,_) := simplifyPattern(inPat,1);
13161315
then pat;
1317-
end matchcontinue;
1316+
end match;
13181317
end checkDefUsePattern;
13191318

13201319
protected function useLocalCref
@@ -2959,7 +2958,9 @@ algorithm
29592958
case DAE.STMT_FOR(ty,b,id,index,exp,body,source)
29602959
equation
29612960
// Loops repeat, so check for usage in the whole loop before removing any dead stores.
2961+
ErrorExt.setCheckpoint(getInstanceName());
29622962
(_, useTree) = List.map1Fold(body, statementFindDeadStore, localsTree, inUseTree);
2963+
ErrorExt.rollBack(getInstanceName());
29632964
(body,useTree) = statementListFindDeadStoreRemoveEmptyStatements(body,localsTree, useTree);
29642965
(_,useTree) = Expression.traverseExpBottomUp(exp, useLocalCref, useTree);
29652966
// TODO: We should remove ident from the use-tree in case of shadowing... But our avlTree cannot delete
@@ -2969,7 +2970,9 @@ algorithm
29692970
case DAE.STMT_WHILE(exp=exp,statementLst=body,source=source)
29702971
equation
29712972
// Loops repeat, so check for usage in the whole loop before removing any dead stores.
2973+
ErrorExt.setCheckpoint(getInstanceName());
29722974
(_, useTree) = List.map1Fold(body, statementFindDeadStore, localsTree, inUseTree);
2975+
ErrorExt.rollBack(getInstanceName());
29732976
(body,useTree) = statementListFindDeadStoreRemoveEmptyStatements(body, localsTree, useTree);
29742977
(_,useTree) = Expression.traverseExpBottomUp(exp, useLocalCref, useTree);
29752978
// The loop might not be entered just like if. The following should not remove all previous uses:

Compiler/Util/BaseAvlSet.mo

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,13 @@ function printTreeStr
222222
protected
223223
Tree left, right;
224224
algorithm
225-
NODE(left = left, right = right) := inTree;
226-
outString := printTreeStr2(left, true, "") +
225+
outString := match inTree
226+
case EMPTY() then "EMPTY()";
227+
case LEAF() then printNodeStr(inTree);
228+
case NODE(left = left, right = right) then printTreeStr2(left, true, "") +
227229
printNodeStr(inTree) + "\n" +
228230
printTreeStr2(right, false, "");
231+
end match;
229232
end printTreeStr;
230233

231234
replaceable function setTreeLeftRight

0 commit comments

Comments
 (0)