Skip to content

Commit 97088b2

Browse files
authored
[RemoveDIs][ValueMapper] Remap DIAssignIDs in DPValues (#81595)
Fix crash raised in comments for 5c9f768
1 parent e79ad7b commit 97088b2

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

llvm/lib/Transforms/Utils/ValueMapper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ void Mapper::remapDPValue(DPValue &V) {
552552
V.setKillAddress();
553553
else if (NewAddr)
554554
V.setAddress(NewAddr);
555+
V.setAssignId(cast<DIAssignID>(mapMetadata(V.getAssignID())));
555556
}
556557

557558
// Find Value operands and remap those.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
; RUN: opt -passes=ipsccp %s -S -o - | FileCheck %s
2+
; RUN: opt --try-experimental-debuginfo-iterators -passes=ipsccp %s -S -o - | FileCheck %s
3+
4+
;; Check the dbg.assign DIAssignID operand gets remapped after cloning.
5+
6+
; CHECK: %tmp = alloca [4096 x i32], i32 0, align 16, !DIAssignID ![[ID1:[0-9]+]]
7+
; CHECK-NEXT: dbg.assign(metadata i1 undef, metadata !{{.*}}, metadata !DIExpression(), metadata ![[ID1]], metadata ptr %tmp, metadata !DIExpression())
8+
;
9+
; CHECK: %tmp = alloca [4096 x i32], i32 0, align 16, !DIAssignID ![[ID2:[0-9]+]]
10+
; CHECK-NEXT: dbg.assign(metadata i1 undef, metadata !{{.*}}, metadata !DIExpression(), metadata ![[ID2]], metadata ptr %tmp, metadata !DIExpression())
11+
12+
; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
13+
declare void @llvm.dbg.declare(metadata, metadata, metadata)
14+
15+
define void @inv_txfm_add_dct_dct_4x4_c() {
16+
entry:
17+
call void @inv_txfm_add_c(ptr @dav1d_inv_dct4_1d_c)
18+
ret void
19+
}
20+
21+
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)
22+
23+
; Function Attrs: noinline
24+
define void @inv_txfm_add_c(ptr %first_1d_fn) #2 {
25+
entry:
26+
%tmp = alloca [4096 x i32], i32 0, align 16, !DIAssignID !5
27+
tail call void @llvm.dbg.assign(metadata i1 undef, metadata !6, metadata !DIExpression(), metadata !5, metadata ptr %tmp, metadata !DIExpression()), !dbg !16
28+
call void @llvm.memset.p0.i64(ptr %tmp, i8 0, i64 0, i1 false), !DIAssignID !17
29+
call void %first_1d_fn(ptr null, i64 0, i32 0, i32 0)
30+
ret void
31+
}
32+
33+
declare void @dav1d_inv_dct4_1d_c(ptr, i64, i32, i32)
34+
35+
declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata)
36+
37+
attributes #2 = { noinline }
38+
39+
!llvm.dbg.cu = !{!0}
40+
!llvm.module.flags = !{!3, !4}
41+
42+
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, splitDebugInlining: false, nameTableKind: GNU)
43+
!1 = !DIFile(filename: "itx_tmpl.c", directory: ".")
44+
!2 = !{}
45+
!3 = !{i32 2, !"Debug Info Version", i32 3}
46+
!4 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
47+
!5 = distinct !DIAssignID()
48+
!6 = !DILocalVariable(name: "tmp", scope: !7, file: !1, line: 78, type: !10)
49+
!7 = distinct !DISubprogram(name: "inv_txfm_add_c", scope: !1, file: !1, line: 41, type: !8, scopeLine: 45, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
50+
!8 = distinct !DISubroutineType(types: !9)
51+
!9 = !{null}
52+
!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 131072, elements: !2)
53+
!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "int32_t", file: !12, line: 26, baseType: !13)
54+
!12 = !DIFile(filename: "stdint-intn.h", directory: ".")
55+
!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int32_t", file: !14, line: 41, baseType: !15)
56+
!14 = !DIFile(filename: "types.h", directory: ".")
57+
!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
58+
!16 = !DILocation(line: 0, scope: !7)
59+
!17 = distinct !DIAssignID()

0 commit comments

Comments
 (0)