summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Yejun <yejun.guo@intel.com>2017-05-17 14:52:18 +0800
committerYang Rong <rong.r.yang@intel.com>2017-05-23 19:11:12 +0800
commitc5994621b2fc12f4eec4da7fc177c438fc757198 (patch)
tree52a3a37917670f2a318a618588c2b207ac9856b7
parent12719dbbb66be89cf9be4ddad36a24d7cc004ebd (diff)
refresh DAG when an arg has both direct and indirect read
when the return value is ARG_INDIRECT_READ, there is still possible that some IRs read it directly, and will be handled in buildConstantPush() so we need to refresh the dag afer function buildConstantPush another method is to update DAG accordingly, but i don't think it is easy compared with the refresh method, so i do not choose it. Signed-off-by: Guo Yejun <yejun.guo@intel.com> Reviewed-by: Yang Rong <rong.r.yang@intel.com>
-rw-r--r--backend/src/ir/lowering.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/backend/src/ir/lowering.cpp b/backend/src/ir/lowering.cpp
index 93bd96ad..bcf59400 100644
--- a/backend/src/ir/lowering.cpp
+++ b/backend/src/ir/lowering.cpp
@@ -199,6 +199,7 @@ namespace ir {
GBE_SAFE_DELETE(liveness);
this->liveness = GBE_NEW(ir::Liveness, *fn);
this->dag = GBE_NEW(ir::FunctionDAG, *this->liveness);
+ bool needRefreshDag = false;
// Process all structure arguments and find all the direct loads we can
// replace
@@ -207,13 +208,27 @@ namespace ir {
for (uint32_t argID = 0; argID < argNum; ++argID) {
FunctionArgument &arg = fn->getArg(argID);
if (arg.type != FunctionArgument::STRUCTURE) continue;
- if(this->lower(argID) == ARG_INDIRECT_READ)
+ if(this->lower(argID) == ARG_INDIRECT_READ) {
indirctReadArgs.push_back(argID);
+ //when the return value is ARG_INDIRECT_READ, there is still possible
+ //that some IRs read it directly, and will be handled in buildConstantPush()
+ //so we need to refresh the dag afer function buildConstantPush
+ for (const auto &loadAddImm : seq) {
+ if (loadAddImm.argID == argID)
+ needRefreshDag = true;
+ }
+ }
}
// Build the constant push description and remove the instruction that
// therefore become useless
this->buildConstantPush();
+ if (needRefreshDag) {
+ GBE_SAFE_DELETE(dag);
+ GBE_SAFE_DELETE(liveness);
+ this->liveness = GBE_NEW(ir::Liveness, *fn);
+ this->dag = GBE_NEW(ir::FunctionDAG, *this->liveness);
+ }
for (uint32_t i = 0; i < indirctReadArgs.size(); ++i){
lowerIndirectRead(indirctReadArgs[i]);
}