[llvm] [llvm][Support] Enable pass timing in StandardInstrumentations constr… (PR #108983)
Tarun Prabhu via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 18:37:53 PDT 2024
https://github.com/tarunprabhu updated https://github.com/llvm/llvm-project/pull/108983
>From 33416d81bf28a5c3a1d16fc37ac83661e0ceabe5 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu <tarun.prabhu at gmail.com>
Date: Tue, 17 Sep 2024 08:30:38 -0600
Subject: [PATCH 1/3] [llvm][Support] Enable pass timing in
StandardInstrumentations constructor
Add two optional arguments to the llvm::StandardInstrumentations constructor
that enables pass timings and pass timings per run. If the optional arguments
are not provided, the TimePassesIsEnabled and TimePassesPerRun global variables
will be read when constructing the TimePassesHandler object which will preserve
the current behavior.
---
llvm/include/llvm/Passes/StandardInstrumentations.h | 4 +++-
llvm/lib/Passes/StandardInstrumentations.cpp | 5 ++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index fa9c744294a666..37d918eb30e5c7 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -601,7 +601,9 @@ class StandardInstrumentations {
public:
StandardInstrumentations(LLVMContext &Context, bool DebugLogging,
bool VerifyEach = false,
- PrintPassOptions PrintPassOpts = PrintPassOptions());
+ PrintPassOptions PrintPassOpts = PrintPassOptions(),
+ std::optional<bool> TimePasses = std::nullopt,
+ std::optional<bool> TimePassesPerRun = std::nullopt);
// Register all the standard instrumentation callbacks. If \p FAM is nullptr
// then PreservedCFGChecker is not enabled.
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 036484c9c1c0c4..44a0a2c03718b9 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -2442,8 +2442,11 @@ void DotCfgChangeReporter::registerCallbacks(
StandardInstrumentations::StandardInstrumentations(
LLVMContext &Context, bool DebugLogging, bool VerifyEach,
- PrintPassOptions PrintPassOpts)
+ PrintPassOptions PrintPassOpts, std::optional<bool> EnableTimePasses,
+ std::optional<bool> EnablePerRunTiming)
: PrintPass(DebugLogging, PrintPassOpts),
+ TimePasses(EnableTimePasses ? *EnableTimePasses : TimePassesIsEnabled,
+ EnablePerRunTiming ? *EnablePerRunTiming : TimePassesPerRun),
OptNone(DebugLogging),
OptPassGate(Context),
PrintChangedIR(PrintChanged == ChangePrinter::Verbose),
>From 9d470dc2371d75d9f8aa8fafccea2d30d1c0116e Mon Sep 17 00:00:00 2001
From: Tarun Prabhu <tarun.prabhu at gmail.com>
Date: Tue, 17 Sep 2024 10:07:24 -0600
Subject: [PATCH 2/3] Run clang-format
---
llvm/lib/Passes/StandardInstrumentations.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 44a0a2c03718b9..7730d10e965158 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -2447,8 +2447,7 @@ StandardInstrumentations::StandardInstrumentations(
: PrintPass(DebugLogging, PrintPassOpts),
TimePasses(EnableTimePasses ? *EnableTimePasses : TimePassesIsEnabled,
EnablePerRunTiming ? *EnablePerRunTiming : TimePassesPerRun),
- OptNone(DebugLogging),
- OptPassGate(Context),
+ OptNone(DebugLogging), OptPassGate(Context),
PrintChangedIR(PrintChanged == ChangePrinter::Verbose),
PrintChangedDiff(PrintChanged == ChangePrinter::DiffVerbose ||
PrintChanged == ChangePrinter::ColourDiffVerbose,
>From c6a38ad7682188e1e8ca20102bb14d4b91fee6a6 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu <tarun.prabhu at gmail.com>
Date: Wed, 18 Sep 2024 19:37:42 -0600
Subject: [PATCH 3/3] Replace optional arguments with ones that default to
false. Give priority to cl::opts that have been set.
---
llvm/include/llvm/Passes/StandardInstrumentations.h | 4 ++--
llvm/lib/Passes/StandardInstrumentations.cpp | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 37d918eb30e5c7..11b2b2951ff9aa 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -602,8 +602,8 @@ class StandardInstrumentations {
StandardInstrumentations(LLVMContext &Context, bool DebugLogging,
bool VerifyEach = false,
PrintPassOptions PrintPassOpts = PrintPassOptions(),
- std::optional<bool> TimePasses = std::nullopt,
- std::optional<bool> TimePassesPerRun = std::nullopt);
+ bool EnableTimePasses = false,
+ bool EnableTimePassesPerRun = false);
// Register all the standard instrumentation callbacks. If \p FAM is nullptr
// then PreservedCFGChecker is not enabled.
diff --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index 7730d10e965158..383301a131dc8c 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -2442,11 +2442,11 @@ void DotCfgChangeReporter::registerCallbacks(
StandardInstrumentations::StandardInstrumentations(
LLVMContext &Context, bool DebugLogging, bool VerifyEach,
- PrintPassOptions PrintPassOpts, std::optional<bool> EnableTimePasses,
- std::optional<bool> EnablePerRunTiming)
+ PrintPassOptions PrintPassOpts, bool EnableTimePasses,
+ bool EnableTimePassesPerRun)
: PrintPass(DebugLogging, PrintPassOpts),
- TimePasses(EnableTimePasses ? *EnableTimePasses : TimePassesIsEnabled,
- EnablePerRunTiming ? *EnablePerRunTiming : TimePassesPerRun),
+ TimePasses(TimePassesIsEnabled ? TimePassesIsEnabled : EnableTimePasses,
+ TimePassesPerRun ? TimePassesPerRun : EnableTimePassesPerRun),
OptNone(DebugLogging), OptPassGate(Context),
PrintChangedIR(PrintChanged == ChangePrinter::Verbose),
PrintChangedDiff(PrintChanged == ChangePrinter::DiffVerbose ||
More information about the llvm-commits
mailing list