Index: clang/test/Misc/x86-emit-codegen-only.c =================================================================== --- /dev/null +++ clang/test/Misc/x86-emit-codegen-only.c @@ -0,0 +1,5 @@ +// REQUIRES: x86-registered-target +// RUN: %clang_cc1 -triple i386-pc-win32 -gcodeview -debug-info-kind=standalone -emit-codegen-only %s + +// TargetStreamer is used in emitFunctionBodyStart/emitFunctionBodyEnd for codeview. +void foo() {} Index: llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp =================================================================== --- llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -16,6 +16,7 @@ #include "X86BaseInfo.h" #include "X86IntelInstPrinter.h" #include "X86MCAsmInfo.h" +#include "X86TargetStreamer.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/Triple.h" #include "llvm/DebugInfo/CodeView/CodeView.h" @@ -722,6 +723,9 @@ // Register the asm target streamer. TargetRegistry::RegisterAsmTargetStreamer(*T, createX86AsmTargetStreamer); + // Register the null streamer. + TargetRegistry::RegisterNullTargetStreamer(*T, createX86NullTargetStreamer); + TargetRegistry::RegisterCOFFStreamer(*T, createX86WinCOFFStreamer); // Register the MCInstPrinter. Index: llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h =================================================================== --- llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h +++ llvm/lib/Target/X86/MCTargetDesc/X86TargetStreamer.h @@ -19,16 +19,27 @@ X86TargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {} virtual bool emitFPOProc(const MCSymbol *ProcSym, unsigned ParamsSize, - SMLoc L = {}) = 0; - virtual bool emitFPOEndPrologue(SMLoc L = {}) = 0; - virtual bool emitFPOEndProc(SMLoc L = {}) = 0; - virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L = {}) = 0; - virtual bool emitFPOPushReg(unsigned Reg, SMLoc L = {}) = 0; - virtual bool emitFPOStackAlloc(unsigned StackAlloc, SMLoc L = {}) = 0; - virtual bool emitFPOStackAlign(unsigned Align, SMLoc L = {}) = 0; - virtual bool emitFPOSetFrame(unsigned Reg, SMLoc L = {}) = 0; + SMLoc L = {}) { + return false; + } + virtual bool emitFPOEndPrologue(SMLoc L = {}) { return false; } + virtual bool emitFPOEndProc(SMLoc L = {}) { return false; }; + virtual bool emitFPOData(const MCSymbol *ProcSym, SMLoc L = {}) { + return false; + } + virtual bool emitFPOPushReg(unsigned Reg, SMLoc L = {}) { return false; } + virtual bool emitFPOStackAlloc(unsigned StackAlloc, SMLoc L = {}) { + return false; + } + virtual bool emitFPOStackAlign(unsigned Align, SMLoc L = {}) { return false; } + virtual bool emitFPOSetFrame(unsigned Reg, SMLoc L = {}) { return false; } }; +/// Implements X86-only null emission. +inline MCTargetStreamer *createX86NullTargetStreamer(MCStreamer &S) { + return new X86TargetStreamer(S); +} + } // end namespace llvm #endif Index: llvm/lib/Target/X86/X86AsmPrinter.cpp =================================================================== --- llvm/lib/Target/X86/X86AsmPrinter.cpp +++ llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -98,19 +98,19 @@ void X86AsmPrinter::emitFunctionBodyStart() { if (EmitFPOData) { - if (auto *XTS = - static_cast(OutStreamer->getTargetStreamer())) - XTS->emitFPOProc( - CurrentFnSym, - MF->getInfo()->getArgumentStackSize()); + auto *XTS = + static_cast(OutStreamer->getTargetStreamer()); + XTS->emitFPOProc( + CurrentFnSym, + MF->getInfo()->getArgumentStackSize()); } } void X86AsmPrinter::emitFunctionBodyEnd() { if (EmitFPOData) { - if (auto *XTS = - static_cast(OutStreamer->getTargetStreamer())) - XTS->emitFPOEndProc(); + auto *XTS = + static_cast(OutStreamer->getTargetStreamer()); + XTS->emitFPOEndProc(); } }