Skip to content

Commit

Permalink
- Add dependency not to assign to an array before it is allocated
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12228 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jun 28, 2012
1 parent 721f3b0 commit 7d0bb6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Compiler/FrontEnd/InstUtil.mo
Expand Up @@ -1718,4 +1718,11 @@ algorithm
end match;
end printEquation;

public function isArrayAllocation
input InstTypes.Statement stmt;
output Boolean b;
algorithm
b := match stmt case InstTypes.FUNCTION_ARRAY_INIT(name=_) then true; else false; end match;
end isArrayAllocation;

end InstUtil;
10 changes: 4 additions & 6 deletions Compiler/FrontEnd/SCodeInst.mo
Expand Up @@ -1862,7 +1862,7 @@ algorithm
Error.assertionOrAddSourceMessage(not listMember(name,deps),Error.INTERNAL_ERROR,{"getStatementDependencies: self-dependence in deps"},info);
deps = List.intersectionOnTrue(allPossible,deps,stringEq);
then // O(n^2), but function init-bindings are usually too small to warrant a hashtable
List.select1(allStatements,selectStatement,deps);
List.select2(allStatements,selectStatement,deps,SOME(name));
case (InstTypes.FUNCTION_ARRAY_INIT(name,dimensions,info), (allStatements,allPossible))
equation
dims = List.map(arrayList(dimensions),InstUtil.unwrapDimension);
Expand All @@ -1871,7 +1871,7 @@ algorithm
Error.assertionOrAddSourceMessage(not listMember(name,deps),Error.INTERNAL_ERROR,{"getStatementDependencies: self-dependence in deps"},info);
deps = List.intersectionOnTrue(allPossible,deps,stringEq);
then // O(n^2), but function init-bindings are usually too small to warrant a hashtable
List.select1(allStatements,selectStatement,deps);
List.select2(allStatements,selectStatement,deps,NONE());
else
equation
Error.addMessage(Error.INTERNAL_ERROR,{"SCodeInst.getStatementDependencies failed"});
Expand All @@ -1882,17 +1882,15 @@ end getStatementDependencies;
protected function selectStatement
input Statement stmt;
input list<String> deps;
input Option<String> oname "If this is SOME(name), return true only if the statement is an array allocation.";
output Boolean select;
protected
String name;
algorithm
name := getInitStatementName(stmt);
select := listMember(name,deps);
select := listMember(name,deps) or (InstUtil.isArrayAllocation(stmt) and stringEq(name,Util.getOptionOrDefault(oname,"")));
end selectStatement;

protected function selectStatement2
end selectStatement2;

protected function getExpDependencies
input tuple<DAE.Exp,list<String>> inTpl;
output tuple<DAE.Exp,list<String>> outTpl;
Expand Down

0 comments on commit 7d0bb6d

Please sign in to comment.