Index: llvm/trunk/include/llvm/Support/TargetRegistry.h =================================================================== --- llvm/trunk/include/llvm/Support/TargetRegistry.h +++ llvm/trunk/include/llvm/Support/TargetRegistry.h @@ -47,6 +47,7 @@ class MCRelocationInfo; class MCTargetAsmParser; class MCTargetOptions; + class MCTargetStreamer; class TargetMachine; class TargetOptions; class raw_ostream; @@ -139,6 +140,7 @@ 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 @@ /// (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 @@ return llvm::createNullStreamer(Ctx); } + MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) const { + if (NullTargetStreamerCtorFn) + return NullTargetStreamerCtorFn(S); + return nullptr; + } + /// createMCRelocationInfo - Create a target specific MCRelocationInfo. /// /// \param TT The target triple. @@ -783,6 +795,11 @@ T.NullStreamerCtorFn = Fn; } + static void + RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn) { + T.NullTargetStreamerCtorFn = Fn; + } + /// RegisterMCRelocationInfo - Register an MCRelocationInfo /// implementation for the given target. /// Index: llvm/trunk/lib/Object/IRObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/IRObjectFile.cpp +++ llvm/trunk/lib/Object/IRObjectFile.cpp @@ -73,6 +73,7 @@ MCContext MCCtx(MAI.get(), MRI.get(), &MOFI); MOFI.InitMCObjectFileInfo(Triple, Reloc::Default, CodeModel::Default, MCCtx); std::unique_ptr Streamer(new RecordStreamer(MCCtx)); + T->createNullTargetStreamer(*Streamer); std::unique_ptr Buffer(MemoryBuffer::getMemBuffer(InlineAsm)); SourceMgr SrcMgr; Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -1360,6 +1360,10 @@ 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) { Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h =================================================================== --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.h @@ -29,6 +29,7 @@ class MCSubtargetInfo; class MCStreamer; class MCRelocationInfo; +class MCTargetStreamer; class StringRef; class Target; class raw_ostream; @@ -53,6 +54,8 @@ MCStreamer *createARMNullStreamer(MCContext &Ctx); +MCTargetStreamer *createARMNullTargetStreamer(MCStreamer &S); + MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, const MCSubtargetInfo &STI, Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -461,6 +461,16 @@ 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); Index: llvm/trunk/test/LTO/ARM/inline-asm.ll =================================================================== --- llvm/trunk/test/LTO/ARM/inline-asm.ll +++ llvm/trunk/test/LTO/ARM/inline-asm.ll @@ -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"