Skip to content

Commit af1daf2

Browse files
Sidorenko, Antonsys_zuul
authored andcommitted
Support -ftime-report for VC backend
Change-Id: I3c7ad21cf89857bf5ee5147ea2d6aea106f67ce2
1 parent 546d48d commit af1daf2

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

IGC/VectorCompiler/include/vc/GenXCodeGen/GenXWrapper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ struct CompileOptions {
157157
BinaryKind Binary = BinaryKind::OpenCL;
158158
bool DumpIsa = false;
159159
bool DumpIR = false;
160+
bool TimePasses = false;
160161
};
161162

162163
class ExternalData {

IGC/VectorCompiler/include/vc/Support/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,8 @@ def runtime : Separate<["-"], "runtime">, Alias<binary_format>,
141141
def runtime_eq : Joined<["-"], "runtime=">,
142142
Alias<binary_format>, HelpText<"Alias for -runtime <value>">;
143143

144+
def ftime_report : Flag<["-"], "ftime-report">,
145+
HelpText<"Print timing summary of each stage of compilation">;
146+
144147
}
145148
// }} Internal options

IGC/VectorCompiler/lib/GenXCodeGen/GenXWrapper.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
6767
#include "llvm/Support/StringSaver.h"
6868
#include "llvm/Support/TargetRegistry.h"
6969
#include "llvm/Support/TargetSelect.h"
70+
#include "llvm/Support/Timer.h"
7071
#include "llvm/Support/raw_ostream.h"
7172
#include "llvm/Target/TargetOptions.h"
7273
#include "llvm/Transforms/IPO.h"
@@ -545,6 +546,11 @@ Expected<vc::CompileOutput> vc::Compile(ArrayRef<char> Input,
545546
TargetMachine &TM = *ExpTargetMachine.get();
546547
M.setDataLayout(TM.createDataLayout());
547548

549+
// Save old value and restore at the end.
550+
bool TimePassesIsEnabledLocal = TimePassesIsEnabled;
551+
if (Opts.TimePasses)
552+
TimePassesIsEnabled = true;
553+
548554
if (Opts.DumpIR)
549555
dumpModuleToTemp(M, "start.ll");
550556

@@ -553,7 +559,13 @@ Expected<vc::CompileOutput> vc::Compile(ArrayRef<char> Input,
553559
if (Opts.DumpIR)
554560
dumpModuleToTemp(M, "optimized.ll");
555561

556-
return runCodeGen(Opts, ExtData, TM, M);
562+
vc::CompileOutput Output = runCodeGen(Opts, ExtData, TM, M);
563+
564+
// Print timers if any and restore old TimePassesIsEnabled value.
565+
TimerGroup::printAll(llvm::errs());
566+
TimePassesIsEnabled = TimePassesIsEnabledLocal;
567+
568+
return Output;
557569
}
558570

559571
static Expected<opt::InputArgList>
@@ -658,6 +670,8 @@ static Error fillInternalOptions(const opt::ArgList &InternalOptions,
658670
Opts.DumpIsa = true;
659671
if (InternalOptions.hasArg(vc::options::OPT_dump_llvm_ir))
660672
Opts.DumpIR = true;
673+
if (InternalOptions.hasArg(vc::options::OPT_ftime_report))
674+
Opts.TimePasses = true;
661675

662676
if (opt::Arg *A =
663677
InternalOptions.getLastArg(vc::options::OPT_binary_format)) {

0 commit comments

Comments
 (0)