diff options
| -rw-r--r-- | docs/command-line-slangc-reference.md | 5 | ||||
| -rw-r--r-- | slang.h | 2 | ||||
| -rwxr-xr-x | source/slang/slang-compiler.h | 3 | ||||
| -rw-r--r-- | source/slang/slang-diagnostic-defs.h | 2 | ||||
| -rw-r--r-- | source/slang/slang-options.cpp | 9 | ||||
| -rw-r--r-- | source/slang/slang.cpp | 19 |
6 files changed, 36 insertions, 4 deletions
diff --git a/docs/command-line-slangc-reference.md b/docs/command-line-slangc-reference.md index 7a16b380f..777d586d1 100644 --- a/docs/command-line-slangc-reference.md +++ b/docs/command-line-slangc-reference.md @@ -232,6 +232,11 @@ Dump to output list of warning diagnostic numeric and name ids. Treat the rest of the command line as input files. +<a id="report-downstream-time"></a> +## -report-downstream-time +Reports the time spent in the downstream compiler. + + <a id="Target"></a> # Target @@ -4125,6 +4125,8 @@ namespace slang virtual SLANG_NO_THROW void SLANG_MCALL setEnableEffectAnnotations(bool value) = 0; + virtual SLANG_NO_THROW void SLANG_MCALL setReportDownstreamTime(bool value) = 0; + }; #define SLANG_UUID_ICompileRequest ICompileRequest::getTypeGuid() diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 42fc3ca1f..1386b37e8 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -2637,7 +2637,7 @@ namespace Slang virtual SLANG_NO_THROW SlangDiagnosticFlags SLANG_MCALL getDiagnosticFlags() SLANG_OVERRIDE; virtual SLANG_NO_THROW void SLANG_MCALL setDiagnosticFlags(SlangDiagnosticFlags flags) SLANG_OVERRIDE; virtual SLANG_NO_THROW void SLANG_MCALL setDebugInfoFormat(SlangDebugInfoFormat format) SLANG_OVERRIDE; - + virtual SLANG_NO_THROW void SLANG_MCALL setReportDownstreamTime(bool value) SLANG_OVERRIDE; void setHLSLToVulkanLayoutOptions(int targetIndex, HLSLToVulkanLayoutOptions* vulkanLayoutOptions); EndToEndCompileRequest( @@ -2675,6 +2675,7 @@ namespace Slang // Are we being driven by the command-line `slangc`, and should act accordingly? bool m_isCommandLineCompile = false; + bool m_reportDownstreamCompileTime = false; String m_diagnosticOutput; diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 723dc4d64..d4bb63f52 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -138,7 +138,7 @@ DIAGNOSTIC( 99, Error, unknownDebugOption, "unknown debug option, known optio DIAGNOSTIC( 100, Error, failedToLoadDownstreamCompiler, "failed to load downstream compiler '$0'") DIAGNOSTIC( 101, Error, downstreamCompilerDoesntSupportWholeProgramCompilation, "downstream compiler '$0' doesn't support whole program compilation") - +DIAGNOSTIC( 102, Note, downstreamCompileTime, "downstream compile time: $0s") DIAGNOSTIC(99999, Note, noteFailedToLoadDynamicLibrary, "failed to load dynamic library '$0'") diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index cb04632cc..f69e0ec3a 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -70,6 +70,7 @@ enum class OptionKind DumpWarningDiagnostics, InputFilesRemain, EmitIr, + ReportDownstreamTime, // Target @@ -413,7 +414,8 @@ void initCommandOptions(CommandOptions& options) { OptionKind::EnableWarning, "-W...", "-W<id>", "Enable a warning with the specified id."}, { OptionKind::DisableWarning, "-Wno-...", "-Wno-<id>", "Disable warning with <id>"}, { OptionKind::DumpWarningDiagnostics, "-dump-warning-diagnostics", nullptr, "Dump to output list of warning diagnostic numeric and name ids." }, - { OptionKind::InputFilesRemain, "--", nullptr, "Treat the rest of the command line as input files."} + { OptionKind::InputFilesRemain, "--", nullptr, "Treat the rest of the command line as input files."}, + { OptionKind::ReportDownstreamTime, "-report-downstream-time", nullptr, "Reports the time spent in the downstream compiler." }, }; _addOptions(makeConstArrayView(generalOpts), options); @@ -1838,6 +1840,11 @@ SlangResult OptionsParser::_parse( } break; } + case OptionKind::ReportDownstreamTime: + { + m_compileRequest->setReportDownstreamTime(true); + break; + } case OptionKind::ModuleName: { CommandLineArg moduleName; diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index f2598786f..ead1e338f 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -4806,6 +4806,11 @@ void EndToEndCompileRequest::setPassThrough(SlangPassThrough inPassThrough) m_passThrough = PassThroughMode(inPassThrough); } +void EndToEndCompileRequest::setReportDownstreamTime(bool value) +{ + m_reportDownstreamCompileTime = value; +} + void EndToEndCompileRequest::setDiagnosticCallback(SlangDiagnosticCallback callback, void const* userData) { ComPtr<ISlangWriter> writer(new CallbackWriter(callback, userData, WriterFlag::IsConsole)); @@ -5112,7 +5117,11 @@ SlangResult EndToEndCompileRequest::setTypeNameForEntryPointExistentialTypeParam SlangResult EndToEndCompileRequest::EndToEndCompileRequest::compile() { SlangResult res = SLANG_FAIL; - + double downstreamStartTime = 0.0; + if (m_reportDownstreamCompileTime) + { + downstreamStartTime = getSession()->getDownstreamCompilerElapsedTime(); + } #if !defined(SLANG_DEBUG_INTERNAL_ERROR) // By default we'd like to catch as many internal errors as possible, // and report them to the user nicely (rather than just crash their @@ -5160,6 +5169,14 @@ SlangResult EndToEndCompileRequest::EndToEndCompileRequest::compile() } #endif + if (m_reportDownstreamCompileTime) + { + double downstreamTime = getSession()->getDownstreamCompilerElapsedTime() - downstreamStartTime; + String downstreamTimeStr = String(downstreamTime, "%.2f"); + getSink()->diagnose(SourceLoc(), Diagnostics::downstreamCompileTime, downstreamTimeStr); + + } + // Repro dump handling { if (m_dumpRepro.getLength()) |
