diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -767,6 +767,11 @@ if (!MI.isCandidateForCallSiteEntry()) continue; + // Skip instructions marked as frame setup, as they are not interesting to + // the user. + if (MI.getFlag(MachineInstr::FrameSetup)) + continue; + // TODO: Add support for targets with delay slots (see: beginInstruction). if (MI.hasDelaySlot()) return; diff --git a/llvm/test/DebugInfo/RISCV/saverestore.ll b/llvm/test/DebugInfo/RISCV/saverestore.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/RISCV/saverestore.ll @@ -0,0 +1,28 @@ +; RUN: llc -mtriple=riscv32 -mattr=+save-restore < %s + +; Ensure that the addition of framesetup instructions which call save/restore +; libcalls do not cause a crash when DIFlagAllCallsDescribed is set. + +define i32 @main() noreturn nounwind !dbg !7 { +entry: + tail call void @exit(i32 0) + unreachable +} + +declare void @exit(i32) noreturn + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "saverestore.c", directory: ".") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 5} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{!"clang"} +!7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2) +!8 = !DISubroutineType(types: !9) +!9 = !{!10} +!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)