[llvm] r364508 - [AMDGPU] Fix +DumpCode to print an entry label for the first function
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 27 01:19:28 PDT 2019
Author: foad
Date: Thu Jun 27 01:19:28 2019
New Revision: 364508
URL: http://llvm.org/viewvc/llvm-project?rev=364508&view=rev
Log:
[AMDGPU] Fix +DumpCode to print an entry label for the first function
Summary:
The +DumpCode attribute is a horrible hack in AMDGPU to embed the
disassembly of the generated code into the elf file. It is used by LLPC
to implement an extension that allows the application to read back the
disassembly of the code.
It tries to print an entry label at the start of every function, but
that didn't work for the first function in the module because
DumpCodeInstEmitter wasn't initialised until EmitFunctionBodyStart
which is too late.
Change-Id: I790d73ddf4f51fd02ab32529380c7cb7c607c4ee
Reviewers: arsenm, tpr, kzhuravl
Reviewed By: arsenm
Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D63712
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/trunk/test/CodeGen/AMDGPU/debug.ll
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp?rev=364508&r1=364507&r2=364508&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp Thu Jun 27 01:19:28 2019
@@ -206,18 +206,6 @@ void AMDGPUAsmPrinter::EmitFunctionBodyS
if (STM.isAmdHsaOS())
HSAMetadataStream->emitKernel(*MF, CurrentProgramInfo);
-
- DumpCodeInstEmitter = nullptr;
- if (STM.dumpCode()) {
- // For -dumpcode, get the assembler out of the streamer, even if it does
- // not really want to let us have it. This only works with -filetype=obj.
- bool SaveFlag = OutStreamer->getUseAssemblerInfoForParsing();
- OutStreamer->setUseAssemblerInfoForParsing(true);
- MCAssembler *Assembler = OutStreamer->getAssemblerPtr();
- OutStreamer->setUseAssemblerInfoForParsing(SaveFlag);
- if (Assembler)
- DumpCodeInstEmitter = Assembler->getEmitterPtr();
- }
}
void AMDGPUAsmPrinter::EmitFunctionBodyEnd() {
@@ -458,6 +446,18 @@ bool AMDGPUAsmPrinter::runOnMachineFunct
EmitProgramInfoSI(MF, CurrentProgramInfo);
}
+ DumpCodeInstEmitter = nullptr;
+ if (STM.dumpCode()) {
+ // For -dumpcode, get the assembler out of the streamer, even if it does
+ // not really want to let us have it. This only works with -filetype=obj.
+ bool SaveFlag = OutStreamer->getUseAssemblerInfoForParsing();
+ OutStreamer->setUseAssemblerInfoForParsing(true);
+ MCAssembler *Assembler = OutStreamer->getAssemblerPtr();
+ OutStreamer->setUseAssemblerInfoForParsing(SaveFlag);
+ if (Assembler)
+ DumpCodeInstEmitter = Assembler->getEmitterPtr();
+ }
+
DisasmLines.clear();
HexLines.clear();
DisasmLineMaxLen = 0;
Modified: llvm/trunk/test/CodeGen/AMDGPU/debug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/debug.ll?rev=364508&r1=364507&r2=364508&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/debug.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/debug.ll Thu Jun 27 01:19:28 2019
@@ -3,6 +3,8 @@
; Test for a crash in the custom assembly dump code.
+; SI: test:
+; SI: BB0_0:
; SI: s_endpgm
define amdgpu_kernel void @test(i32 addrspace(1)* %out) {
store i32 0, i32 addrspace(1)* %out
More information about the llvm-commits
mailing list