mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
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
This commit is contained in:
parent
729aa1dbd3
commit
61b696f1fa
@ -51,6 +51,7 @@ namespace llvm {
|
|||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
class formatted_raw_ostream;
|
class formatted_raw_ostream;
|
||||||
|
|
||||||
|
MCStreamer *createNullStreamer(MCContext &Ctx);
|
||||||
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
||||||
bool isVerboseAsm, bool useDwarfDirectory,
|
bool isVerboseAsm, bool useDwarfDirectory,
|
||||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||||
@ -139,6 +140,7 @@ namespace llvm {
|
|||||||
MCCodeEmitter *CE,
|
MCCodeEmitter *CE,
|
||||||
MCAsmBackend *TAB,
|
MCAsmBackend *TAB,
|
||||||
bool ShowInst);
|
bool ShowInst);
|
||||||
|
typedef MCStreamer *(*NullStreamerCtorTy)(MCContext &Ctx);
|
||||||
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
|
typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(StringRef TT,
|
||||||
MCContext &Ctx);
|
MCContext &Ctx);
|
||||||
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(StringRef TT,
|
typedef MCSymbolizer *(*MCSymbolizerCtorTy)(StringRef TT,
|
||||||
@ -225,6 +227,10 @@ namespace llvm {
|
|||||||
/// AsmStreamer, if registered (default = llvm::createAsmStreamer).
|
/// AsmStreamer, if registered (default = llvm::createAsmStreamer).
|
||||||
AsmStreamerCtorTy AsmStreamerCtorFn;
|
AsmStreamerCtorTy AsmStreamerCtorFn;
|
||||||
|
|
||||||
|
/// Construction function for this target's NullStreamer, if registered
|
||||||
|
/// (default = llvm::createNullStreamer).
|
||||||
|
NullStreamerCtorTy NullStreamerCtorFn;
|
||||||
|
|
||||||
/// MCRelocationInfoCtorFn - Construction function for this target's
|
/// MCRelocationInfoCtorFn - Construction function for this target's
|
||||||
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
|
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
|
||||||
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
|
MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
|
||||||
@ -235,8 +241,8 @@ namespace llvm {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
Target()
|
Target()
|
||||||
: AsmStreamerCtorFn(nullptr), MCRelocationInfoCtorFn(nullptr),
|
: AsmStreamerCtorFn(nullptr), NullStreamerCtorFn(nullptr),
|
||||||
MCSymbolizerCtorFn(nullptr) {}
|
MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
|
||||||
|
|
||||||
/// @name Target Information
|
/// @name Target Information
|
||||||
/// @{
|
/// @{
|
||||||
@ -447,6 +453,12 @@ namespace llvm {
|
|||||||
InstPrint, CE, TAB, ShowInst);
|
InstPrint, CE, TAB, ShowInst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCStreamer *createNullStreamer(MCContext &Ctx) const {
|
||||||
|
if (NullStreamerCtorFn)
|
||||||
|
return NullStreamerCtorFn(Ctx);
|
||||||
|
return llvm::createNullStreamer(Ctx);
|
||||||
|
}
|
||||||
|
|
||||||
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
/// createMCRelocationInfo - Create a target specific MCRelocationInfo.
|
||||||
///
|
///
|
||||||
/// \param TT The target triple.
|
/// \param TT The target triple.
|
||||||
@ -780,6 +792,10 @@ namespace llvm {
|
|||||||
T.AsmStreamerCtorFn = Fn;
|
T.AsmStreamerCtorFn = Fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void RegisterNullStreamer(Target &T, Target::NullStreamerCtorTy Fn) {
|
||||||
|
T.NullStreamerCtorFn = Fn;
|
||||||
|
}
|
||||||
|
|
||||||
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
/// RegisterMCRelocationInfo - Register an MCRelocationInfo
|
||||||
/// implementation for the given target.
|
/// implementation for the given target.
|
||||||
///
|
///
|
||||||
|
@ -209,7 +209,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
|||||||
case CGFT_Null:
|
case CGFT_Null:
|
||||||
// The Null output is intended for use for performance analysis and testing,
|
// The Null output is intended for use for performance analysis and testing,
|
||||||
// not real users.
|
// not real users.
|
||||||
AsmStreamer.reset(createNullStreamer(*Context));
|
AsmStreamer.reset(getTarget().createNullStreamer(*Context));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,6 +1332,12 @@ MCStreamer *createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
|||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MCStreamer *createARMNullStreamer(MCContext &Ctx) {
|
||||||
|
MCStreamer *S = llvm::createNullStreamer(Ctx);
|
||||||
|
new ARMTargetStreamer(*S);
|
||||||
|
return S;
|
||||||
|
}
|
||||||
|
|
||||||
MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
MCELFStreamer* createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB,
|
||||||
raw_ostream &OS, MCCodeEmitter *Emitter,
|
raw_ostream &OS, MCCodeEmitter *Emitter,
|
||||||
bool RelaxAll, bool NoExecStack,
|
bool RelaxAll, bool NoExecStack,
|
||||||
|
@ -427,6 +427,12 @@ extern "C" void LLVMInitializeARMTargetMC() {
|
|||||||
TargetRegistry::RegisterAsmStreamer(TheThumbLETarget, createMCAsmStreamer);
|
TargetRegistry::RegisterAsmStreamer(TheThumbLETarget, createMCAsmStreamer);
|
||||||
TargetRegistry::RegisterAsmStreamer(TheThumbBETarget, createMCAsmStreamer);
|
TargetRegistry::RegisterAsmStreamer(TheThumbBETarget, createMCAsmStreamer);
|
||||||
|
|
||||||
|
// Register the null streamer.
|
||||||
|
TargetRegistry::RegisterNullStreamer(TheARMLETarget, createARMNullStreamer);
|
||||||
|
TargetRegistry::RegisterNullStreamer(TheARMBETarget, createARMNullStreamer);
|
||||||
|
TargetRegistry::RegisterNullStreamer(TheThumbLETarget, createARMNullStreamer);
|
||||||
|
TargetRegistry::RegisterNullStreamer(TheThumbBETarget, createARMNullStreamer);
|
||||||
|
|
||||||
// Register the MCInstPrinter.
|
// Register the MCInstPrinter.
|
||||||
TargetRegistry::RegisterMCInstPrinter(TheARMLETarget, createARMMCInstPrinter);
|
TargetRegistry::RegisterMCInstPrinter(TheARMLETarget, createARMMCInstPrinter);
|
||||||
TargetRegistry::RegisterMCInstPrinter(TheARMBETarget, createARMMCInstPrinter);
|
TargetRegistry::RegisterMCInstPrinter(TheARMBETarget, createARMMCInstPrinter);
|
||||||
|
@ -51,6 +51,8 @@ MCStreamer *createMCAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS,
|
|||||||
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
MCInstPrinter *InstPrint, MCCodeEmitter *CE,
|
||||||
MCAsmBackend *TAB, bool ShowInst);
|
MCAsmBackend *TAB, bool ShowInst);
|
||||||
|
|
||||||
|
MCStreamer *createARMNullStreamer(MCContext &Ctx);
|
||||||
|
|
||||||
MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
|
MCCodeEmitter *createARMLEMCCodeEmitter(const MCInstrInfo &MCII,
|
||||||
const MCRegisterInfo &MRI,
|
const MCRegisterInfo &MRI,
|
||||||
const MCSubtargetInfo &STI,
|
const MCSubtargetInfo &STI,
|
||||||
|
@ -40,78 +40,34 @@ void ARMTargetStreamer::finish() { ConstantPools->emitAll(Streamer); }
|
|||||||
|
|
||||||
// The remaining callbacks should be handled separately by each
|
// The remaining callbacks should be handled separately by each
|
||||||
// streamer.
|
// streamer.
|
||||||
void ARMTargetStreamer::emitFnStart() {
|
void ARMTargetStreamer::emitFnStart() {}
|
||||||
llvm_unreachable("unimplemented");
|
void ARMTargetStreamer::emitFnEnd() {}
|
||||||
}
|
void ARMTargetStreamer::emitCantUnwind() {}
|
||||||
void ARMTargetStreamer::emitFnEnd() {
|
void ARMTargetStreamer::emitPersonality(const MCSymbol *Personality) {}
|
||||||
llvm_unreachable("unimplemented");
|
void ARMTargetStreamer::emitPersonalityIndex(unsigned Index) {}
|
||||||
}
|
void ARMTargetStreamer::emitHandlerData() {}
|
||||||
void ARMTargetStreamer::emitCantUnwind() {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitPersonality(const MCSymbol *Personality) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitPersonalityIndex(unsigned Index) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitHandlerData() {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
|
void ARMTargetStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
|
||||||
int64_t Offset) {
|
int64_t Offset) {}
|
||||||
llvm_unreachable("unimplemented");
|
void ARMTargetStreamer::emitMovSP(unsigned Reg, int64_t Offset) {}
|
||||||
}
|
void ARMTargetStreamer::emitPad(int64_t Offset) {}
|
||||||
void ARMTargetStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
|
void ARMTargetStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
|
||||||
llvm_unreachable("unimplemented");
|
bool isVector) {}
|
||||||
}
|
void ARMTargetStreamer::emitUnwindRaw(int64_t StackOffset,
|
||||||
void ARMTargetStreamer::emitPad(int64_t Offset) {
|
const SmallVectorImpl<uint8_t> &Opcodes) {
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void
|
|
||||||
ARMTargetStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
|
|
||||||
bool isVector) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitUnwindRaw(
|
|
||||||
int64_t StackOffset, const SmallVectorImpl<uint8_t> &Opcodes) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::switchVendor(StringRef Vendor) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
}
|
||||||
|
void ARMTargetStreamer::switchVendor(StringRef Vendor) {}
|
||||||
|
void ARMTargetStreamer::emitAttribute(unsigned Attribute, unsigned Value) {}
|
||||||
void ARMTargetStreamer::emitTextAttribute(unsigned Attribute,
|
void ARMTargetStreamer::emitTextAttribute(unsigned Attribute,
|
||||||
StringRef String) {
|
StringRef String) {}
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitIntTextAttribute(unsigned Attribute,
|
void ARMTargetStreamer::emitIntTextAttribute(unsigned Attribute,
|
||||||
unsigned IntValue,
|
unsigned IntValue,
|
||||||
StringRef StringValue) {
|
StringRef StringValue) {}
|
||||||
llvm_unreachable("unimplemented");
|
void ARMTargetStreamer::emitArch(unsigned Arch) {}
|
||||||
}
|
void ARMTargetStreamer::emitObjectArch(unsigned Arch) {}
|
||||||
void ARMTargetStreamer::emitArch(unsigned Arch) {
|
void ARMTargetStreamer::emitFPU(unsigned FPU) {}
|
||||||
llvm_unreachable("unimplemented");
|
void ARMTargetStreamer::finishAttributeSection() {}
|
||||||
}
|
void ARMTargetStreamer::emitInst(uint32_t Inst, char Suffix) {}
|
||||||
void ARMTargetStreamer::emitObjectArch(unsigned Arch) {
|
void
|
||||||
llvm_unreachable("unimplemented");
|
ARMTargetStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) {}
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitFPU(unsigned FPU) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::finishAttributeSection() {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::emitInst(uint32_t Inst, char Suffix) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
void ARMTargetStreamer::AnnotateTLSDescriptorSequence(
|
|
||||||
const MCSymbolRefExpr *SRE) {
|
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ARMTargetStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
|
void ARMTargetStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {}
|
||||||
llvm_unreachable("unimplemented");
|
|
||||||
}
|
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
; Also test that the null streamer doesn't crash with debug info.
|
; Also test that the null streamer doesn't crash with debug info.
|
||||||
; RUN: %llc_dwarf -O0 -filetype=null < %s
|
; RUN: %llc_dwarf -O0 -filetype=null < %s
|
||||||
|
|
||||||
|
; Test the null streamer with a terget streamer too.
|
||||||
|
; RUN: llc -O0 -filetype=null -mtriple=arm-linux < %s
|
||||||
|
|
||||||
; generated from the following source compiled to bitcode with clang -g -O1
|
; generated from the following source compiled to bitcode with clang -g -O1
|
||||||
; static int i;
|
; static int i;
|
||||||
; int main() {
|
; int main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user