mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-25 13:00:04 +00:00
Improvements to disassembly within PassManager (#4677)
* PassManager: Print errors occurring during disassembly Otherwise one could be greeted by the following text when running spirv-opt withe the `--print-all` flag: ; IR before pass wrap-opkill ; IR before pass eliminate-dead-branches ; IR before pass merge-return With this commit, one will instead get: error: line 143: Invalid opcode: 400 warning: line 0: Disassembly failed before pass wrap-opkill error: line 143: Invalid opcode: 400 warning: line 0: Disassembly failed before pass eliminate-dead-branches error: line 143: Invalid opcode: 400 warning: line 0: Disassembly failed before pass merge-return * PassManager: Use the right target environment when disassembling Disassembly would fail if features from a newer version of SPIR-V than 1.2 were used.
This commit is contained in:
parent
b9e0e13d19
commit
05c839ca01
@ -35,10 +35,18 @@ Pass::Status PassManager::Run(IRContext* context) {
|
||||
if (print_all_stream_) {
|
||||
std::vector<uint32_t> binary;
|
||||
context->module()->ToBinary(&binary, false);
|
||||
SpirvTools t(SPV_ENV_UNIVERSAL_1_2);
|
||||
SpirvTools t(target_env_);
|
||||
t.SetMessageConsumer(consumer());
|
||||
std::string disassembly;
|
||||
t.Disassemble(binary, &disassembly, 0);
|
||||
*print_all_stream_ << preamble << (pass ? pass->name() : "") << "\n"
|
||||
std::string pass_name = (pass ? pass->name() : "");
|
||||
if (!t.Disassemble(binary, &disassembly, 0)) {
|
||||
std::string msg = "Disassembly failed before pass ";
|
||||
msg += pass_name + "\n";
|
||||
spv_position_t null_pos{0, 0, 0};
|
||||
consumer()(SPV_MSG_WARNING, "", null_pos, msg.c_str());
|
||||
return;
|
||||
}
|
||||
*print_all_stream_ << preamble << pass_name << "\n"
|
||||
<< disassembly << std::endl;
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user