diff options
author | Rhys Perry <[email protected]> | 2019-09-24 15:23:46 +0100 |
---|---|---|
committer | Rhys Perry <[email protected]> | 2019-09-26 11:08:31 +0100 |
commit | 15ea1c5cff1dad6b8cf065774aaf3b41aa36de69 (patch) | |
tree | 44e4bf5461c103839bc858b2872028f89806fb28 | |
parent | 6613b813278bd8f31b777a33a945fd1ce86ede46 (diff) |
aco: store printed backend IR in binary
Signed-off-by: Rhys Perry <[email protected]>
Reviewed-by: Daniel Schürmann <[email protected]>
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
-rw-r--r-- | src/amd/compiler/aco_interface.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp index 5a6556f8fad..2a1986357ca 100644 --- a/src/amd/compiler/aco_interface.cpp +++ b/src/amd/compiler/aco_interface.cpp @@ -95,6 +95,21 @@ void aco_compile_shader(unsigned shader_count, //aco_print_program(program.get(), stderr); aco::schedule_program(program.get(), live_vars); + std::string llvm_ir; + if (options->record_llvm_ir) { + char *data = NULL; + size_t size = 0; + FILE *f = open_memstream(&data, &size); + if (f) { + aco_print_program(program.get(), f); + fputc(0, f); + fclose(f); + } + + llvm_ir = std::string(data, data + size); + free(data); + } + /* Register Allocation */ aco::register_allocation(program.get(), live_vars.live_out); if (options->dump_shader) { @@ -127,7 +142,7 @@ void aco_compile_shader(unsigned shader_count, bool get_disasm = options->dump_shader || options->record_llvm_ir; - size_t size = 0; + size_t size = llvm_ir.size(); std::string disasm; if (get_disasm) { @@ -152,11 +167,13 @@ void aco_compile_shader(unsigned shader_count, legacy_binary->config = config; legacy_binary->disasm_size = 0; - legacy_binary->llvm_ir_size = 0; + legacy_binary->llvm_ir_size = llvm_ir.size(); + + llvm_ir.copy((char*) legacy_binary->data + legacy_binary->code_size, llvm_ir.size()); if (get_disasm) { - disasm.copy((char*) legacy_binary->data + legacy_binary->code_size, disasm.size()); - legacy_binary->disasm_size = disasm.size() - 1; + disasm.copy((char*) legacy_binary->data + legacy_binary->code_size + llvm_ir.size(), disasm.size()); + legacy_binary->disasm_size = disasm.size(); } *binary = (radv_shader_binary*) legacy_binary; |