Skip to content

Commit 48732d3

Browse files
committed
SPARC: Register null target streamer
Fixes null dereference in emitFunctionBodyStart for 64-bit
1 parent 1179bdf commit 48732d3

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
8484
return new SparcTargetAsmStreamer(S, OS);
8585
}
8686

87+
static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) {
88+
return new SparcTargetStreamer(S);
89+
}
90+
8791
static MCInstPrinter *createSparcMCInstPrinter(const Triple &T,
8892
unsigned SyntaxVariant,
8993
const MCAsmInfo &MAI,
@@ -122,6 +126,9 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTargetMC() {
122126
// Register the asm streamer.
123127
TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer);
124128

129+
// Register the null streamer.
130+
TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer);
131+
125132
// Register the MCInstPrinter
126133
TargetRegistry::RegisterMCInstPrinter(*T, createSparcMCInstPrinter);
127134
}

llvm/lib/Target/Sparc/MCTargetDesc/SparcTargetStreamer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class SparcTargetStreamer : public MCTargetStreamer {
2222
public:
2323
SparcTargetStreamer(MCStreamer &S);
2424
/// Emit ".register <reg>, #ignore".
25-
virtual void emitSparcRegisterIgnore(unsigned reg) = 0;
25+
virtual void emitSparcRegisterIgnore(unsigned reg){};
2626
/// Emit ".register <reg>, #scratch".
27-
virtual void emitSparcRegisterScratch(unsigned reg) = 0;
27+
virtual void emitSparcRegisterScratch(unsigned reg){};
2828
};
2929

3030
// This part is for ascii assembly output

llvm/test/CodeGen/SPARC/64bit.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; RUN: llc < %s -march=sparcv9 -mattr=+popc -disable-sparc-delay-filler -disable-sparc-leaf-proc | FileCheck %s
22
; RUN: llc < %s -march=sparcv9 -mattr=+popc | FileCheck %s -check-prefix=OPT
3+
; RUN: llc %s -march=sparcv9 -mattr=+popc -filetype=null
34

45
; CHECK-LABEL: ret2:
56
; CHECK: mov %i1, %i0

0 commit comments

Comments
 (0)