[llvm] [llvm][Support] Enable pass timing in StandardInstrumentations constr… (PR #108983)
Tarun Prabhu via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 17 09:07:36 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/2] [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/2] 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,
More information about the llvm-commits
mailing list