This should be a pretty simple review -- mostly housecleaning...

While working in scalarReplace.cpp this week, I noticed that we sort through cases that make for a legal scalar replacement, but then there's a nested else if conditional that has no 'else' clause which suggests that expressions could slip through and not be scalar replaced. I added an else clause with an INT_FATAL in it to help people who add new cases but then fail to replace them.

While here, I also cleaned up some logic relating to unnecessarily checking too much whether call is NULL or not.

-Brad
Index: compiler/optimizations/scalarReplace.cpp
===================================================================
--- compiler/optimizations/scalarReplace.cpp	(revision 22796)
+++ compiler/optimizations/scalarReplace.cpp	(working copy)
@@ -255,7 +255,6 @@
   //
   for_uses(se, useMap, sym) {
     if (CallExpr* call = toCallExpr(se->parentExpr)) {
-     if (call) {
       SET_LINENO(call);
       if (call->isPrimitive(PRIM_GET_MEMBER)) {
         SymExpr* member = toSymExpr(call->get(2));
@@ -298,8 +297,9 @@
         addDef(defMap, def);
         if (call->get(1)->typeInfo() == call->get(2)->typeInfo()->refType)
           call->insertAtTail(new CallExpr(PRIM_ADDR_OF, call->get(2)->remove()));
+      } else {
+        INT_FATAL("It seems someone forgot to rewrite an Expression");
       }
-     }
     }
   }
 
@@ -417,7 +417,7 @@
     if (CallExpr* call = toCallExpr(se->parentExpr)) {
       SET_LINENO(sym);
       // Do we need to add a case for PRIM_ASSIGN?
-      if (call && call->isPrimitive(PRIM_MOVE)) {
+      if (call->isPrimitive(PRIM_MOVE)) {
         SymExpr* lhs = toSymExpr(call->get(1));
         for_fields(field, ct) {
           SymExpr* lhsCopy = lhs->copy();
@@ -428,17 +428,17 @@
           addUse(useMap, lhsCopy);
         }
         call->remove();
-      } else if (call && call->isPrimitive(PRIM_GET_MEMBER)) {
+      } else if (call->isPrimitive(PRIM_GET_MEMBER)) {
         SymExpr* member = toSymExpr(call->get(2));
         SymExpr* use = new SymExpr(fieldMap.get(member->var));
         call->replace(new CallExpr(PRIM_ADDR_OF, use));
         addUse(useMap, use);
-      } else if (call && call->isPrimitive(PRIM_GET_MEMBER_VALUE)) {
+      } else if (call->isPrimitive(PRIM_GET_MEMBER_VALUE)) {
         SymExpr* member = toSymExpr(call->get(2));
         SymExpr* use = new SymExpr(fieldMap.get(member->var));
         call->replace(use);
         addUse(useMap, use);
-      } else if (call && call->isPrimitive(PRIM_SET_MEMBER)) {
+      } else if (call->isPrimitive(PRIM_SET_MEMBER)) {
         SymExpr* member = toSymExpr(call->get(2));
         call->primitive = primitives[PRIM_MOVE];
         call->get(2)->remove();
@@ -448,6 +448,8 @@
         addDef(defMap, def);
         if (call->get(1)->typeInfo() == call->get(2)->typeInfo()->refType)
           call->insertAtTail(new CallExpr(PRIM_ADDR_OF, call->get(2)->remove()));
+      } else {
+        INT_FATAL("Someone forgot to scalar replace an expression");
       }
     }
   }
------------------------------------------------------------------------------
Flow-based real-time traffic analytics software. Cisco certified tool.
Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
Customize your own dashboards, set traffic alerts and generate reports.
Network behavioral analysis & security monitoring. All-in-one tool.
http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to