From 0db8cb01472f483ec676c9fc91f3d738365b1bb8 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 15 Nov 2018 15:17:15 +0000 Subject: [PATCH] [X86] Fix MCNullStreamer support for modules with a CodeView flag This fixes -filetype=null support when compiling for a Win32 target and the module has a CodeView flag. The only places changed are the uses of getTargetStreamer function - this patch guards both of them with null checks. Committed on behalf of @eush (Eugene Sharygin) Differential Revision: https://reviews.llvm.org/D54008 llvm-svn: 346962 --- llvm/lib/Target/X86/X86AsmPrinter.cpp | 16 ++++++++-------- llvm/test/CodeGen/X86/null-streamer.ll | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp index 74dbdcd27930..b164b4e1fcf5 100644 --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -88,19 +88,19 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) { void X86AsmPrinter::EmitFunctionBodyStart() { if (EmitFPOData) { - X86TargetStreamer *XTS = - static_cast(OutStreamer->getTargetStreamer()); - unsigned ParamsSize = - MF->getInfo()->getArgumentStackSize(); - XTS->emitFPOProc(CurrentFnSym, ParamsSize); + if (auto *XTS = + static_cast(OutStreamer->getTargetStreamer())) + XTS->emitFPOProc( + CurrentFnSym, + MF->getInfo()->getArgumentStackSize()); } } void X86AsmPrinter::EmitFunctionBodyEnd() { if (EmitFPOData) { - X86TargetStreamer *XTS = - static_cast(OutStreamer->getTargetStreamer()); - XTS->emitFPOEndProc(); + if (auto *XTS = + static_cast(OutStreamer->getTargetStreamer())) + XTS->emitFPOEndProc(); } } diff --git a/llvm/test/CodeGen/X86/null-streamer.ll b/llvm/test/CodeGen/X86/null-streamer.ll index 8528be3ca593..28a457f64d4a 100644 --- a/llvm/test/CodeGen/X86/null-streamer.ll +++ b/llvm/test/CodeGen/X86/null-streamer.ll @@ -14,7 +14,7 @@ define void @f1() { } !llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!7, !8} +!llvm.module.flags = !{!7, !8, !9} !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: " ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !3, imports: !2) !1 = !DIFile(filename: "file.c", directory: "") @@ -25,4 +25,4 @@ define void @f1() { !6 = !DIBasicType(size: 32, align: 32, encoding: DW_ATE_signed) !7 = !{i32 2, !"Dwarf Version", i32 3} !8 = !{i32 1, !"Debug Info Version", i32 3} - +!9 = !{i32 2, !"CodeView", i32 1}