diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -782,6 +782,7 @@ return VariableDie; const DIExpression *Expr = DV.getSingleExpression(); assert(Expr && "Variadic Debug Value must have an Expression."); + DIELoc *Loc = new (DIEValueAllocator) DIELoc; DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc); DwarfExpr.addFragmentOffset(Expr); @@ -789,7 +790,7 @@ const TargetRegisterInfo &TRI = *Asm->MF->getSubtarget().getRegisterInfo(); auto AddEntry = [&](const DbgValueLocEntry &Entry, - DIExpressionCursor &Cursor) { + DIExpressionCursor &Cursor) { if (Entry.isLocation()) { if (!DwarfExpr.addMachineRegExpression(TRI, Cursor, Entry.getLoc().getReg())) @@ -799,9 +800,13 @@ DwarfExpr.addUnsignedConstant(Entry.getInt()); } else if (Entry.isConstantFP()) { APInt RawBytes = Entry.getConstantFP()->getValueAPF().bitcastToAPInt(); + if (RawBytes.getBitWidth() > 64) + return false; DwarfExpr.addUnsignedConstant(RawBytes); } else if (Entry.isConstantInt()) { APInt RawBytes = Entry.getConstantInt()->getValue(); + if (RawBytes.getBitWidth() > 64) + return false; DwarfExpr.addUnsignedConstant(RawBytes); } else if (Entry.isTargetIndexLocation()) { TargetIndexLocation Loc = Entry.getTargetIndexLocation(); diff --git a/llvm/test/DebugInfo/X86/pr52584.ll b/llvm/test/DebugInfo/X86/pr52584.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/X86/pr52584.ll @@ -0,0 +1,27 @@ +; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu -o /dev/null + +define dso_local void @test() !dbg !4 { +entry: + call void @llvm.dbg.value(metadata !DIArgList(i128 0), metadata !8, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_stack_value, DW_OP_LLVM_fragment, 0, 127)), !dbg !13 + ret void, !dbg !13 +} + +declare void @llvm.dbg.value(metadata, metadata, metadata) + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!2, !3} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "test.c", directory: "") +!2 = !{i32 7, !"Dwarf Version", i32 4} +!3 = !{i32 2, !"Debug Info Version", i32 3} +!4 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 1, type: !6, unit: !0) +!5 = !DIFile(filename: "/usr/local/google/home/rickyz/l/pr52333/n.c", directory: "") +!6 = !DISubroutineType(types: !7) +!7 = !{null} +!8 = !DILocalVariable(name: "arr", scope: !4, file: !5, line: 1, type: !9) +!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 128, elements: !11) +!10 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) +!11 = !{!12} +!12 = !DISubrange(count: 16) +!13 = !DILocation(line: 1, column: 1, scope: !4)