[llvm] 7a2e112 - [NewPM][PassInstrument] Make PrintIR and TimePasses to use before-pass-run callback
Yuanfang Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 29 08:27:25 PDT 2020
Author: Yuanfang Chen
Date: 2020-07-29T08:26:36-07:00
New Revision: 7a2e1122ae4611916c920c815a4310085ed04830
URL: https://github.com/llvm/llvm-project/commit/7a2e1122ae4611916c920c815a4310085ed04830
DIFF: https://github.com/llvm/llvm-project/commit/7a2e1122ae4611916c920c815a4310085ed04830.diff
LOG: [NewPM][PassInstrument] Make PrintIR and TimePasses to use before-pass-run callback
Reviewed By: asbirlea, aeubanks
Differential Revision: https://reviews.llvm.org/D84773
Added:
Modified:
llvm/include/llvm/IR/PassTimingInfo.h
llvm/include/llvm/Passes/StandardInstrumentations.h
llvm/lib/IR/PassTimingInfo.cpp
llvm/lib/Passes/StandardInstrumentations.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/PassTimingInfo.h b/llvm/include/llvm/IR/PassTimingInfo.h
index a42d6aa3bede..a3608971217b 100644
--- a/llvm/include/llvm/IR/PassTimingInfo.h
+++ b/llvm/include/llvm/IR/PassTimingInfo.h
@@ -100,7 +100,7 @@ class TimePassesHandler {
void stopTimer(StringRef PassID);
// Implementation of pass instrumentation callbacks.
- bool runBeforePass(StringRef PassID);
+ void runBeforePass(StringRef PassID);
void runAfterPass(StringRef PassID);
};
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index bd8b886a2bb3..9c29bfc35941 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -39,7 +39,7 @@ class PrintIRInstrumentation {
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);
diff --git a/llvm/lib/IR/PassTimingInfo.cpp b/llvm/lib/IR/PassTimingInfo.cpp
index 829c3e8ea9ad..b3cb4ae60164 100644
--- a/llvm/lib/IR/PassTimingInfo.cpp
+++ b/llvm/lib/IR/PassTimingInfo.cpp
@@ -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(
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 22a7103715d5..2f802c9eee8a 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -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(
More information about the llvm-commits
mailing list