diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1396,8 +1396,8 @@ bool isPPC64 = DL.getPointerSizeInBits() == 64; - PPCTargetStreamer &TS = - static_cast(*OutStreamer->getTargetStreamer()); + PPCTargetStreamer *TS = + static_cast(OutStreamer->getTargetStreamer()); if (!TOC.empty()) { const char *Name = isPPC64 ? ".toc" : ".got2"; @@ -1412,8 +1412,8 @@ MCSymbol *const TOCEntryLabel = TOCMapPair.second; OutStreamer->emitLabel(TOCEntryLabel); - if (isPPC64) - TS.emitTCEntry(*TOCEntryTarget); + if (isPPC64 && TS != nullptr) + TS->emitTCEntry(*TOCEntryTarget); else OutStreamer->emitSymbolValue(TOCEntryTarget, 4); }