Skip to content

Commit 0db8cb0

Browse files
committed
[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
1 parent 35f3da1 commit 0db8cb0

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,19 +88,19 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
8888

8989
void X86AsmPrinter::EmitFunctionBodyStart() {
9090
if (EmitFPOData) {
91-
X86TargetStreamer *XTS =
92-
static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
93-
unsigned ParamsSize =
94-
MF->getInfo<X86MachineFunctionInfo>()->getArgumentStackSize();
95-
XTS->emitFPOProc(CurrentFnSym, ParamsSize);
91+
if (auto *XTS =
92+
static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer()))
93+
XTS->emitFPOProc(
94+
CurrentFnSym,
95+
MF->getInfo<X86MachineFunctionInfo>()->getArgumentStackSize());
9696
}
9797
}
9898

9999
void X86AsmPrinter::EmitFunctionBodyEnd() {
100100
if (EmitFPOData) {
101-
X86TargetStreamer *XTS =
102-
static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
103-
XTS->emitFPOEndProc();
101+
if (auto *XTS =
102+
static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer()))
103+
XTS->emitFPOEndProc();
104104
}
105105
}
106106

llvm/test/CodeGen/X86/null-streamer.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ define void @f1() {
1414
}
1515

1616
!llvm.dbg.cu = !{!0}
17-
!llvm.module.flags = !{!7, !8}
17+
!llvm.module.flags = !{!7, !8, !9}
1818

1919
!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)
2020
!1 = !DIFile(filename: "file.c", directory: "")
@@ -25,4 +25,4 @@ define void @f1() {
2525
!6 = !DIBasicType(size: 32, align: 32, encoding: DW_ATE_signed)
2626
!7 = !{i32 2, !"Dwarf Version", i32 3}
2727
!8 = !{i32 1, !"Debug Info Version", i32 3}
28-
28+
!9 = !{i32 2, !"CodeView", i32 1}

0 commit comments

Comments
 (0)