diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-12-07 13:15:23 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-07 13:15:23 -0500 |
| commit | 8b3df74758c536db9535903158242dd2350e5265 (patch) | |
| tree | 98258066e11153d747448d68785bbb5be251d448 /source | |
| parent | 9e666a332aafeffdc15ceab6017fe377144a928b (diff) | |
Output of IR ids as command line option (#2043)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP control of dump options.
* Removed SourceManager for IRDumpOptions
* Arm aarch64 debug connection timeout - as CI timed out.
Diffstat (limited to 'source')
| -rwxr-xr-x | source/slang/slang-compiler.h | 6 | ||||
| -rw-r--r-- | source/slang/slang-emit.cpp | 5 | ||||
| -rw-r--r-- | source/slang/slang-ir.cpp | 30 | ||||
| -rw-r--r-- | source/slang/slang-ir.h | 18 | ||||
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 5 | ||||
| -rw-r--r-- | source/slang/slang-options.cpp | 5 |
6 files changed, 39 insertions, 30 deletions
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 9677c4fbe..52c03ffdb 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -1855,6 +1855,9 @@ namespace Slang Name* m_defaultModuleName = nullptr; + /// The irDumpOptions + IRDumpOptions m_irDumpOptions; + /// An "extra" entry point that was added via a library reference struct ExtraEntryPointInfo { @@ -2043,6 +2046,9 @@ namespace Slang // If true will disable generating dynamic dispatch code. bool disableDynamicDispatch = false; + // The default IR dumping options + IRDumpOptions m_irDumpOptions; + String m_dumpIntermediatePrefix; private: diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 951e6fad5..335e7f7d9 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -144,10 +144,7 @@ static void dumpIRIfEnabled( //FILE* f = nullptr; //fopen_s(&f, (String("dump-") + label + ".txt").getBuffer(), "wt"); //FileWriter writer(f, 0); - IRDumpOptions options; - options.sourceManager = compileRequest->getSourceManager(); - - dumpIR(irModule, options, label, &writer); + dumpIR(irModule, compileRequest->m_irDumpOptions, label, compileRequest->getSourceManager(), &writer); //fclose(f); } } diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 601ebca26..81b554c3b 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -4360,6 +4360,7 @@ namespace Slang int indent = 0; IRDumpOptions options; + SourceManager* sourceManager; PathInfo lastPathInfo = PathInfo::makeUnknown(); Dictionary<IRInst*, String> mapValueToName; @@ -4555,9 +4556,12 @@ namespace Slang static void dumpDebugID(IRDumpContext* context, IRInst* inst) { #if SLANG_ENABLE_IR_BREAK_ALLOC - dump(context, "[#"); - dump(context, String(inst->_debugUID)); - dump(context, "]"); + if (context->options.flags & IRDumpOptions::Flag::DumpDebugIds) + { + dump(context, "[#"); + dump(context, String(inst->_debugUID)); + dump(context, "]"); + } #else SLANG_UNUSED(context); SLANG_UNUSED(inst); @@ -5115,7 +5119,7 @@ namespace Slang // Output the originating source location { - SourceManager* sourceManager = context->options.sourceManager; + SourceManager* sourceManager = context->sourceManager; if (sourceManager && context->options.flags & IRDumpOptions::Flag::SourceLocations) { StringBuilder buf; @@ -5168,17 +5172,18 @@ namespace Slang } } - void printSlangIRAssembly(StringBuilder& builder, IRModule* module, const IRDumpOptions& options) + void printSlangIRAssembly(StringBuilder& builder, IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager) { IRDumpContext context; context.builder = &builder; context.indent = 0; context.options = options; + context.sourceManager = sourceManager; dumpIRModule(&context, module); } - void dumpIR(IRInst* globalVal, const IRDumpOptions& options, ISlangWriter* writer) + void dumpIR(IRInst* globalVal, const IRDumpOptions& options, SourceManager* sourceManager, ISlangWriter* writer) { StringBuilder sb; @@ -5186,6 +5191,7 @@ namespace Slang context.builder = &sb; context.indent = 0; context.options = options; + context.sourceManager = sourceManager; dumpInst(&context, globalVal); @@ -5193,7 +5199,7 @@ namespace Slang writer->flush(); } - void dumpIR(IRModule* module, const IRDumpOptions& options, char const* label, ISlangWriter* inWriter) + void dumpIR(IRModule* module, const IRDumpOptions& options, char const* label, SourceManager* sourceManager, ISlangWriter* inWriter) { WriterHelper writer(inWriter); @@ -5204,7 +5210,7 @@ namespace Slang writer.put(":\n"); } - dumpIR(module, options, inWriter); + dumpIR(module, options, sourceManager, inWriter); if (label) { @@ -5212,16 +5218,16 @@ namespace Slang } } - String getSlangIRAssembly(IRModule* module, const IRDumpOptions& options) + String getSlangIRAssembly(IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager) { StringBuilder sb; - printSlangIRAssembly(sb, module, options); + printSlangIRAssembly(sb, module, options, sourceManager); return sb; } - void dumpIR(IRModule* module, const IRDumpOptions& options, ISlangWriter* writer) + void dumpIR(IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager, ISlangWriter* writer) { - String ir = getSlangIRAssembly(module, options); + String ir = getSlangIRAssembly(module, options, sourceManager); writer->write(ir.getBuffer(), ir.getLength()); writer->flush(); } diff --git a/source/slang/slang-ir.h b/source/slang/slang-ir.h index 7542a883a..6006ce64c 100644 --- a/source/slang/slang-ir.h +++ b/source/slang/slang-ir.h @@ -1500,7 +1500,8 @@ struct IRDumpOptions { enum Enum : Flags { - SourceLocations = 0x1, ///< If set will output source locations + SourceLocations = 0x1, ///< If set will output source locations + DumpDebugIds = 0x2, ///< If set *and* debug build will write ids }; }; @@ -1532,18 +1533,15 @@ struct IRDumpOptions Mode mode = Mode::Simplified; /// Flags to control output /// Add Flag::SourceLocations to output source locations set on IR - Flags flags = 0; - - /// Must be set if source location output is desired - SourceManager* sourceManager = nullptr; + Flags flags = 0; }; -void printSlangIRAssembly(StringBuilder& builder, IRModule* module, const IRDumpOptions& options); -String getSlangIRAssembly(IRModule* module, const IRDumpOptions& options); +void printSlangIRAssembly(StringBuilder& builder, IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager); +String getSlangIRAssembly(IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager); -void dumpIR(IRModule* module, const IRDumpOptions& options, ISlangWriter* writer); -void dumpIR(IRInst* globalVal, const IRDumpOptions& options, ISlangWriter* writer); -void dumpIR(IRModule* module, const IRDumpOptions& options, char const* label, ISlangWriter* writer); +void dumpIR(IRModule* module, const IRDumpOptions& options, SourceManager* sourceManager, ISlangWriter* writer); +void dumpIR(IRInst* globalVal, const IRDumpOptions& options, SourceManager* sourceManager, ISlangWriter* writer); +void dumpIR(IRModule* module, const IRDumpOptions& options, char const* label, SourceManager* sourceManager, ISlangWriter* writer); IRInst* createEmptyInst( IRModule* module, diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 2c63520b6..3d686304a 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -8147,10 +8147,7 @@ IRModule* generateIRForTranslationUnit( { DiagnosticSinkWriter writer(compileRequest->getSink()); - IRDumpOptions options; - options.sourceManager = compileRequest->getSourceManager(); - - dumpIR(module, options, "LOWER-TO-IR", &writer); + dumpIR(module, compileRequest->m_irDumpOptions, "LOWER-TO-IR", compileRequest->getSourceManager(), &writer); } return module; diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index 8f5c75efa..07f474c78 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -624,6 +624,11 @@ struct OptionsParser { compileRequest->setDumpIntermediates(true); } + else if (argValue == "-dump-ir-ids") + { + requestImpl->getFrontEndReq()->m_irDumpOptions.flags |= IRDumpOptions::Flag::DumpDebugIds; + requestImpl->getBackEndReq()->m_irDumpOptions.flags |= IRDumpOptions::Flag::DumpDebugIds; + } else if (argValue == "-dump-intermediate-prefix") { CommandLineArg prefix; |
