[PATCH] D137120: SystemZ: Register null target streamer

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 31 15:27:44 PDT 2022


arsenm created this revision.
arsenm added reviewers: uweigand, jonpa.
Herald added a subscriber: hiraditya.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

Fixes at least one null dereference.


https://reviews.llvm.org/D137120

Files:
  llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
  llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
  llvm/test/CodeGen/SystemZ/memcpy-01.ll


Index: llvm/test/CodeGen/SystemZ/memcpy-01.ll
===================================================================
--- llvm/test/CodeGen/SystemZ/memcpy-01.ll
+++ llvm/test/CodeGen/SystemZ/memcpy-01.ll
@@ -1,6 +1,7 @@
 ; Test memcpy using MVC.
 ;
 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
+; RUN: llc -mtriple=s390x-linux-gnu -filetype=null %s
 
 declare void @llvm.memcpy.p0.p0.i32(ptr nocapture, ptr nocapture, i32, i1) nounwind
 declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
Index: llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
===================================================================
--- llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
+++ llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
@@ -48,7 +48,7 @@
 
   void emitConstantPools() override;
 
-  virtual void emitMachine(StringRef CPU) = 0;
+  virtual void emitMachine(StringRef CPU) {};
 };
 
 } // end namespace llvm
Index: llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
===================================================================
--- llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
+++ llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
@@ -236,6 +236,11 @@
   return new SystemZTargetELFStreamer(S);
 }
 
+static MCTargetStreamer *
+createNullTargetStreamer(MCStreamer &S) {
+  return new SystemZTargetStreamer(S);
+}
+
 extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetMC() {
   // Register the MCAsmInfo.
   TargetRegistry::RegisterMCAsmInfo(getTheSystemZTarget(),
@@ -272,4 +277,8 @@
   // Register the obj streamer
   TargetRegistry::RegisterObjectTargetStreamer(getTheSystemZTarget(),
                                                createObjectTargetStreamer);
+
+  // Register the null streamer
+  TargetRegistry::RegisterNullTargetStreamer(getTheSystemZTarget(),
+                                             createNullTargetStreamer);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137120.472155.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/8caa037f/attachment.bin>


More information about the llvm-commits mailing list