mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[NewPM][PassInstrument] Make PrintIR and TimePasses to use before-pass-run callback
Reviewed By: asbirlea, aeubanks Differential Revision: https://reviews.llvm.org/D84773
This commit is contained in:
parent
53414ad22f
commit
4fad307f88
@ -100,7 +100,7 @@ private:
|
||||
void stopTimer(StringRef PassID);
|
||||
|
||||
// Implementation of pass instrumentation callbacks.
|
||||
bool runBeforePass(StringRef PassID);
|
||||
void runBeforePass(StringRef PassID);
|
||||
void runAfterPass(StringRef PassID);
|
||||
};
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
void registerCallbacks(PassInstrumentationCallbacks &PIC);
|
||||
|
||||
private:
|
||||
bool printBeforePass(StringRef PassID, Any IR);
|
||||
void printBeforePass(StringRef PassID, Any IR);
|
||||
void printAfterPass(StringRef PassID, Any IR);
|
||||
void printAfterPassInvalidated(StringRef PassID);
|
||||
|
||||
|
@ -240,17 +240,14 @@ static bool matchPassManager(StringRef PassID) {
|
||||
Prefix.endswith("AnalysisManagerProxy");
|
||||
}
|
||||
|
||||
bool TimePassesHandler::runBeforePass(StringRef PassID) {
|
||||
void TimePassesHandler::runBeforePass(StringRef PassID) {
|
||||
if (matchPassManager(PassID))
|
||||
return true;
|
||||
return;
|
||||
|
||||
startTimer(PassID);
|
||||
|
||||
LLVM_DEBUG(dbgs() << "after runBeforePass(" << PassID << ")\n");
|
||||
LLVM_DEBUG(dump());
|
||||
|
||||
// we are not going to skip this pass, thus return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
void TimePassesHandler::runAfterPass(StringRef PassID) {
|
||||
@ -267,8 +264,8 @@ void TimePassesHandler::registerCallbacks(PassInstrumentationCallbacks &PIC) {
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
PIC.registerBeforePassCallback(
|
||||
[this](StringRef P, Any) { return this->runBeforePass(P); });
|
||||
PIC.registerBeforeNonSkippedPassCallback(
|
||||
[this](StringRef P, Any) { this->runBeforePass(P); });
|
||||
PIC.registerAfterPassCallback(
|
||||
[this](StringRef P, Any) { this->runAfterPass(P); });
|
||||
PIC.registerAfterPassInvalidatedCallback(
|
||||
|
@ -180,9 +180,9 @@ PrintIRInstrumentation::popModuleDesc(StringRef PassID) {
|
||||
return ModuleDesc;
|
||||
}
|
||||
|
||||
bool PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
|
||||
void PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
|
||||
if (PassID.startswith("PassManager<") || PassID.contains("PassAdaptor<"))
|
||||
return true;
|
||||
return;
|
||||
|
||||
// Saving Module for AfterPassInvalidated operations.
|
||||
// Note: here we rely on a fact that we do not change modules while
|
||||
@ -192,11 +192,11 @@ bool PrintIRInstrumentation::printBeforePass(StringRef PassID, Any IR) {
|
||||
pushModuleDesc(PassID, IR);
|
||||
|
||||
if (!llvm::shouldPrintBeforePass(PassID))
|
||||
return true;
|
||||
return;
|
||||
|
||||
SmallString<20> Banner = formatv("*** IR Dump Before {0} ***", PassID);
|
||||
unwrapAndPrint(IR, Banner, llvm::forcePrintModuleIR());
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
void PrintIRInstrumentation::printAfterPass(StringRef PassID, Any IR) {
|
||||
@ -240,8 +240,8 @@ void PrintIRInstrumentation::registerCallbacks(
|
||||
// for later use in AfterPassInvalidated.
|
||||
StoreModuleDesc = llvm::forcePrintModuleIR() && llvm::shouldPrintAfterPass();
|
||||
if (llvm::shouldPrintBeforePass() || StoreModuleDesc)
|
||||
PIC.registerBeforePassCallback(
|
||||
[this](StringRef P, Any IR) { return this->printBeforePass(P, IR); });
|
||||
PIC.registerBeforeNonSkippedPassCallback(
|
||||
[this](StringRef P, Any IR) { this->printBeforePass(P, IR); });
|
||||
|
||||
if (llvm::shouldPrintAfterPass()) {
|
||||
PIC.registerAfterPassCallback(
|
||||
|
Loading…
Reference in New Issue
Block a user