Repository: systemml Updated Branches: refs/heads/master 563b8926b -> 1fbf939d7
[SYSTEMML-2388] Fix IPA inlining of functions w/o bound returns The IPA rewrite for inlining small functions led to invalid hops in case of special cases of functions w/o returns and remaining transient writes from a previously existing sequence of statement blocks that were combined into a single block via rewrites. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/1fbf939d Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/1fbf939d Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/1fbf939d Branch: refs/heads/master Commit: 1fbf939d7b4e9d989520a1022e318c17a373b8e2 Parents: 563b892 Author: Matthias Boehm <mboe...@gmail.com> Authored: Tue Jun 12 13:10:43 2018 -0700 Committer: Matthias Boehm <mboe...@gmail.com> Committed: Tue Jun 12 13:10:43 2018 -0700 ---------------------------------------------------------------------- .../sysml/hops/ipa/IPAPassInlineFunctions.java | 5 +++- .../functions/misc/FunctionPotpourriTest.java | 7 +++++ .../functions/misc/FunPotpourriNoReturn2.dml | 28 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/1fbf939d/src/main/java/org/apache/sysml/hops/ipa/IPAPassInlineFunctions.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/hops/ipa/IPAPassInlineFunctions.java b/src/main/java/org/apache/sysml/hops/ipa/IPAPassInlineFunctions.java index 51e3754..2f76a55 100644 --- a/src/main/java/org/apache/sysml/hops/ipa/IPAPassInlineFunctions.java +++ b/src/main/java/org/apache/sysml/hops/ipa/IPAPassInlineFunctions.java @@ -96,8 +96,11 @@ public class IPAPassInlineFunctions extends IPAPass outMap.put(fstmt.getOutputParams().get(j).getName(), opOutputs[j]); for(int j=0; j<hops2.size(); j++) { Hop out = hops2.get(j); - if( HopRewriteUtils.isData(out, DataOpTypes.TRANSIENTWRITE) ) + if( HopRewriteUtils.isData(out, DataOpTypes.TRANSIENTWRITE) ) { out.setName(outMap.get(out.getName())); + if( out.getName() == null ) + hops2.remove(j); + } } fcallsSB.get(i).getHops().remove(op); fcallsSB.get(i).getHops().addAll(hops2); http://git-wip-us.apache.org/repos/asf/systemml/blob/1fbf939d/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionPotpourriTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionPotpourriTest.java b/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionPotpourriTest.java index b5bd02f..21f06ae 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionPotpourriTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionPotpourriTest.java @@ -30,6 +30,7 @@ public class FunctionPotpourriTest extends AutomatedTestBase { private final static String TEST_NAME1 = "FunPotpourriNoReturn"; private final static String TEST_NAME2 = "FunPotpourriComments"; + private final static String TEST_NAME3 = "FunPotpourriNoReturn2"; private final static String TEST_DIR = "functions/misc/"; private final static String TEST_CLASS_DIR = TEST_DIR + FunctionPotpourriTest.class.getSimpleName() + "/"; @@ -39,6 +40,7 @@ public class FunctionPotpourriTest extends AutomatedTestBase TestUtils.clearAssertionInformation(); addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "R" }) ); addTestConfiguration( TEST_NAME2, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "R" }) ); + addTestConfiguration( TEST_NAME3, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME3, new String[] { "R" }) ); } @Test @@ -51,6 +53,11 @@ public class FunctionPotpourriTest extends AutomatedTestBase runFunctionTest( TEST_NAME2, false ); } + @Test + public void testFunctionNoReturnSpec() { + runFunctionTest( TEST_NAME3, false ); + } + private void runFunctionTest(String testName, boolean error) { TestConfiguration config = getTestConfiguration(testName); loadTestConfiguration(config); http://git-wip-us.apache.org/repos/asf/systemml/blob/1fbf939d/src/test/scripts/functions/misc/FunPotpourriNoReturn2.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/FunPotpourriNoReturn2.dml b/src/test/scripts/functions/misc/FunPotpourriNoReturn2.dml new file mode 100644 index 0000000..bc7b94d --- /dev/null +++ b/src/test/scripts/functions/misc/FunPotpourriNoReturn2.dml @@ -0,0 +1,28 @@ +#------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#------------------------------------------------------------- + +foo = function (String msg) { + verbose = FALSE + if (verbose) + print(msg) +} + +foo("This is an test error message.")