Skip to content

Commit 3a1046b

Browse files
author
Tarun Prabhu
committed
Address reviewer comments. Remove code specific to -ftime-report= since that
is not supported right now anyway. Add checks that will only print out timing streams if there is anything in them to avoid empty lines.
1 parent fdf3934 commit 3a1046b

File tree

5 files changed

+14
-45
lines changed

5 files changed

+14
-45
lines changed

flang/include/flang/Frontend/CompilerInstance.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ class CompilerInstance {
279279
/// {
280280
/// @name Timing
281281
/// @{
282-
bool isTimingEnabled() { return timingMgr.isEnabled(); }
283282
bool isTimingEnabled() const { return timingMgr.isEnabled(); }
284283

285284
mlir::DefaultTimingManager &getTimingManager() { return timingMgr; }

flang/include/flang/Frontend/CompilerInvocation.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,6 @@ class CompilerInvocation : public CompilerInvocationBase {
148148
/// is enabled.
149149
bool enableTimers;
150150

151-
/// Whether to report the timing of each run of an LLVM pass. Set when
152-
/// -ftime-report=per-pass-run is enabled.
153-
bool timeLLVMPassesPerRun;
154-
155151
public:
156152
CompilerInvocation() = default;
157153

@@ -234,9 +230,6 @@ class CompilerInvocation : public CompilerInvocationBase {
234230
bool getEnableTimers() { return enableTimers; }
235231
bool getEnableTimers() const { return enableTimers; }
236232

237-
bool getTimeLLVMPassesPerRun() { return timeLLVMPassesPerRun; }
238-
bool getTimeLLVMPassesPerRun() const { return timeLLVMPassesPerRun; }
239-
240233
/// Create a compiler invocation from a list of input options.
241234
/// \returns true on success.
242235
/// \returns false if an error was encountered while parsing the arguments

flang/lib/Frontend/CompilerInstance.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ bool CompilerInstance::executeAction(FrontendAction &act) {
178178
// Once the root cause of this is determined, we should enable this to have
179179
// behavior that is comparable to clang.
180180
// llvm::TimePassesIsEnabled = true;
181-
// llvm::TimePassesPerRun = invoc.getTimeLLVMPassesPerRun();
182181

183182
timingStreamMLIR = std::make_unique<Fortran::support::string_ostream>();
184183
timingStreamLLVM = std::make_unique<Fortran::support::string_ostream>();
@@ -218,11 +217,19 @@ bool CompilerInstance::executeAction(FrontendAction &act) {
218217
timingMgr.setOutput(
219218
Fortran::support::createTimingFormatterText(mlir::thread_safe_nulls()));
220219

221-
// This is deliberately done in "reverse" order and does not match the
222-
// behavior of clang.
223-
llvm::errs() << timingStreamCodeGen->str() << "\n";
224-
llvm::errs() << timingStreamLLVM->str() << "\n";
225-
llvm::errs() << timingStreamMLIR->str() << "\n";
220+
// This prints the timings in "reverse" order, starting from code
221+
// generation, followed by LLVM-IR optimizations, then MLIR optimizations
222+
// and transformations and the frontend. If any of the steps are disabled,
223+
// for instance because code generation was not performed, the strings
224+
// will be empty.
225+
if (!timingStreamCodeGen->str().empty())
226+
llvm::errs() << timingStreamCodeGen->str() << "\n";
227+
228+
if (!timingStreamLLVM->str().empty())
229+
llvm::errs() << timingStreamLLVM->str() << "\n";
230+
231+
if (!timingStreamMLIR->str().empty())
232+
llvm::errs() << timingStreamMLIR->str() << "\n";
226233
}
227234

228235
return !getDiagnostics().getClient()->getNumErrors();

flang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,20 +1360,8 @@ bool CompilerInvocation::createFromArgs(
13601360

13611361
// Process the timing-related options.
13621362
if (const llvm::opt::Arg *a =
1363-
args.getLastArg(clang::driver::options::OPT_ftime_report,
1364-
clang::driver::options::OPT_ftime_report_EQ)) {
1363+
args.getLastArg(clang::driver::options::OPT_ftime_report)) {
13651364
invoc.enableTimers = true;
1366-
if (a->getOption().getID() == clang::driver::options::OPT_ftime_report_EQ) {
1367-
llvm::StringRef val = a->getValue();
1368-
if (val == "per-pass") {
1369-
invoc.timeLLVMPassesPerRun = false;
1370-
} else if (val == "per-pass-run") {
1371-
invoc.timeLLVMPassesPerRun = true;
1372-
} else {
1373-
diags.Report(clang::diag::err_drv_invalid_value)
1374-
<< a->getAsString(args) << a->getValue();
1375-
}
1376-
}
13771365
}
13781366

13791367
invoc.setArgv0(argv0);

flang/test/Driver/time-report-eq.f90

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)