[llvm] 68f97d2 - LiveDebugValues: Fix another crash related to unreachable blocks
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 9 10:35:59 PDT 2022
Author: Adrian Prantl
Date: 2022-08-09T10:34:57-07:00
New Revision: 68f97d2f787507eba56c667585fc31db3c27c469
URL: https://github.com/llvm/llvm-project/commit/68f97d2f787507eba56c667585fc31db3c27c469
DIFF: https://github.com/llvm/llvm-project/commit/68f97d2f787507eba56c667585fc31db3c27c469.diff
LOG: LiveDebugValues: Fix another crash related to unreachable blocks
This is a follow-up patch to D130999. In the test, the MIR contains an
unreachable MBB but the code attempts to look it up in MLocs. This
patch fixes this issue by checking for the default-constructed value.
rdar://97226240
Differential Revision: https://reviews.llvm.org/D131453
Added:
llvm/test/DebugInfo/MIR/X86/ldv_unreachable_blocks2.mir
Modified:
llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 968283eb14c96..aa3e7a39cf14f 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -297,6 +297,8 @@ class TransferTracker {
for (auto Location : MTracker->locations()) {
LocIdx Idx = Location.Idx;
ValueIDNum &VNum = MLocs[Idx.asU64()];
+ if (VNum == ValueIDNum::EmptyValue)
+ continue;
VarLocs.push_back(VNum);
// Is there a variable that wants a location for this value? If not, skip.
diff --git a/llvm/test/DebugInfo/MIR/X86/ldv_unreachable_blocks2.mir b/llvm/test/DebugInfo/MIR/X86/ldv_unreachable_blocks2.mir
new file mode 100644
index 0000000000000..d1fbb251fb228
--- /dev/null
+++ b/llvm/test/DebugInfo/MIR/X86/ldv_unreachable_blocks2.mir
@@ -0,0 +1,32 @@
+# RUN: llc -mtriple=x86_64-apple-macos %s -start-before=livedebugvalues -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
+# CHECK: DW_TAG_subprogram
+# Test that LiveDebugValues can handle MBBs that are not reachable in a RPOT.
+--- |
+ define hidden zeroext i1 @__foo_block_invoke(i8* nocapture noundef readonly %.block_descriptor, i64 noundef %type) !dbg !7 {
+ entry:
+ unreachable
+ do.body.i129.i: ; preds = %if.else6.i128.i
+ unreachable
+ }
+ !llvm.dbg.cu = !{!3}
+ !llvm.module.flags = !{!5, !6}
+ !2 = !{}
+ !3 = distinct !DICompileUnit(language: DW_LANG_C99, file: !4, producer: "clang", runtimeVersion: 0, emissionKind: FullDebug)
+ !4 = !DIFile(filename: "t.c", directory: "/")
+ !5 = !{i32 2, !"Debug Info Version", i32 3}
+ !6 = !{i32 1, !"LTOPostLink", i32 1}
+ !7 = distinct !DISubprogram(name: "__foo_block_invoke", scope: !4, file: !4, line: 573, type: !9, scopeLine: 573, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !3, retainedNodes: !2)
+ !9 = !DISubroutineType(types: !2)
+ !11 = !DILocalVariable(name: ".block_descriptor", arg: 1, scope: !7, file: !4, line: 557, type: !12, flags: DIFlagArtificial)
+ !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
+ !13 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_1", scope: !4, file: !4, line: 557, size: 392, elements: !2)
+ !15 = !DILocation(line: 558, column: 7, scope: !7)
+name: __foo_block_invoke
+body: |
+ bb.0.entry:
+ DBG_VALUE $rdi, $noreg, !11, !DIExpression(), debug-location !15
+ $ecx = MOV32rr undef $edi, implicit $dil, debug-location !15
+ bb.2:
+ successors:
+ TRAP
+ bb.21.do.body.i129.i (address-taken):
More information about the llvm-commits
mailing list