[llvm] r229797 - Introduce Target::createNullTargetStreamer and use it from IRObjectFile.
David Blaikie
dblaikie at gmail.com
Thu Feb 19 11:01:18 PST 2015
On Wed, Feb 18, 2015 at 4:45 PM, Peter Collingbourne <peter at pcc.me.uk>
wrote:
> Author: pcc
> Date: Wed Feb 18 18:45:02 2015
> New Revision: 229797
>
> URL: http://llvm.org/viewvc/llvm-project?rev=229797&view=rev
> Log:
> Introduce Target::createNullTargetStreamer and use it from IRObjectFile.
>
> A null MCTargetStreamer allows IRObjectFile to ignore target-specific
> directives. Previously we were crashing.
>
> Differential Revision: http://reviews.llvm.org/D7711
>
> Added:
> llvm/trunk/test/LTO/ARM/inline-asm.ll
> Modified:
> llvm/trunk/include/llvm/Support/TargetRegistry.h
> llvm/trunk/lib/Object/IRObjectFile.cpp
> llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
> llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
> llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h
>
> Modified: llvm/trunk/include/llvm/Support/TargetRegistry.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TargetRegistry.h?rev=229797&r1=229796&r2=229797&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/Support/TargetRegistry.h (original)
> +++ llvm/trunk/include/llvm/Support/TargetRegistry.h Wed Feb 18 18:45:02
> 2015
> @@ -47,6 +47,7 @@ namespace llvm {
> class MCRelocationInfo;
> class MCTargetAsmParser;
> class MCTargetOptions;
> + class MCTargetStreamer;
> class TargetMachine;
> class TargetOptions;
> class raw_ostream;
> @@ -139,6 +140,7 @@ namespace llvm {
> MCAsmBackend *TAB,
> bool ShowInst);
> typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
> + typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
> typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
> MCContext &Ctx);
> typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
> @@ -227,6 +229,10 @@ namespace llvm {
> /// (default = llvm::createNullStreamer).
> NullStreamerCtorTy NullStreamerCtorFn;
>
> + /// Construction function for this target's null TargetStreamer, if
> + /// registered (default = nullptr).
> + NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
> +
> /// MCRelocationInfoCtorFn - Construction function for this target's
> /// MCRelocationInfo, if registered (default =
> llvm::createMCRelocationInfo)
> MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
> @@ -453,6 +459,12 @@ namespace llvm {
> return llvm::createNullStreamer(Ctx);
> }
>
> + MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const {
>
Could/should this (& NullTargetStreamerCtorFn) return by unique_ptr instead?
> + if (NullTargetStreamerCtorFn)
> + return NullTargetStreamerCtorFn(S);
> + return nullptr;
> + }
> +
> /// createMCRelocationInfo - Create a target specific
> MCRelocationInfo.
> ///
> /// \param TT The target triple.
> @@ -783,6 +795,11 @@ namespace llvm {
> T.NullStreamerCtorFn = Fn;
> }
>
> + static void
> + RegisterNullTargetStreamer(Target &T,
> Target::NullTargetStreamerCtorTy Fn) {
> + T.NullTargetStreamerCtorFn = Fn;
> + }
> +
> /// RegisterMCRelocationInfo - Register an MCRelocationInfo
> /// implementation for the given target.
> ///
>
> Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=229797&r1=229796&r2=229797&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/IRObjectFile.cpp Wed Feb 18 18:45:02 2015
> @@ -73,6 +73,7 @@ IRObjectFile::IRObjectFile(MemoryBufferR
> MCContext MCCtx(MAI.get(), MRI.get(), &MOFI);
> MOFI.InitMCObjectFileInfo(Triple, Reloc::Default, CodeModel::Default,
> MCCtx);
> std::unique_ptr<RecordStreamer> Streamer(new RecordStreamer(MCCtx));
> + T->createNullTargetStreamer(*Streamer);
>
> std::unique_ptr<MemoryBuffer>
> Buffer(MemoryBuffer::getMemBuffer(InlineAsm));
> SourceMgr SrcMgr;
>
> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp?rev=229797&r1=229796&r2=229797&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp Wed Feb 18
> 18:45:02 2015
> @@ -1360,6 +1360,10 @@ MCStreamer *createARMNullStreamer(MCCont
> return S;
> }
>
> +MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S) {
> + return new ARMTargetStreamer(S);
> +}
> +
> MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
> raw_ostream &OS, MCCodeEmitter
> *Emitter,
> bool RelaxAll, bool IsThumb) {
>
> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp?rev=229797&r1=229796&r2=229797&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp (original)
> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp Wed Feb 18
> 18:45:02 2015
> @@ -461,6 +461,16 @@ extern "C" void LLVMInitializeARMTargetM
> TargetRegistry::RegisterNullStreamer(TheThumbLETarget,
> createARMNullStreamer);
> TargetRegistry::RegisterNullStreamer(TheThumbBETarget,
> createARMNullStreamer);
>
> + // Register the null TargetStreamer.
> + TargetRegistry::RegisterNullTargetStreamer(TheARMLETarget,
> + createARMNullTargetStreamer);
> + TargetRegistry::RegisterNullTargetStreamer(TheARMBETarget,
> + createARMNullTargetStreamer);
> + TargetRegistry::RegisterNullTargetStreamer(TheThumbLETarget,
> + createARMNullTargetStreamer);
> + TargetRegistry::RegisterNullTargetStreamer(TheThumbBETarget,
> + createARMNullTargetStreamer);
> +
> // Register the MCInstPrinter.
> TargetRegistry::RegisterMCInstPrinter(TheARMLETarget,
> createARMMCInstPrinter);
> TargetRegistry::RegisterMCInstPrinter(TheARMBETarget,
> createARMMCInstPrinter);
>
> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h?rev=229797&r1=229796&r2=229797&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h (original)
> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h Wed Feb 18
> 18:45:02 2015
> @@ -29,6 +29,7 @@ class MCRegisterInfo;
> class MCSubtargetInfo;
> class MCStreamer;
> class MCRelocationInfo;
> +class MCTargetStreamer;
> class StringRef;
> class Target;
> class raw_ostream;
> @@ -53,6 +54,8 @@ MCStreamer *createMCAsmStreamer(MCContex
>
> MCStreamer *createARMNullStreamer(MCContext &Ctx);
>
> +MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S);
> +
> MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
> const MCRegisterInfo &MRI,
> const MCSubtargetInfo &STI,
>
> Added: llvm/trunk/test/LTO/ARM/inline-asm.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/ARM/inline-asm.ll?rev=229797&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/LTO/ARM/inline-asm.ll (added)
> +++ llvm/trunk/test/LTO/ARM/inline-asm.ll Wed Feb 18 18:45:02 2015
> @@ -0,0 +1,9 @@
> +; Check that we don't crash on target-specific inline asm directives.
> +;
> +; RUN: llvm-as < %s > %t
> +; RUN: llvm-lto -o /dev/null %t -mcpu armv4t
> +
> +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
> +target triple = "armv4t-unknown-linux"
> +
> +module asm ".fnstart"
>
>
> _______________________________________________
> 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/20150219/91c49823/attachment.html>
More information about the llvm-commits
mailing list