diff --git a/src/mapleall/maple_be/include/cg/cg_ssu_pre.h b/src/mapleall/maple_be/include/cg/cg_ssu_pre.h index 3af0fca939c2235b6a3662b754229fce7998903b..d7e6eef56e31ab775e8b99e5673304fdaeb884c9 100644 --- a/src/mapleall/maple_be/include/cg/cg_ssu_pre.h +++ b/src/mapleall/maple_be/include/cg/cg_ssu_pre.h @@ -20,7 +20,7 @@ #include "cg_dominance.h" // Use SSUPRE to determine where to insert restores for callee-saved registers. -// The usage interface is DoRestorePlacementOpt(). Class SPreWorkCand is used +// The external interface is DoRestorePlacementOpt(). Class SPreWorkCand is used // as input/output interface. namespace maplebe { @@ -42,6 +42,8 @@ class SPreWorkCand { // outputs MapleSet restoreAtEntryBBs; // Id's of BBs to insert restores of the register at BB entry MapleSet restoreAtExitBBs; // Id's of BBs to insert restores of the register at BB exit + bool restoreAtEpilog = false; // if true, no shrinkwrapping can be done and + // the other outputs can be ignored }; extern void DoRestorePlacementOpt(CGFunc *f, PostDomAnalysis *pdom, SPreWorkCand *workCand); diff --git a/src/mapleall/maple_be/src/cg/cg_ssu_pre.cpp b/src/mapleall/maple_be/src/cg/cg_ssu_pre.cpp index 5e5f5da591776153a38449f2a92b66989ee4c89d..32b910ab5c184632af48f06db033c6e1a2e51af9 100644 --- a/src/mapleall/maple_be/src/cg/cg_ssu_pre.cpp +++ b/src/mapleall/maple_be/src/cg/cg_ssu_pre.cpp @@ -87,7 +87,8 @@ void SSUPre::Finalize() { !static_cast(lambdaResOcc->use)->WillBeAnt())) { // insert a store if (lambdaResOcc->cgbb->GetPreds().size() != 1) { // critical edge - CHECK_FATAL(false, "SSUPre::Finalize: insertion at critical edge"); + workCand->restoreAtEpilog = true; + break; } lambdaResOcc->insertHere = true; } else { @@ -103,9 +104,16 @@ void SSUPre::Finalize() { ASSERT(false, "Finalize: unexpected occ type"); break; } + if (workCand->restoreAtEpilog) { + break; + } } if (enabledDebug) { LogInfo::MapleLogger() << " _______ after finalize _______" << '\n'; + if (workCand->restoreAtEpilog) { + LogInfo::MapleLogger() << "Giving up because of insertion at critical edge" << '\n'; + return; + } for (SOcc *occ : allOccs) { if (occ->occTy == kSOccReal) { SRealOcc *realOcc = static_cast(occ); @@ -535,8 +543,10 @@ void SSUPre::ApplySSUPre() { } // #5 Finalize Finalize(); - // #6 Code Motion - CodeMotion(); + if (!workCand->restoreAtEpilog) { + // #6 Code Motion + CodeMotion(); + } } void DoRestorePlacementOpt(CGFunc *f, PostDomAnalysis *pdom, SPreWorkCand *workCand) {