[llvm] r236004 - R600: Fix up for AsmPrinter's OutStreamer being a unique_ptr

David Blaikie dblaikie at gmail.com
Tue Apr 28 11:15:50 PDT 2015


On Tue, Apr 28, 2015 at 10:37 AM, Tom Stellard <thomas.stellard at amd.com>
wrote:

> Author: tstellar
> Date: Tue Apr 28 12:37:03 2015
> New Revision: 236004
>
> URL: http://llvm.org/viewvc/llvm-project?rev=236004&view=rev
> Log:
> R600: Fix up for AsmPrinter's OutStreamer being a unique_ptr
>
> 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 at amd.com>
>
> Added:
>     llvm/trunk/test/CodeGen/R600/debug.ll
> Modified:
>     llvm/trunk/lib/Target/R600/AMDGPUMCInstLower.cpp
>
> Modified: llvm/trunk/lib/Target/R600/AMDGPUMCInstLower.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/AMDGPUMCInstLower.cpp?rev=236004&r1=236003&r2=236004&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/R600/AMDGPUMCInstLower.cpp (original)
> +++ llvm/trunk/lib/Target/R600/AMDGPUMCInstLower.cpp Tue Apr 28 12:37:03
> 2015
> @@ -132,8 +132,9 @@ void AMDGPUAsmPrinter::EmitInstruction(c
>        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());
>

Could skip the '.get()' call by moving to references, since we dereference
on the next line anyway:

auto &ObjStreamer = static_cast<MCObjectStreamer&>(*OutStreamer);

(& this starts to look a lot like the original code, just adding the needed
dereference in, fixing up the cast to be safer, using auto to avoid
duplicating the typename, etc)

But maybe the ref/pointer difference between OutStreamer and ObjStreamer
would be confusing? (though it's only used once anyway, on the immediate
next line)


> +      MCCodeEmitter &InstEmitter =
> ObjStreamer->getAssembler().getEmitter();
>        InstEmitter.EncodeInstruction(TmpInst, CodeStream, Fixups,
>                                      MF->getSubtarget<MCSubtargetInfo>());
>        CodeStream.flush();
>
> Added: llvm/trunk/test/CodeGen/R600/debug.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/debug.ll?rev=236004&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/R600/debug.ll (added)
> +++ llvm/trunk/test/CodeGen/R600/debug.ll Tue Apr 28 12:37:03 2015
> @@ -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
> +}
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150428/ab5c3939/attachment.html>


More information about the llvm-commits mailing list