diff --git a/src/bin/maple b/src/bin/maple index fe0b7350167db25ab374b7c642bb2ef021c2528d..76c011f5626f594583b19180ef663329ee1f92f1 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/bin/mplcg b/src/bin/mplcg index 6eeb609cfd05874c67e43881fb41a24f27cb67b1..877c2af423ded2ff415f447e5c0039c4010f5f4d 100755 Binary files a/src/bin/mplcg and b/src/bin/mplcg differ diff --git a/src/maple_driver/src/driver_runner.cpp b/src/maple_driver/src/driver_runner.cpp index 35bcfe060ef539c2f72f6ec8826dd216c0a916b3..13760bfdd6d3d65f2f6f7d67e72cac7d884e023d 100644 --- a/src/maple_driver/src/driver_runner.cpp +++ b/src/maple_driver/src/driver_runner.cpp @@ -166,22 +166,21 @@ void DriverRunner::InitPhases(InterleavedManager &mgr, const std::vector curPhases; for (const std::string &phase : phases) { - auto temp = mgr.GetSupportPhaseManager(phase); - if (temp != nullptr) { - if (temp != curManager) { - if (curManager != nullptr) { - AddPhases(mgr, curPhases, *curManager); - } - curManager = temp; + const PhaseManager *supportManager = mgr.GetSupportPhaseManager(phase); + if (supportManager != nullptr) { + if (curManager != nullptr && curManager != supportManager && !curPhases.empty()) { + AddPhases(mgr, curPhases, *curManager); curPhases.clear(); } - CHECK_FATAL(curManager != nullptr, "Invalid phase manager"); - AddPhase(curPhases, phase, *curManager); + if (curManager != supportManager) { + curManager = supportManager; + } + AddPhase(curPhases, phase, *supportManager); } } - if (curManager != nullptr) { + if (curManager != nullptr && !curPhases.empty()) { AddPhases(mgr, curPhases, *curManager); } } diff --git a/src/maple_ipa/include/module_phase_manager.h b/src/maple_ipa/include/module_phase_manager.h index 19f6f34577c6d21f591a3a96859482400d78f216..69091a28b2d6036f40b43591c54f67d9c75f20a4 100644 --- a/src/maple_ipa/include/module_phase_manager.h +++ b/src/maple_ipa/include/module_phase_manager.h @@ -14,22 +14,9 @@ */ #ifndef MAPLE_IPA_INCLUDE_MODULE_PHASE_MANAGER_H #define MAPLE_IPA_INCLUDE_MODULE_PHASE_MANAGER_H -#include "module_phase.h" #include "me_phase_manager.h" namespace maple { -class DoKlassHierarchy : public ModulePhase { - public: - explicit DoKlassHierarchy(ModulePhaseID id) : ModulePhase(id) {} - - AnalysisResult *Run(MIRModule *module, ModuleResultMgr *m) override; - std::string PhaseName() const override { - return "classhierarchy"; - } - - virtual ~DoKlassHierarchy() = default; -}; - class ModulePhaseManager : public PhaseManager { public: ModulePhaseManager(MemPool *memPool, MIRModule &mod, ModuleResultMgr *mrm = nullptr) diff --git a/src/maple_ipa/src/module_phase_manager.cpp b/src/maple_ipa/src/module_phase_manager.cpp index a6ee412aaa1560caa18a31199878828210623d7f..d0d2d3388323a906945f68125833acc492f295d9 100644 --- a/src/maple_ipa/src/module_phase_manager.cpp +++ b/src/maple_ipa/src/module_phase_manager.cpp @@ -38,25 +38,6 @@ constexpr char kDotMplStr[] = ".mpl"; namespace maple { // Manage the phases of middle and implement some maplecomb-options such as // skipAfter, skipFrom, quiet. -AnalysisResult *DoKlassHierarchy::Run(MIRModule *module, ModuleResultMgr *m) { - MemPool *memPool = memPoolCtrler.NewMemPool("classhierarchy mempool"); - KlassHierarchy *kh = memPool->New(module, memPool); - KlassHierarchy::traceFlag = TRACE_PHASE; - kh->BuildHierarchy(); -#if MIR_JAVA - if (!Options::skipVirtualMethod) { - kh->CountVirtualMethods(); - } -#else - kh->CountVirtualMethods(); -#endif - if (KlassHierarchy::traceFlag) { - kh->Dump(); - } - m->AddResult(GetPhaseID(), *module, *kh); - return kh; -} - void ModulePhaseManager::RegisterModulePhases() { #define MODAPHASE(id, modphase) \ do { \ diff --git a/src/maple_util/include/muid.h b/src/maple_util/include/muid.h index 41664c06c8c8fba4447dc21fed7c334fb4230ebe..beb29254addb82ce86c5aa5aec64a88308f0e0f8 100644 --- a/src/maple_util/include/muid.h +++ b/src/maple_util/include/muid.h @@ -95,11 +95,11 @@ struct MUID { std::string ToStr() const { std::stringstream sbuf; #ifdef USE_64BIT_MUID - sbuf << std::setfill('0') << std::setw(8) << std::hex << data.words[1] - << std::setfill('0') << std::setw(8) << std::hex << data.words[0]; + sbuf << std::setfill('0') << std::setw(8) << std::hex << data.words[1] << + std::setfill('0') << std::setw(8) << std::hex << data.words[0]; #else - sbuf << std::setfill('0') << std::setw(16) << std::hex << data.words[1] - << std::setfill('0') << std::setw(16) << std::hex << data.words[0]; + sbuf << std::setfill('0') << std::setw(16) << std::hex << data.words[1] << + std::setfill('0') << std::setw(16) << std::hex << data.words[0]; #endif // USE_64BIT_MUID return sbuf.str(); } diff --git a/src/maple_util/include/safe_cast.h b/src/maple_util/include/safe_cast.h index ff13ff68bd74ed3f40e7902347549157a4c311e3..39be207e513012f412a1ead89e6cb234f7da4565 100644 --- a/src/maple_util/include/safe_cast.h +++ b/src/maple_util/include/safe_cast.h @@ -25,7 +25,7 @@ struct safe_cast_condition : std::false_type {}; template <> \ struct safe_cast_condition : std::true_type { \ template \ - static inline bool DoIt(FromT &from) { \ + static inline bool DoIt(const FromT &from) { \ return (condition); \ } \ } @@ -34,14 +34,14 @@ namespace __impl { template ::value>> struct instance_of_impl { - static inline bool DoIt(FromT &from) { + static inline bool DoIt(const FromT &from) { return (safe_cast_condition::DoIt(from)); } }; template struct instance_of_impl::value>> { - static inline bool DoIt(FromT&) { + static inline bool DoIt(const FromT&) { return true; } }; diff --git a/src/mpl2mpl/include/class_hierarchy.h b/src/mpl2mpl/include/class_hierarchy.h index 13335b85180a37c84eaa7220ea66b99dd1057df0..0fddbe92655f4098c424f7c9a71f3d15081de39b 100644 --- a/src/mpl2mpl/include/class_hierarchy.h +++ b/src/mpl2mpl/include/class_hierarchy.h @@ -391,5 +391,17 @@ class KlassHierarchy : public AnalysisResult { MapleMap strIdx2KlassMap; MapleVector topoWorkList; }; + +class DoKlassHierarchy : public ModulePhase { + public: + explicit DoKlassHierarchy(ModulePhaseID id) : ModulePhase(id) {} + + AnalysisResult *Run(MIRModule *module, ModuleResultMgr *m) override; + std::string PhaseName() const override { + return "classhierarchy"; + } + + virtual ~DoKlassHierarchy() = default; +}; } // namespace maple #endif // MPL2MPL_INCLUDE_CLASS_HIERARCHY_H diff --git a/src/mpl2mpl/src/class_hierarchy.cpp b/src/mpl2mpl/src/class_hierarchy.cpp index bd0c139de6b873a18183280d9152ce722b7f26b7..2e7c3c36f1111d25ffd2472e4294c3558b32dc78 100644 --- a/src/mpl2mpl/src/class_hierarchy.cpp +++ b/src/mpl2mpl/src/class_hierarchy.cpp @@ -765,6 +765,25 @@ KlassHierarchy::KlassHierarchy(MIRModule *mirmodule, MemPool *memPool) strIdx2KlassMap(std::less(), alloc.Adapter()), topoWorkList(alloc.Adapter()) {} +AnalysisResult *DoKlassHierarchy::Run(MIRModule *module, ModuleResultMgr *m) { + MemPool *memPool = memPoolCtrler.NewMemPool("classhierarchy mempool"); + KlassHierarchy *kh = memPool->New(module, memPool); + KlassHierarchy::traceFlag = TRACE_PHASE; + kh->BuildHierarchy(); +#if MIR_JAVA + if (!Options::skipVirtualMethod) { + kh->CountVirtualMethods(); + } +#else + kh->CountVirtualMethods(); +#endif + if (KlassHierarchy::traceFlag) { + kh->Dump(); + } + m->AddResult(GetPhaseID(), *module, *kh); + return kh; +} + MIRType *WKTypes::javaLangObject; MIRType *WKTypes::javaLangString; MIRType *WKTypes::javaLangObjectSerializable;