From d20c42553f3e5c4d969e2045a35fb1ff05a13e87 Mon Sep 17 00:00:00 2001 From: linma Date: Mon, 18 Jul 2022 10:01:35 -0700 Subject: [PATCH] profileGen emit error, add emit phase for profileGen because old one "emitforipa" was deleted --- .../maple_ipa/src/ipa_phase_manager.cpp | 2 +- src/mapleall/maple_me/include/me_autovec.h | 2 +- src/mapleall/maple_me/include/me_emit.h | 1 + src/mapleall/maple_me/src/me_emit.cpp | 31 +++++++++++++++++++ .../maple_me/src/me_phase_manager.cpp | 1 + 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp b/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp index 164f7bad5c..9ce4533efa 100644 --- a/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp +++ b/src/mapleall/maple_ipa/src/ipa_phase_manager.cpp @@ -207,7 +207,7 @@ bool SCCProfile::PhaseRun(SCCNode &scc) { AddPhase("splitcriticaledge", true); AddPhase("profileGen", true); } - AddPhase("emitforipa", true); + AddPhase("profgenEmit", true); // Not like other phasemanager which use temp mempool to hold analysis results generated from the sub phases. // Here we use GetManagerMemPool which lives longer than this phase(manager) itself to hold all the analysis result. // So the following phase can access the result in this phase. diff --git a/src/mapleall/maple_me/include/me_autovec.h b/src/mapleall/maple_me/include/me_autovec.h index 0612469db7..537dea2e10 100644 --- a/src/mapleall/maple_me/include/me_autovec.h +++ b/src/mapleall/maple_me/include/me_autovec.h @@ -1,5 +1,5 @@ /* - * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * Copyright (c) [2021] Futurewei Technologies Co.,Ltd.All rights reserved. * * OpenArkCompiler is licensed under Mulan PSL v2. * You can use this software according to the terms and conditions of the Mulan PSL v2. diff --git a/src/mapleall/maple_me/include/me_emit.h b/src/mapleall/maple_me/include/me_emit.h index 421d9bbe77..4775981f4a 100644 --- a/src/mapleall/maple_me/include/me_emit.h +++ b/src/mapleall/maple_me/include/me_emit.h @@ -20,5 +20,6 @@ // emit ir to specified file namespace maple { MAPLE_FUNC_PHASE_DECLARE(MEEmit, MeFunction) +MAPLE_FUNC_PHASE_DECLARE(ProfileGenEmit, MeFunction) } // namespace maple #endif // MAPLE_ME_INCLUDE_ME_EMIT_H diff --git a/src/mapleall/maple_me/src/me_emit.cpp b/src/mapleall/maple_me/src/me_emit.cpp index 80fd11f309..7e7ad4e76d 100644 --- a/src/mapleall/maple_me/src/me_emit.cpp +++ b/src/mapleall/maple_me/src/me_emit.cpp @@ -148,4 +148,35 @@ bool MEEmit::PhaseRun(maple::MeFunction &f) { } return false; } + +void ProfileGenEmit::GetAnalysisDependence(maple::AnalysisDep &aDep) const { + aDep.SetPreservedAll(); +} + +// emit IR for profileGen +bool ProfileGenEmit::PhaseRun(maple::MeFunction &f) { + if (f.GetCfg()->NumBBs() > 0) { + CHECK_FATAL(f.GetIRMap(), "sanity check"); + // emit after hssa + MIRFunction *mirFunction = f.GetMirFunc(); + mirFunction->ReleaseCodeMemory(); + mirFunction->SetMemPool(new ThreadLocalMemPool(memPoolCtrler, "IR from IRMap::Emit()")); + mirFunction->SetBody(mirFunction->GetCodeMempool()->New()); + // initialize is_deleted field to true; will reset when emitting Maple IR + for (size_t k = 1; k < mirFunction->GetSymTab()->GetSymbolTableSize(); ++k) { + MIRSymbol *sym = mirFunction->GetSymTab()->GetSymbolFromStIdx(k); + if (sym->GetSKind() == kStVar) { + sym->SetIsDeleted(); + } + } + for (BB *bb : f.GetCfg()->GetAllBBs()) { + if (bb == nullptr) { + continue; + } + bb->EmitBB(*mirFunction->GetBody(), false); + } + ResetDependentedSymbolLive(mirFunction); + } + return false; +} } // namespace maple diff --git a/src/mapleall/maple_me/src/me_phase_manager.cpp b/src/mapleall/maple_me/src/me_phase_manager.cpp index 77a16dae13..a9b2f6072c 100644 --- a/src/mapleall/maple_me/src/me_phase_manager.cpp +++ b/src/mapleall/maple_me/src/me_phase_manager.cpp @@ -278,4 +278,5 @@ MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(MEPlacementRC, placementrc) MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(MEDse, dse) MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(MEABCOpt, abcopt) MAPLE_TRANSFORM_PHASE_REGISTER(MEEmit, meemit) +MAPLE_TRANSFORM_PHASE_REGISTER_CANSKIP(ProfileGenEmit, profgenEmit); } // namespace maple -- Gitee