R600: Fix up for AsmPrinter's OutStreamer being a unique_ptr
authorTom Stellard <thomas.stellard@amd.com>
Tue, 28 Apr 2015 17:37:03 +0000 (17:37 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 28 Apr 2015 17:37:03 +0000 (17:37 +0000)
Fixes a crash with basically any OpenGL application using the radeonsi
driver.

Patch by: Michel Dänzer

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90176
Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236004 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/AMDGPUMCInstLower.cpp
test/CodeGen/R600/debug.ll [new file with mode: 0644]

index b00bd8d9490c0829193b1cbde978cece02a991b4..0aa1a9a2a2c3f63185cda512a34786c6c848d137 100644 (file)
@@ -132,8 +132,9 @@ void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
       SmallVector<char, 16> CodeBytes;
       raw_svector_ostream CodeStream(CodeBytes);
 
-      MCObjectStreamer &ObjStreamer = (MCObjectStreamer &)OutStreamer;
-      MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
+      MCObjectStreamer *ObjStreamer =
+          static_cast<MCObjectStreamer *>(OutStreamer.get());
+      MCCodeEmitter &InstEmitter = ObjStreamer->getAssembler().getEmitter();
       InstEmitter.EncodeInstruction(TmpInst, CodeStream, Fixups,
                                     MF->getSubtarget<MCSubtargetInfo>());
       CodeStream.flush();
diff --git a/test/CodeGen/R600/debug.ll b/test/CodeGen/R600/debug.ll
new file mode 100644 (file)
index 0000000..a2e0e87
--- /dev/null
@@ -0,0 +1,10 @@
+; RUN: llc < %s -march=amdgcn -mcpu=verde -verify-machineinstrs -mattr=dumpcode -filetype=obj | FileCheck --check-prefix=SI --check-prefix=FUNC %s
+; RUN: llc < %s -march=amdgcn -mcpu=tonga -verify-machineinstrs -mattr=dumpcode -filetype=obj | FileCheck --check-prefix=SI --check-prefix=FUNC %s
+
+; Test for a crash in the custom assembly dump code.
+
+; SI: s_endpgm
+define void @test(i32 addrspace(1)* %out) {
+  store i32 0, i32 addrspace(1)* %out
+  ret void
+}