[llvm] a6bd125 - [DebugInfo] Call site entries cannot be generated for FrameSetup calls

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 11 13:25:53 PST 2020


Author: lewis-revill
Date: 2020-02-11T21:23:18Z
New Revision: a6bd1256ce8ae5d5faf66a2ed198e0bc8674ee97

URL: https://github.com/llvm/llvm-project/commit/a6bd1256ce8ae5d5faf66a2ed198e0bc8674ee97
DIFF: https://github.com/llvm/llvm-project/commit/a6bd1256ce8ae5d5faf66a2ed198e0bc8674ee97.diff

LOG: [DebugInfo] Call site entries cannot be generated for FrameSetup calls

Instructions marked as FrameSetup do not cause requestLabelAfterInsn to
be called and so no such label is generated. Call instructions which
require call site entries to be generated require this label to be
present in order to calculate the return PC offset/address, but the
check for whether the call instruction is marked as FrameSetup was not
present.

Therefore in the case where a call instruction is marked as FrameSetup,
an assertion failure occurs if a call site entry is to be generated.
This is the case with RISC-V's implementation of save/restore via
library calls.

Differential Revision: https://reviews.llvm.org/D71593

Added: 
    llvm/test/DebugInfo/RISCV/saverestore.ll

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index fd27f241d808..c1e7d9fe0211 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -767,6 +767,11 @@ void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
       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
index 000000000000..77ece5e55ac5
--- /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)


        


More information about the llvm-commits mailing list