Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/X86/ghost-sdnode-dbgvalues.ll

raw
1 ; REQUIRES: object-emission
2
3 ; RUN: llvm-as < %s -o %t.bc
4 ; RUN: llvm-spirv %t.bc -o %t.spv
5 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
6
7 ; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 -o %t %t.ll
8
9 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
10 target triple = "spir64-unknown-unknown"
11
12 ; Testcase generated from:
13 ; #include <stdint.h>
14 ; int foo(int a) {
15 ; int b = (int16_t)a + 8;
16 ; int c = (int16_t)b + 8;
17 ; int d = (int16_t)c + 8;
18 ; int e = (int16_t)d + 8;
19 ; int f = (int16_t)e + 8;
20 ; return f;
21 ; }
22 ; by emitting the IR and then manually applying mem2reg to it.
23
24 ; This testcase would trigger the assert commited along with it if the
25 ; fix of r221709 isn't applied. There is no other check except the successful
26 ; run of llc.
27 ; What happened before r221709, is that SDDbgInfo (the data structure helping
28 ; SelectionDAG to keep track of dbg.values) kept a map keyed by SDNode pointers.
29 ; This map was never purged when the SDNodes were deallocated and thus if a new
30 ; SDNode was allocated in the same memory, it would have an entry in the SDDbgInfo
31 ; map upon creation (Reallocation in the same memory can happen easily as
32 ; SelectionDAG uses a Recycling allocator). This behavior could turn into a
33 ; pathological memory consumption explosion if the DAG combiner hit the 'right'
34 ; allocation patterns as could be seen in PR20893.
35 ; By nature, this test could bitrot quite easily. If it doesn't trigger an assert
36 ; when run with r221709 reverted, then it really doesn't test anything anymore.
37
38 ; Function Attrs: nounwind ssp uwtable
39 define i32 @foo(i32 %a) #0 !dbg !8 {
40 entry:
41 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !17), !dbg !18
42 %conv = trunc i32 %a to i16, !dbg !19
43 %conv1 = sext i16 %conv to i32, !dbg !19
44 %add = add nsw i32 %conv1, 8, !dbg !19
45 call void @llvm.dbg.value(metadata i32 %add, metadata !20, metadata !17), !dbg !21
46 %conv2 = trunc i32 %add to i16, !dbg !22
47 %conv3 = sext i16 %conv2 to i32, !dbg !22
48 %add4 = add nsw i32 %conv3, 8, !dbg !22
49 call void @llvm.dbg.value(metadata i32 %add4, metadata !23, metadata !17), !dbg !24
50 %conv5 = trunc i32 %add4 to i16, !dbg !25
51 %conv6 = sext i16 %conv5 to i32, !dbg !25
52 %add7 = add nsw i32 %conv6, 8, !dbg !25
53 call void @llvm.dbg.value(metadata i32 %add7, metadata !26, metadata !17), !dbg !27
54 %conv8 = trunc i32 %add7 to i16, !dbg !28
55 %conv9 = sext i16 %conv8 to i32, !dbg !28
56 %add10 = add nsw i32 %conv9, 8, !dbg !28
57 call void @llvm.dbg.value(metadata i32 %add10, metadata !29, metadata !17), !dbg !30
58 %conv11 = trunc i32 %add10 to i16, !dbg !31
59 %conv12 = sext i16 %conv11 to i32, !dbg !31
60 %add13 = add nsw i32 %conv12, 8, !dbg !31
61 call void @llvm.dbg.value(metadata i32 %add13, metadata !32, metadata !17), !dbg !33
62 ret i32 %add13, !dbg !34
63 }
64
65 ; Function Attrs: nounwind readnone
66 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
67
68 ; Function Attrs: nounwind readnone
69 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
70
71 attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
72 attributes #1 = { nounwind readnone }
73
74 !llvm.dbg.cu = !{!0}
75 !llvm.module.flags = !{!13, !14}
76 !llvm.ident = !{!15}
77
78 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.6.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
79 !1 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp")
80 !2 = !{}
81 !3 = !{!4}
82 !4 = !DIDerivedType(tag: DW_TAG_typedef, name: "int16_t", line: 30, file: !5, baseType: !6)
83 !5 = !DIFile(filename: "/usr/include/sys/_types/_int16_t.h", directory: "/tmp")
84 !6 = !DIBasicType(tag: DW_TAG_base_type, name: "short", size: 16, align: 16, encoding: DW_ATE_signed)
85 !8 = distinct !DISubprogram(name: "foo", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !9, type: !10, retainedNodes: !2)
86 !9 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp")
87 !10 = !DISubroutineType(types: !11)
88 !11 = !{!12, !12}
89 !12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
90 !13 = !{i32 2, !"Dwarf Version", i32 2}
91 !14 = !{i32 2, !"Debug Info Version", i32 3}
92 !15 = !{!"clang version 3.6.0 "}
93 !16 = !DILocalVariable(name: "a", line: 3, arg: 1, scope: !8, file: !9, type: !12)
94 !17 = !DIExpression()
95 !18 = !DILocation(line: 3, column: 13, scope: !8)
96 !19 = !DILocation(line: 4, column: 5, scope: !8)
97 !20 = !DILocalVariable(name: "b", line: 4, scope: !8, file: !9, type: !12)
98 !21 = !DILocation(line: 4, column: 9, scope: !8)
99 !22 = !DILocation(line: 5, column: 5, scope: !8)
100 !23 = !DILocalVariable(name: "c", line: 5, scope: !8, file: !9, type: !12)
101 !24 = !DILocation(line: 5, column: 9, scope: !8)
102 !25 = !DILocation(line: 6, column: 5, scope: !8)
103 !26 = !DILocalVariable(name: "d", line: 6, scope: !8, file: !9, type: !12)
104 !27 = !DILocation(line: 6, column: 9, scope: !8)
105 !28 = !DILocation(line: 7, column: 5, scope: !8)
106 !29 = !DILocalVariable(name: "e", line: 7, scope: !8, file: !9, type: !12)
107 !30 = !DILocation(line: 7, column: 9, scope: !8)
108 !31 = !DILocation(line: 8, column: 5, scope: !8)
109 !32 = !DILocalVariable(name: "f", line: 8, scope: !8, file: !9, type: !12)
110 !33 = !DILocation(line: 8, column: 9, scope: !8)
111 !34 = !DILocation(line: 9, column: 5, scope: !8)