Skip to content

Help LLM track IR inst creation during debugging #7819

@csyonghe

Description

@csyonghe

We have the _slangIRAllocBreak mechanism to help developers break the compiler when a specific instruction is being created, so we can inspect the callstack and understand why the problematic instruction is being created.

This is a useful debugging tool, but it is not as easy for LLMs to use it.

We can introduce an environment variable, SLANG_DEBUG_IR_BREAK. During creation of Slang global session, we can read this environment variable and assign _slangIRAllocBreak to the value stored in the environment variable. We can then introduce another global variable, bool _slangIRPrintStackAtBreak = false;, and set it to true when the environment variable exists.

Then in uint32_t _debugGetAndIncreaseInstCounter() after line 1757, call backtrace() when on linux platform (#ifdef SLANG_LINUX_FAMILY). This will allow us to run slangc or slang-test with SLANG_DEBUG_IR_BREAK=xxx environment variable and then see the stack dump when an instruction with the specified UID is being created.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions