Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp =================================================================== --- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -352,6 +352,10 @@ return new PPCTargetAsmStreamer(S, OS); } +static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) { + return new PPCTargetStreamer(S); +} + static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) { const Triple &TT = STI.getTargetTriple(); @@ -432,6 +436,9 @@ // Register the asm target streamer. TargetRegistry::RegisterAsmTargetStreamer(*T, createAsmTargetStreamer); + // Register the null target streamer. + TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer); + // Register the MCInstPrinter. TargetRegistry::RegisterMCInstPrinter(*T, createPPCMCInstPrinter); } Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1572,9 +1572,7 @@ if (static_cast(TM).isELFv2ABI()) { PPCTargetStreamer *TS = static_cast(OutStreamer->getTargetStreamer()); - - if (TS) - TS->emitAbiVersion(2); + TS->emitAbiVersion(2); } if (static_cast(TM).isPPC64() || @@ -1700,7 +1698,7 @@ MCSymbol *const TOCEntryLabel = TOCMapPair.second; OutStreamer->emitLabel(TOCEntryLabel); - if (isPPC64 && TS != nullptr) + if (isPPC64) TS->emitTCEntry(*TOCEntryTarget, TOCMapPair.first.second); else OutStreamer->emitSymbolValue(TOCEntryTarget, 4); @@ -1806,9 +1804,7 @@ PPCTargetStreamer *TS = static_cast(OutStreamer->getTargetStreamer()); - - if (TS) - TS->emitLocalEntry(cast(CurrentFnSym), LocalOffsetExp); + TS->emitLocalEntry(cast(CurrentFnSym), LocalOffsetExp); } else if (Subtarget->isUsingPCRelativeCalls()) { // When generating the entry point for a function we have a few scenarios // based on whether or not that function uses R2 and whether or not that @@ -1835,9 +1831,8 @@ MF->hasInlineAsm() || (!PPCFI->usesTOCBasePtr() && UsesX2OrR2)) { PPCTargetStreamer *TS = static_cast(OutStreamer->getTargetStreamer()); - if (TS) - TS->emitLocalEntry(cast(CurrentFnSym), - MCConstantExpr::create(1, OutContext)); + TS->emitLocalEntry(cast(CurrentFnSym), + MCConstantExpr::create(1, OutContext)); } } } @@ -2568,8 +2563,7 @@ OutStreamer->switchSection(TCEntry); OutStreamer->emitLabel(I.second); - if (TS != nullptr) - TS->emitTCEntry(*I.first.first, I.first.second); + TS->emitTCEntry(*I.first.first, I.first.second); } for (const auto *GV : TOCDataGlobalVars) Index: llvm/lib/Target/PowerPC/PPCTargetStreamer.h =================================================================== --- llvm/lib/Target/PowerPC/PPCTargetStreamer.h +++ llvm/lib/Target/PowerPC/PPCTargetStreamer.h @@ -25,10 +25,10 @@ ~PPCTargetStreamer() override; virtual void emitTCEntry(const MCSymbol &S, - MCSymbolRefExpr::VariantKind Kind) = 0; - virtual void emitMachine(StringRef CPU) = 0; - virtual void emitAbiVersion(int AbiVersion) = 0; - virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset) = 0; + MCSymbolRefExpr::VariantKind Kind){}; + virtual void emitMachine(StringRef CPU){}; + virtual void emitAbiVersion(int AbiVersion){}; + virtual void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset){}; }; } // end namespace llvm