Index: lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -206,18 +206,6 @@ 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() { @@ -430,6 +418,18 @@ 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; Index: test/CodeGen/AMDGPU/debug.ll =================================================================== --- test/CodeGen/AMDGPU/debug.ll +++ test/CodeGen/AMDGPU/debug.ll @@ -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