llvm.org GIT mirror llvm / 61b696f
Allow a target to create a null streamer. Targets can assume that a target streamer is present, so they have to be able to construct a null streamer in order to set the target streamer in it to. Fixes a crash when using the null streamer with arm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211358 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
7 changed file(s) with 64 addition(s) and 75 deletion(s). Raw diff Collapse all Expand all
5050 class raw_ostream;
5151 class formatted_raw_ostream;
5252
53 MCStreamer *createNullStreamer(MCContext &Ctx);
5354 MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
5455 bool isVerboseAsm, bool useDwarfDirectory,
5556 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
138139 MCCodeEmitter *CE,
139140 MCAsmBackend *TAB,
140141 bool ShowInst);
142 typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
141143 typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
142144 MCContext &Ctx);
143145 typedef MCSymbolizer *(*MCSymbolizerCtorTy)(StringRef TT,
224226 /// AsmStreamer, if registered (default = llvm::createAsmStreamer).
225227 AsmStreamerCtorTy AsmStreamerCtorFn;
226228
229 /// Construction function for this target's NullStreamer, if registered
230 /// (default = llvm::createNullStreamer).
231 NullStreamerCtorTy NullStreamerCtorFn;
232
227233 /// MCRelocationInfoCtorFn - Construction function for this target's
228234 /// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
229235 MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
234240
235241 public:
236242 Target()
237 : AsmStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
238 MCSymbolizerCtorFn(nullptr) {}
243 : AsmStreamerCtorFn(nullptr), NullStreamerCtorFn(nullptr),
244 MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
239245
240246 /// @name Target Information
241247 /// @{
446452 InstPrint, CE, TAB, ShowInst);
447453 }
448454
455 MCStreamer *createNullStreamer(MCContext &Ctx) const {
456 if (NullStreamerCtorFn)
457 return NullStreamerCtorFn(Ctx);
458 return llvm::createNullStreamer(Ctx);
459 }
460
449461 /// createMCRelocationInfo - Create a target specific MCRelocationInfo.
450462 ///
451463 /// \param TT The target triple.
779791 T.AsmStreamerCtorFn = Fn;
780792 }
781793
794 static void RegisterNullStreamer(Target &T, Target::NullStreamerCtorTy Fn) {
795 T.NullStreamerCtorFn = Fn;
796 }
797
782798 /// RegisterMCRelocationInfo - Register an MCRelocationInfo
783799 /// implementation for the given target.
784800 ///
208208 case CGFT_Null:
209209 // The Null output is intended for use for performance analysis and testing,
210210 // not real users.
211 AsmStreamer.reset(createNullStreamer(*Context));
211 AsmStreamer.reset(getTarget().createNullStreamer(*Context));
212212 break;
213213 }
214214
13311331 return S;
13321332 }
13331333
1334 MCStreamer *createARMNullStreamer(MCContext &Ctx) {
1335 MCStreamer *S = llvm::createNullStreamer(Ctx);
1336 new ARMTargetStreamer(*S);
1337 return S;
1338 }
1339
13341340 MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
13351341 raw_ostream &OS, MCCodeEmitter *Emitter,
13361342 bool RelaxAll, bool NoExecStack,
426426 TargetRegistry::RegisterAsmStreamer(TheThumbLETarget, createMCAsmStreamer);
427427 TargetRegistry::RegisterAsmStreamer(TheThumbBETarget, createMCAsmStreamer);
428428
429 // Register the null streamer.
430 TargetRegistry::RegisterNullStreamer(TheARMLETarget, createARMNullStreamer);
431 TargetRegistry::RegisterNullStreamer(TheARMBETarget, createARMNullStreamer);
432 TargetRegistry::RegisterNullStreamer(TheThumbLETarget, createARMNullStreamer);
433 TargetRegistry::RegisterNullStreamer(TheThumbBETarget, createARMNullStreamer);
434
429435 // Register the MCInstPrinter.
430436 TargetRegistry::RegisterMCInstPrinter(TheARMLETarget, createARMMCInstPrinter);
431437 TargetRegistry::RegisterMCInstPrinter(TheARMBETarget, createARMMCInstPrinter);
4949 bool isVerboseAsm, bool useDwarfDirectory,
5050 MCInstPrinter *InstPrint, MCCodeEmitter *CE,
5151 MCAsmBackend *TAB, bool ShowInst);
52
53 MCStreamer *createARMNullStreamer(MCContext &Ctx);
5254
5355 MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
5456 const MCRegisterInfo &MRI,
3939
4040 // The remaining callbacks should be handled separately by each
4141 // streamer.
42 void ARMTargetStreamer::emitFnStart() {
43 llvm_unreachable("unimplemented");
42 void ARMTargetStreamer::emitFnStart() {}
43 void ARMTargetStreamer::emitFnEnd() {}
44 void ARMTargetStreamer::emitCantUnwind() {}
45 void ARMTargetStreamer::emitPersonality(const MCSymbol *Personality) {}
46 void ARMTargetStreamer::emitPersonalityIndex(unsigned Index) {}
47 void ARMTargetStreamer::emitHandlerData() {}
48 void ARMTargetStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
49 int64_t Offset) {}
50 void ARMTargetStreamer::emitMovSP(unsigned Reg, int64_t Offset) {}
51 void ARMTargetStreamer::emitPad(int64_t Offset) {}
52 void ARMTargetStreamer::emitRegSave(const SmallVectorImpl &RegList,
53 bool isVector) {}
54 void ARMTargetStreamer::emitUnwindRaw(int64_t StackOffset,
55 const SmallVectorImpl &Opcodes) {
4456 }
45 void ARMTargetStreamer::emitFnEnd() {
46 llvm_unreachable("unimplemented");
47 }
48 void ARMTargetStreamer::emitCantUnwind() {
49 llvm_unreachable("unimplemented");
50 }
51 void ARMTargetStreamer::emitPersonality(const MCSymbol *Personality) {
52 llvm_unreachable("unimplemented");
53 }
54 void ARMTargetStreamer::emitPersonalityIndex(unsigned Index) {
55 llvm_unreachable("unimplemented");
56 }
57 void ARMTargetStreamer::emitHandlerData() {
58 llvm_unreachable("unimplemented");
59 }
60 void ARMTargetStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
61 int64_t Offset) {
62 llvm_unreachable("unimplemented");
63 }
64 void ARMTargetStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
65 llvm_unreachable("unimplemented");
66 }
67 void ARMTargetStreamer::emitPad(int64_t Offset) {
68 llvm_unreachable("unimplemented");
69 }
57 void ARMTargetStreamer::switchVendor(StringRef Vendor) {}
58 void ARMTargetStreamer::emitAttribute(unsigned Attribute, unsigned Value) {}
59 void ARMTargetStreamer::emitTextAttribute(unsigned Attribute,
60 StringRef String) {}
61 void ARMTargetStreamer::emitIntTextAttribute(unsigned Attribute,
62 unsigned IntValue,
63 StringRef StringValue) {}
64 void ARMTargetStreamer::emitArch(unsigned Arch) {}
65 void ARMTargetStreamer::emitObjectArch(unsigned Arch) {}
66 void ARMTargetStreamer::emitFPU(unsigned FPU) {}
67 void ARMTargetStreamer::finishAttributeSection() {}
68 void ARMTargetStreamer::emitInst(uint32_t Inst, char Suffix) {}
7069 void
71 ARMTargetStreamer::emitRegSave(const SmallVectorImpl &RegList,
72 bool isVector) {
73 llvm_unreachable("unimplemented");
74 }
75 void ARMTargetStreamer::emitUnwindRaw(
76 int64_t StackOffset, const SmallVectorImpl &Opcodes) {
77 llvm_unreachable("unimplemented");
78 }
79 void ARMTargetStreamer::switchVendor(StringRef Vendor) {
80 llvm_unreachable("unimplemented");
81 }
82 void ARMTargetStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
83 llvm_unreachable("unimplemented");
84 }
85 void ARMTargetStreamer::emitTextAttribute(unsigned Attribute,
86 StringRef String) {
87 llvm_unreachable("unimplemented");
88 }
89 void ARMTargetStreamer::emitIntTextAttribute(unsigned Attribute,
90 unsigned IntValue,
91 StringRef StringValue) {
92 llvm_unreachable("unimplemented");
93 }
94 void ARMTargetStreamer::emitArch(unsigned Arch) {
95 llvm_unreachable("unimplemented");
96 }
97 void ARMTargetStreamer::emitObjectArch(unsigned Arch) {
98 llvm_unreachable("unimplemented");
99 }
100 void ARMTargetStreamer::emitFPU(unsigned FPU) {
101 llvm_unreachable("unimplemented");
102 }
103 void ARMTargetStreamer::finishAttributeSection() {
104 llvm_unreachable("unimplemented");
105 }
106 void ARMTargetStreamer::emitInst(uint32_t Inst, char Suffix) {
107 llvm_unreachable("unimplemented");
108 }
109 void ARMTargetStreamer::AnnotateTLSDescriptorSequence(
110 const MCSymbolRefExpr *SRE) {
111 llvm_unreachable("unimplemented");
112 }
70 ARMTargetStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) {}
11371
114 void ARMTargetStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
115 llvm_unreachable("unimplemented");
116 }
72 void ARMTargetStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {}
44
55 ; Also test that the null streamer doesn't crash with debug info.
66 ; RUN: %llc_dwarf -O0 -filetype=null < %s
7
8 ; Test the null streamer with a terget streamer too.
9 ; RUN: llc -O0 -filetype=null -mtriple=arm-linux < %s
710
811 ; generated from the following source compiled to bitcode with clang -g -O1
912 ; static int i;