-
LLVM: add option to emit asm file to aid debugging · 6f6ca293Antonio Maiorano authored
Defining ENABLE_RR_EMIT_ASM_FILE will make it so that the LLVM backend outputs a unique asm file per routine that is generated. This file is further processed and updated so that each instruction is prefixed with the final resolved memory location. This is useful, for instance, when we get JIT callstacks and can't easily figure out which code it maps to. Furthermore, when this feature is coupled with ENABLE_RR_DEBUG_INFO, the emitted asm includes source location (file and line) information, making it easy to correlate the asm to the Reactor code. For example, running ReactorUnitTests.Sample with both ENABLE_RR_EMIT_ASM_FILE and ENABLE_RR_DEBUG_INFO enabled generates a file named swiftshader_jit_llvm_0000_ReactorUnitTests_Sample.asm, with partial output like so: ``` .file 2 "C:\\src\\SwiftShader2\\tests\\ReactorUnitTests\\ReactorUnitTests.cpp\\<unknown>" .loc 2 53 0 prologue_end # <unknown>:53:0 [0x2B9D3358004] mov qword ptr [rsp + 64], rcx # encoding: [0x48,0x89,0x4c,0x24,0x40] [0x2B9D3358009] mov qword ptr [rsp + 72], rcx # encoding: [0x48,0x89,0x4c,0x24,0x48] .loc 2 54 0 # <unknown>:54:0 [0x2B9D335800E] mov eax, dword ptr [rcx - 4] # encoding: [0x8b,0x41,0xfc] [0x2B9D3358011] mov dword ptr [rsp + 8], eax # encoding: [0x89,0x44,0x24,0x08] [0x2B9D3358015] mov dword ptr [rsp + 16], eax # encoding: [0x89,0x44,0x24,0x10] .loc 2 55 0 # <unknown>:55:0 [0x2B9D3358019] mov dword ptr [rsp + 12], edx # encoding: [0x89,0x54,0x24,0x0c] [0x2B9D335801D] mov dword ptr [rsp + 20], edx # encoding: [0x89,0x54,0x24,0x14] ``` The "53", "54", and "55" are the line numbers of the respective Reactor code in ReactorUnitTests.cpp. CMake: enable REACTOR_EMIT_ASM_FILE to enable this feature. Bug: b/174358505 Change-Id: I613a25fe0354a1343c49cb399875e82d5e806e29 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/50750 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by:
Antonio Maiorano <amaiorano@google.com> Reviewed-by:
Nicolas Capens <nicolascapens@google.com>
6f6ca293
×