[PATCH] R600/SI: Embed disassembly in ELF object

Hi,

This patch adds R600/SI disassembly text to compiled object files, when a code dump is requested, to assist debugging in Mesa clients.

Here's an example of the output in a Mesa client with a corresponding patch and RADEON_DUMP_SHADERS set:

Shader Disassembly:

   S_WQM_B64 EXEC, EXEC ; BEFE0A7E
   S_MOV_B32 M0, SGPR6 ; BEFC0306
   V_INTERP_MOV_F32 VGPR0, P0, 3, 0, [M0] ; C8020302
   V_INTERP_MOV_F32 VGPR1, P0, 2, 0, [M0] ; C8060202
   V_INTERP_MOV_F32 VGPR2, P0, 1, 0, [M0] ; C80A0102
   V_INTERP_MOV_F32 VGPR3, P0, 0, 0, [M0] ; C80E0002
   EXP 15, 0, 0, 1, 1, VGPR3, VGPR2, VGPR1, VGPR0 ; F800180F 00010203
   S_ENDPGM ; BF810000

A less verbose disassembler is included in Mesa for pre-SI clients, so the patch does not embed disassembly for NI or earlier targets.

Disassembling during compilation is preferred, as it avoids the overhead of a second LLVM invocation. Further, the SILowerControlFlow pass modifies the input LLVM IR, which makes a second invocation for disassembly fail.

An example patch to Mesa to test functionality is available here: gist:6911363 · GitHub

llvm-r600-gcn-disassembly-in-elf.patch (6.19 KB)

Hi,

This patch adds R600/SI disassembly text to compiled object files, when
a code dump is requested, to assist debugging in Mesa clients.

Here's an example of the output in a Mesa client with a corresponding
patch and RADEON_DUMP_SHADERS set:

Shader Disassembly:

   S_WQM_B64 EXEC, EXEC ; BEFE0A7E
   S_MOV_B32 M0, SGPR6 ; BEFC0306
   V_INTERP_MOV_F32 VGPR0, P0, 3, 0, [M0] ; C8020302
   V_INTERP_MOV_F32 VGPR1, P0, 2, 0, [M0] ; C8060202
   V_INTERP_MOV_F32 VGPR2, P0, 1, 0, [M0] ; C80A0102
   V_INTERP_MOV_F32 VGPR3, P0, 0, 0, [M0] ; C80E0002
   EXP 15, 0, 0, 1, 1, VGPR3, VGPR2, VGPR1, VGPR0 ; F800180F 00010203
   S_ENDPGM ; BF810000

A less verbose disassembler is included in Mesa for pre-SI clients, so
the patch does not embed disassembly for NI or earlier targets.

Hi Jay,

Thanks for working on this. This patch looks good, but I think we
should enable it for all targets. Do you have commit access?

Disassembling during compilation is preferred, as it avoids the overhead
of a second LLVM invocation. Further, the SILowerControlFlow pass
modifies the input LLVM IR, which makes a second invocation for
disassembly fail.

An example patch to Mesa to test functionality is available here:
https://gist.github.com/anonymous/6911363

The Mesa patch looks good, have you sent it to mesa-dev?

-Tom

This patch adds R600/SI disassembly text to compiled object files, when
a code dump is requested, to assist debugging in Mesa clients.

Thanks for working on this. This patch looks good, but I think we
should enable it for all targets. Do you have commit access?

OK, I've enabled it for pre-SI and tested with Mesa. I don't have commit access. Would appreciate if you could push it for me.

An example patch to Mesa to test functionality is available here:
gist:6911363 · GitHub

The Mesa patch looks good, have you sent it to mesa-dev?

I've just sent a slightly improved version to mesa-dev, to remove the SI bytecode dump in Mesa when this disassembly is available.

Thanks,

llvm-r600-gcn-disassembly-in-elf.patch (6.08 KB)