[llvm] 5baa4b8 - SystemZ: Register null target streamer

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 11:11:43 PDT 2022


Author: Matt Arsenault
Date: 2022-11-01T11:11:22-07:00
New Revision: 5baa4b8e1164b3635ef9220104159988f4ee836a

URL: https://github.com/llvm/llvm-project/commit/5baa4b8e1164b3635ef9220104159988f4ee836a
DIFF: https://github.com/llvm/llvm-project/commit/5baa4b8e1164b3635ef9220104159988f4ee836a.diff

LOG: SystemZ: Register null target streamer

Fixes at least one null dereference.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
index 08886507fdb77..8e86c59bf9194 100644
--- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
+++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp
@@ -236,6 +236,11 @@ createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
   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 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetMC() {
   // Register the obj streamer
   TargetRegistry::RegisterObjectTargetStreamer(getTheSystemZTarget(),
                                                createObjectTargetStreamer);
+
+  // Register the null streamer
+  TargetRegistry::RegisterNullTargetStreamer(getTheSystemZTarget(),
+                                             createNullTargetStreamer);
 }

diff  --git a/llvm/lib/Target/SystemZ/SystemZTargetStreamer.h b/llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
index 1b4e93ebe39be..884082cfa1965 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
+++ b/llvm/lib/Target/SystemZ/SystemZTargetStreamer.h
@@ -48,7 +48,7 @@ class SystemZTargetStreamer : public MCTargetStreamer {
 
   void emitConstantPools() override;
 
-  virtual void emitMachine(StringRef CPU) = 0;
+  virtual void emitMachine(StringRef CPU) {};
 };
 
 } // end namespace llvm

diff  --git a/llvm/test/CodeGen/SystemZ/memcpy-01.ll b/llvm/test/CodeGen/SystemZ/memcpy-01.ll
index a2ccb5f36be4d..cabbfb40acb9a 100644
--- a/llvm/test/CodeGen/SystemZ/memcpy-01.ll
+++ b/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


        


More information about the llvm-commits mailing list