[PATCH] D90345: [DebugInfo] Fix ICE in DwarfCompileUnit::constructSubprogramScopeDIE
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 28 14:14:28 PDT 2020
scott.linder created this revision.
Herald added subscribers: llvm-commits, jdoerfert, hiraditya.
Herald added a project: LLVM.
scott.linder requested review of this revision.
Don't ICE when generating DWARF debug information for a `DISubprogram`
that is missing a `type:`
Alternatively, if the intended invariant is that every `DISubprogram`
must have a `type:`, the verifier would need to be updated instead.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D90345
Files:
llvm/docs/LangRef.rst
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/test/CodeGen/Generic/disubprogram-no-type.ll
Index: llvm/test/CodeGen/Generic/disubprogram-no-type.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/disubprogram-no-type.ll
@@ -0,0 +1,16 @@
+; RUN: llc %s -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
+
+; Confirm we don't ICE when generating DWARF debug information for a
+; DISubprogram that is missing a `type:`
+
+; CHECK-NOT: DW_AT_type
+
+define i32 @f(i32 %0) !dbg !3 { ret i32 %0 }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: 0, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "-", directory: "")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = distinct !DISubprogram(file: !1, unit: !0)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -927,15 +927,17 @@
}
// If this is a variadic function, add an unspecified parameter.
- DITypeRefArray FnArgs = Sub->getType()->getTypeArray();
-
- // If we have a single element of null, it is a function that returns void.
- // If we have more than one elements and the last one is null, it is a
- // variadic function.
- if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
- !includeMinimalInlineScopes())
- ScopeDIE.addChild(
- DIE::get(DIEValueAllocator, dwarf::DW_TAG_unspecified_parameters));
+ if (DISubroutineType *FnType = Sub->getType()) {
+ DITypeRefArray FnArgs = FnType->getTypeArray();
+
+ // If we have a single element of null, it is a function that returns void.
+ // If we have more than one elements and the last one is null, it is a
+ // variadic function.
+ if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
+ !includeMinimalInlineScopes())
+ ScopeDIE.addChild(
+ DIE::get(DIEValueAllocator, dwarf::DW_TAG_unspecified_parameters));
+ }
return ScopeDIE;
}
Index: llvm/docs/LangRef.rst
===================================================================
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -5084,7 +5084,8 @@
used for call site debug info. The ``retainedNodes:`` field is a list of
:ref:`variables <DILocalVariable>` and :ref:`labels <DILabel>` that must be
retained, even if their IR counterparts are optimized out of the IR. The
-``type:`` field must point at an :ref:`DISubroutineType`.
+``type:`` field is optional, but if present it must point at a
+:ref:`DISubroutineType`.
.. _DISubprogramDeclaration:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90345.301429.patch
Type: text/x-patch
Size: 2605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201028/2f2040b0/attachment.bin>
More information about the llvm-commits
mailing list