Browse Source

HPCC-15767 Remove calls to isPure()

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 9 years ago
parent
commit
3ab2d8ba85

+ 8 - 4
ecl/hql/hqlfold.cpp

@@ -4764,7 +4764,11 @@ IHqlExpression * CExprFolderTransformer::doFoldTransformed(IHqlExpression * unfo
                         break;
                     }
                 }
-                if (!newRow || !newRow->isPure())
+                if (!newRow)
+                    break;
+
+                //Instead of evaluating once newRow will be evaluated multiple times.  Is that ok (e.g., volatile)
+                if (!canDuplicateActivity(newRow))
                     break;
 
                 OwnedHqlExpr replacementRow = createRow(no_newrow, LINK(newRow));
@@ -4905,7 +4909,7 @@ IHqlExpression * CExprFolderTransformer::doFoldTransformed(IHqlExpression * unfo
             switch (childOp)
             {
             case no_inlinetable:
-                if ((foldOptions & HFOconstantdatasets) && isPureInlineDataset(child))
+                if ((foldOptions & HFOconstantdatasets) && isNoSkipInlineDataset(child))
                     ret = queryOptimizeAggregateInline(expr, child->queryChild(0)->numChildren());
                 break;
             default:
@@ -4924,7 +4928,7 @@ IHqlExpression * CExprFolderTransformer::doFoldTransformed(IHqlExpression * unfo
             switch (childOp)
             {
             case no_inlinetable:
-                if (isPureInlineDataset(child))
+                if (isNoSkipInlineDataset(child))
                     return createConstant(expr->queryType()->castFrom(false, (__int64)child->queryChild(0)->numChildren()));
                 break;
             case no_null:
@@ -4958,7 +4962,7 @@ IHqlExpression * CExprFolderTransformer::doFoldTransformed(IHqlExpression * unfo
             switch (childOp)
             {
             case no_inlinetable:
-                if (isPureInlineDataset(child))
+                if (isNoSkipInlineDataset(child))
                 {
                     bool hasChildren = (child->queryChild(0)->numChildren() != 0);
                     return createConstant(hasChildren);

+ 3 - 1
ecl/hqlcpp/hqlcppcase.cpp

@@ -799,7 +799,9 @@ void HqlCppCaseInfo::buildGeneralReturn(BuildCtx & ctx)
 
 bool HqlCppCaseInfo::okToAlwaysEvaluateDefault()
 {
-    return defaultValue->isPure();
+    if (!canRemoveGuard(defaultValue))
+        return false;
+    return true;
 }
 
 ITypeInfo * HqlCppCaseInfo::queryCompareType()

+ 6 - 1
ecl/hqlcpp/hqlcse.cpp

@@ -465,7 +465,10 @@ bool CseSpotter::checkPotentialCSE(IHqlExpression * expr, CseSpotterInfo * extra
     if (extra->alreadyAliased)
         return false;
 
-    if (!expr->isPure() || !canCreateTemporary(expr))
+    if (!expr->isPure())
+        return false;
+
+    if (!canCreateTemporary(expr))
         return false;
 
     if (invariantSelector && exprReferencesDataset(expr, invariantSelector))
@@ -1223,10 +1226,12 @@ static bool canHoistInvariant(IHqlExpression * expr)
         if ((expr->getOperator() != no_alias) || expr->hasAttribute(globalAtom))
             return false;
     }
+
     if (!expr->isPure())
         return false;
     if (expr->isFunction())
         return false;
+
     switch (expr->getOperator())
     {
     case no_list:

+ 1 - 1
ecl/hqlcpp/hqlhtcpp.cpp

@@ -385,7 +385,7 @@ public:
             if (moveTo->isUnconditional() && isUsedUnconditionallyEnough(expr))
                 guard.set(queryBoolExpr(true));
 
-            bool invalid = !guard->isPure();
+            bool invalid = !canDuplicateExpr(guard);
             //version 1: don't guard any child queries.
             if (!matchesBoolean(guard, true))
             {

+ 2 - 2
ecl/hqlcpp/hqliproj.cpp

@@ -575,7 +575,7 @@ void UsedFieldSet::gatherTransformValuesUsed(HqlExprArray * selfSelects, HqlExpr
             IHqlExpression * transformValue = queryTransformAssignValue(transform, field);
             assertex(transformValue);
             bool includeThis = true;
-            if (!curNested.includeAll() && transformValue->isPure())
+            if (!curNested.includeAll() && !containsSkip(transformValue))
             {
                 if (transformValue->getOperator() == no_createrow)
                 {
@@ -2289,7 +2289,7 @@ void ImplicitProjectTransformer::processTransform(ComplexImplicitProjectInfo * e
         case no_assign:
             {
                 IHqlExpression * value = cur->queryChild(1);
-                if (!value->isPure())
+                if (containsSkip(value))
                 {
                     IHqlExpression * lhs = cur->queryChild(0);
                     processMatchingSelector(extra->outputFields, lhs, lhs->queryChild(0));

+ 4 - 1
ecl/hqlcpp/hqlresource.cpp

@@ -3090,6 +3090,9 @@ bool ResourcerInfo::expandRatherThanSpill(bool noteOtherSpills)
         if (info && info->forceHoist)
             return false;
 
+        if (!canDuplicateActivity(expr))
+            return false;
+
         node_operator op = expr->getOperator();
         switch (op)
         {
@@ -3597,7 +3600,7 @@ static bool isPotentialCompoundSteppedIndexRead(IHqlExpression * expr)
         case no_choosen:
             {
                 IHqlExpression * arg2 = expr->queryChild(2);
-                if (arg2 && !arg2->isPure())
+                if (arg2 && !canDuplicateExpr(arg2))
                     return false;
                 break;
             }

+ 1 - 1
ecllibrary/std/system/Debug.ecl

@@ -6,7 +6,7 @@
 
 rtl := SERVICE
  unsigned4 msTick() :       eclrtl,library='eclrtl',entrypoint='rtlTick';
- unsigned4 sleep(unsigned4 _delay) : eclrtl,library='eclrtl',entrypoint='rtlSleep';
+ unsigned4 sleep(unsigned4 _delay) : eclrtl,action,library='eclrtl',entrypoint='rtlSleep';
 END;
 
 import lib_parselib;