From: Devang Patel Date: Fri, 12 Mar 2010 19:18:30 +0000 (+0000) Subject: Fix llc crash on invalid input. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b45fb90b20759cca798423ec6e53ac5fca3b9af3;p=oota-llvm.git Fix llc crash on invalid input. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98369 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp index f175907e5d1..8eaeeacd39b 100644 --- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp +++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp @@ -358,6 +358,13 @@ void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { } else printOperand(MI, 0); } else { + if (MI->getOperand(0).getType()==MachineOperand::MO_Register && + MI->getOperand(0).getReg()==0) { + // Suppress offset in this case, it is not meaningful. + O << "undef"; + OutStreamer.AddBlankLine(); + return; + } // Frame address. Currently handles register +- offset only. assert(MI->getOperand(0).getType()==MachineOperand::MO_Register); assert(MI->getOperand(3).getType()==MachineOperand::MO_Immediate); diff --git a/test/DebugInfo/2010-03-12-llc-crash.ll b/test/DebugInfo/2010-03-12-llc-crash.ll new file mode 100644 index 00000000000..f6de2349585 --- /dev/null +++ b/test/DebugInfo/2010-03-12-llc-crash.ll @@ -0,0 +1,20 @@ +; RUN: llc -O0 < %s -o /dev/null +; llc should not crash on this invalid input. +; PR6588 +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +define void @foo() { +entry: + call void @llvm.dbg.declare(metadata !{i32* undef}, metadata !0) + ret void +} + +!0 = metadata !{i32 524545, metadata !1, metadata !"sy", metadata !2, i32 890, metadata !7} ; [ DW_TAG_arg_variable ] +!1 = metadata !{i32 524334, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"foo", metadata !2, i32 892, metadata !4, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ] +!2 = metadata !{i32 524329, metadata !"qpainter.h", metadata !"QtGui", metadata !3} ; [ DW_TAG_file_type ] +!3 = metadata !{i32 524305, i32 0, i32 4, metadata !"splineeditor.cpp", metadata !"editor", metadata !"clang 1.1", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!4 = metadata !{i32 524309, metadata !5, metadata !"", metadata !5, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !6, i32 0, null} ; [ DW_TAG_subroutine_type ] +!5 = metadata !{i32 524329, metadata !"splineeditor.cpp", metadata !"src", metadata !3} ; [ DW_TAG_file_type ] +!6 = metadata !{null} +!7 = metadata !{i32 524324, metadata !5, metadata !"int", metadata !5, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +