From d91275e3182b9995c4d136a36abc29a031ee6059 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Tue, 2 Oct 2018 13:39:08 +0900 Subject: [PATCH] [enco] Eliminate Objects with no backing bag (#1719) 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 --- .../enco/core/src/Transforms/DeadObjectElimination.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/contrib/enco/core/src/Transforms/DeadObjectElimination.cpp b/contrib/enco/core/src/Transforms/DeadObjectElimination.cpp index 1f5970e..fc77d9b 100644 --- a/contrib/enco/core/src/Transforms/DeadObjectElimination.cpp +++ b/contrib/enco/core/src/Transforms/DeadObjectElimination.cpp @@ -28,11 +28,20 @@ std::set 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); + } } } -- 2.7.4