diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -325,7 +325,7 @@ const MachineFunction *CurFn = nullptr; /// If nonnull, stores the CU in which the previous subprogram was contained. - const DwarfCompileUnit *PrevCU; + const DwarfCompileUnit *PrevCU = nullptr; /// As an optimization, there is no need to emit an entry in the directory /// table for the same directory as DW_AT_comp_dir. diff --git a/llvm/test/DebugInfo/ARM/undef-behavior-in-debug-dwarf-debug.ll b/llvm/test/DebugInfo/ARM/undef-behavior-in-debug-dwarf-debug.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/ARM/undef-behavior-in-debug-dwarf-debug.ll @@ -0,0 +1,41 @@ +; RUN: valgrind --error-exitcode=1 llc --filetype=obj %s -o - +target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" +target triple = "armv7-unknown-linux-android" + +; Function Attrs: norecurse nounwind readnone +define hidden i32 @add(i32 %0, i32 %1) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 %0, metadata !14, metadata !DIExpression()), !dbg !16 + call void @llvm.dbg.value(metadata i32 %1, metadata !15, metadata !DIExpression()), !dbg !16 + %3 = add nsw i32 %1, %0, !dbg !17 + ret i32 %3, !dbg !18 +} + +; Function Attrs: nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) #1 + +attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+armv7-a,+d32,+dsp,+fp64,+neon,+vfp2,+vfp2sp,+vfp3,+vfp3d16,+vfp3d16sp,+vfp3sp,-crypto,-fp-armv8,-fp-armv8d16,-fp-armv8d16sp,-fp-armv8sp,-fp16,-fp16fml,-fullfp16,-thumb-mode,-vfp4,-vfp4d16,-vfp4d16sp,-vfp4sp" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #1 = { nounwind readnone speculatable willreturn } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6, !7} +!llvm.ident = !{!8} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "1.c", directory: "/tmp") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 1, !"min_enum_size", i32 4} +!7 = !{i32 7, !"PIC Level", i32 2} +!8 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 6dd738e2f0609f7d3313b574a1d471263d2d3ba1)"} +!9 = distinct !DISubprogram(name: "add", scope: !1, file: !1, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) +!10 = !DISubroutineType(types: !11) +!11 = !{!12, !12, !12} +!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!13 = !{!14, !15} +!14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 1, type: !12) +!15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 1, type: !12) +!16 = !DILocation(line: 0, scope: !9) +!17 = !DILocation(line: 2, column: 12, scope: !9) +!18 = !DILocation(line: 2, column: 3, scope: !9)