[enco] Eliminate Objects with no backing bag (#1719)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Tue, 2 Oct 2018 04:39:08 +0000 (13:39 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Tue, 2 Oct 2018 04:39:08 +0000 (13:39 +0900)
This commit allows Dead Object Elimination (DOE) pass to eliminate
objects with no backing bag (if it has no uses).

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/enco/core/src/Transforms/DeadObjectElimination.cpp

index 1f5970e..fc77d9b 100644 (file)
@@ -28,11 +28,20 @@ std::set<coco::Object *> dead_objects(const coco::Module *m)
   for (uint32_t n = 0; n < m->entity()->object()->size(); ++n)
   {
     auto obj = m->entity()->object()->at(n);
-    auto bag = obj->bag();
 
-    if (coco::readers(bag).empty() && !(bag->isOutput()))
+    if (auto bag = obj->bag())
     {
-      res.insert(obj);
+      if (coco::readers(bag).empty() && !(bag->isOutput()))
+      {
+        res.insert(obj);
+      }
+    }
+    else
+    {
+      if (obj->uses()->size() == 0)
+      {
+        res.insert(obj);
+      }
     }
   }