Hexagon: Register null TargetStreamer
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 29 Oct 2022 19:34:03 +0000 (12:34 -0700)
committerMatt Arsenault <arsenm2@gmail.com>
Tue, 1 Nov 2022 01:32:41 +0000 (18:32 -0700)
Unlike just about every target, I don't
see an obvious null dereference this fixes.

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp

index b2eb968..3fd69a1 100644 (file)
@@ -346,6 +346,10 @@ createHexagonObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
   return new HexagonTargetELFStreamer(S, STI);
 }
 
+static MCTargetStreamer *createHexagonNullTargetStreamer(MCStreamer &S) {
+  return new HexagonTargetStreamer(S);
+}
+
 static void LLVM_ATTRIBUTE_UNUSED clearFeature(MCSubtargetInfo* STI, uint64_t F) {
   if (STI->getFeatureBits()[F])
     STI->ToggleFeature(F);
@@ -660,6 +664,10 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetMC() {
   TargetRegistry::RegisterAsmTargetStreamer(getTheHexagonTarget(),
                                             createMCAsmTargetStreamer);
 
+  // Register the null streamer
+  TargetRegistry::RegisterNullTargetStreamer(getTheHexagonTarget(),
+                                             createHexagonNullTargetStreamer);
+
   // Register the MC Inst Printer
   TargetRegistry::RegisterMCInstPrinter(getTheHexagonTarget(),
                                         createHexagonMCInstPrinter);