radv: dont store disasm string unless keep_shader_info flag set
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 17 Jul 2019 04:20:55 +0000 (14:20 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Thu, 18 Jul 2019 00:25:55 +0000 (00:25 +0000)
This fixes the memory use regression from bug 111107.

Fixes: 726a31df705 ("radv: Add the concept of radv shader binaries.")
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111107

src/amd/vulkan/radv_shader.c

index bcc050a86ccd04036b8cfc1d96180480dc14ec1d..ffbef6857b9aede8fdbf423c03f7d0d74870f70e 100644 (file)
@@ -1011,18 +1011,20 @@ radv_shader_variant_create(struct radv_device *device,
                        return NULL;
                }
 
-               const char *disasm_data;
-               size_t disasm_size;
-               if (!ac_rtld_get_section_by_name(&rtld_binary, ".AMDGPU.disasm", &disasm_data, &disasm_size)) {
-                       radv_shader_variant_destroy(device, variant);
-                       ac_rtld_close(&rtld_binary);
-                       return NULL;
-               }
+               if (device->keep_shader_info) {
+                       const char *disasm_data;
+                       size_t disasm_size;
+                       if (!ac_rtld_get_section_by_name(&rtld_binary, ".AMDGPU.disasm", &disasm_data, &disasm_size)) {
+                               radv_shader_variant_destroy(device, variant);
+                               ac_rtld_close(&rtld_binary);
+                               return NULL;
+                       }
 
-               variant->llvm_ir_string = bin->llvm_ir_size ? strdup((const char*)(bin->data + bin->elf_size)) : NULL;
-               variant->disasm_string = malloc(disasm_size + 1);
-               memcpy(variant->disasm_string, disasm_data, disasm_size);
-               variant->disasm_string[disasm_size] = 0;
+                       variant->llvm_ir_string = bin->llvm_ir_size ? strdup((const char*)(bin->data + bin->elf_size)) : NULL;
+                       variant->disasm_string = malloc(disasm_size + 1);
+                       memcpy(variant->disasm_string, disasm_data, disasm_size);
+                       variant->disasm_string[disasm_size] = 0;
+               }
 
                ac_rtld_close(&rtld_binary);
        } else {