Skip to content

Commit 2131501

Browse files
committed
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 (cherry picked from commit 68f97d2)
1 parent 8e9875f commit 2131501

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ class TransferTracker {
318318
for (auto Location : MTracker->locations()) {
319319
LocIdx Idx = Location.Idx;
320320
ValueIDNum &VNum = MLocs[Idx.asU64()];
321+
if (VNum == ValueIDNum::EmptyValue)
322+
continue;
321323
VarLocs.push_back(VNum);
322324

323325
// Is there a variable that wants a location for this value? If not, skip.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# RUN: llc -mtriple=x86_64-apple-macos %s -start-before=livedebugvalues -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
2+
# CHECK: DW_TAG_subprogram
3+
# Test that LiveDebugValues can handle MBBs that are not reachable in a RPOT.
4+
--- |
5+
define hidden zeroext i1 @__foo_block_invoke(i8* nocapture noundef readonly %.block_descriptor, i64 noundef %type) !dbg !7 {
6+
entry:
7+
unreachable
8+
do.body.i129.i: ; preds = %if.else6.i128.i
9+
unreachable
10+
}
11+
!llvm.dbg.cu = !{!3}
12+
!llvm.module.flags = !{!5, !6}
13+
!2 = !{}
14+
!3 = distinct !DICompileUnit(language: DW_LANG_C99, file: !4, producer: "clang", runtimeVersion: 0, emissionKind: FullDebug)
15+
!4 = !DIFile(filename: "t.c", directory: "/")
16+
!5 = !{i32 2, !"Debug Info Version", i32 3}
17+
!6 = !{i32 1, !"LTOPostLink", i32 1}
18+
!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)
19+
!9 = !DISubroutineType(types: !2)
20+
!11 = !DILocalVariable(name: ".block_descriptor", arg: 1, scope: !7, file: !4, line: 557, type: !12, flags: DIFlagArtificial)
21+
!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !13, size: 64)
22+
!13 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_1", scope: !4, file: !4, line: 557, size: 392, elements: !2)
23+
!15 = !DILocation(line: 558, column: 7, scope: !7)
24+
name: __foo_block_invoke
25+
body: |
26+
bb.0.entry:
27+
DBG_VALUE $rdi, $noreg, !11, !DIExpression(), debug-location !15
28+
$ecx = MOV32rr undef $edi, implicit $dil, debug-location !15
29+
bb.2:
30+
successors:
31+
TRAP
32+
bb.21.do.body.i129.i (address-taken):

0 commit comments

Comments
 (0)