diff options
-rw-r--r-- | src/amd/compiler/aco_interface.cpp | 7 | ||||
-rw-r--r-- | src/amd/compiler/aco_ir.h | 2 | ||||
-rw-r--r-- | src/amd/compiler/aco_print_asm.cpp | 20 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 27a072ce6bb..4e748cc9010 100644 --- a/src/amd/compiler/aco_interface.cpp +++ b/src/amd/compiler/aco_interface.cpp @@ -172,7 +172,12 @@ void aco_compile_shader(unsigned shader_count, std::string disasm; if (get_disasm) { std::ostringstream stream; - aco::print_asm(program.get(), code, exec_size / 4u, stream); + if (aco::print_asm(program.get(), code, exec_size / 4u, stream)) { + std::cerr << "Failed to disassemble program:\n"; + aco_print_program(program.get(), stderr); + std::cerr << stream.str() << std::endl; + abort(); + } stream << '\0'; disasm = stream.str(); size += disasm.size(); diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index ade74356454..7aa109ce02b 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1693,7 +1693,7 @@ void spill(Program* program, live& live_vars, const struct radv_nir_compiler_opt void insert_wait_states(Program* program); void insert_NOPs(Program* program); unsigned emit_program(Program* program, std::vector<uint32_t>& code); -void print_asm(Program *program, std::vector<uint32_t>& binary, +bool print_asm(Program *program, std::vector<uint32_t>& binary, unsigned exec_size, std::ostream& out); bool validate_ir(Program* program); bool validate_ra(Program* program, const struct radv_nir_compiler_options *options); diff --git a/src/amd/compiler/aco_print_asm.cpp b/src/amd/compiler/aco_print_asm.cpp index 1e818147f1b..3f10a3638ce 100644 --- a/src/amd/compiler/aco_print_asm.cpp +++ b/src/amd/compiler/aco_print_asm.cpp @@ -14,7 +14,7 @@ namespace aco { /* LLVM disassembler only supports GFX8+, try to disassemble with CLRXdisasm * for GFX6-GFX7 if found on the system, this is better than nothing. */ -void print_asm_gfx6_gfx7(Program *program, std::vector<uint32_t>& binary, +bool print_asm_gfx6_gfx7(Program *program, std::vector<uint32_t>& binary, std::ostream& out) { char path[] = "/tmp/fileXXXXXX"; @@ -26,7 +26,7 @@ void print_asm_gfx6_gfx7(Program *program, std::vector<uint32_t>& binary, /* Dump the binary into a temporary file. */ fd = mkstemp(path); if (fd < 0) - return; + return true; for (uint32_t w : binary) { @@ -83,17 +83,21 @@ void print_asm_gfx6_gfx7(Program *program, std::vector<uint32_t>& binary, pclose(p); } + return false; + fail: close(fd); unlink(path); + return true; } -void print_asm(Program *program, std::vector<uint32_t>& binary, +bool print_asm(Program *program, std::vector<uint32_t>& binary, unsigned exec_size, std::ostream& out) { if (program->chip_class <= GFX7) { + /* Do not abort if clrxdisasm isn't found. */ print_asm_gfx6_gfx7(program, binary, out); - return; + return false; } std::vector<bool> referenced_blocks(program->blocks.size()); @@ -224,13 +228,7 @@ void print_asm(Program *program, std::vector<uint32_t>& binary, out << std::setfill(' ') << std::setw(0) << std::dec; - if (invalid) { - /* Invalid instructions usually lead to GPU hangs, which can make - * getting the actual invalid instruction hard. Abort here so that we - * can find the problem. - */ - abort(); - } + return invalid; } } |