blob: 9164525f761b8d1c0dc928e1e6b26a4d128d5258 [file] [log] [blame]
Frederic Riss0f7abef2014-11-13 03:20:23 +00001; REQUIRES: object-emission
2
3; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 -o %t %s
4
5; Testcase generated from:
6; #include <stdint.h>
7; int foo(int a) {
8; int b = (int16_t)a + 8;
9; int c = (int16_t)b + 8;
10; int d = (int16_t)c + 8;
11; int e = (int16_t)d + 8;
12; int f = (int16_t)e + 8;
13; return f;
14; }
15; by emitting the IR and then manually applying mem2reg to it.
16
17; This testcase would trigger the assert commited along with it if the
18; fix of r221709 isn't applied. There is no other check except the successful
19; run of llc.
20; What happened before r221709, is that SDDbgInfo (the data structure helping
21; SelectionDAG to keep track of dbg.values) kept a map keyed by SDNode pointers.
22; This map was never purged when the SDNodes were deallocated and thus if a new
23; SDNode was allocated in the same memory, it would have an entry in the SDDbgInfo
24; map upon creation (Reallocation in the same memory can happen easily as
25; SelectionDAG uses a Recycling allocator). This behavior could turn into a
26; pathological memory consumption explosion if the DAG combiner hit the 'right'
27; allocation patterns as could be seen in PR20893.
28; By nature, this test could bitrot quite easily. If it doesn't trigger an assert
29; when run with r221709 reverted, then it really doesn't test anything anymore.
30
31; Function Attrs: nounwind ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000032define i32 @foo(i32 %a) #0 !dbg !8 {
Frederic Riss0f7abef2014-11-13 03:20:23 +000033entry:
Adrian Prantlabe04752017-07-28 20:21:02 +000034 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !17), !dbg !18
Frederic Riss0f7abef2014-11-13 03:20:23 +000035 %conv = trunc i32 %a to i16, !dbg !19
36 %conv1 = sext i16 %conv to i32, !dbg !19
37 %add = add nsw i32 %conv1, 8, !dbg !19
Adrian Prantlabe04752017-07-28 20:21:02 +000038 call void @llvm.dbg.value(metadata i32 %add, metadata !20, metadata !17), !dbg !21
Frederic Riss0f7abef2014-11-13 03:20:23 +000039 %conv2 = trunc i32 %add to i16, !dbg !22
40 %conv3 = sext i16 %conv2 to i32, !dbg !22
41 %add4 = add nsw i32 %conv3, 8, !dbg !22
Adrian Prantlabe04752017-07-28 20:21:02 +000042 call void @llvm.dbg.value(metadata i32 %add4, metadata !23, metadata !17), !dbg !24
Frederic Riss0f7abef2014-11-13 03:20:23 +000043 %conv5 = trunc i32 %add4 to i16, !dbg !25
44 %conv6 = sext i16 %conv5 to i32, !dbg !25
45 %add7 = add nsw i32 %conv6, 8, !dbg !25
Adrian Prantlabe04752017-07-28 20:21:02 +000046 call void @llvm.dbg.value(metadata i32 %add7, metadata !26, metadata !17), !dbg !27
Frederic Riss0f7abef2014-11-13 03:20:23 +000047 %conv8 = trunc i32 %add7 to i16, !dbg !28
48 %conv9 = sext i16 %conv8 to i32, !dbg !28
49 %add10 = add nsw i32 %conv9, 8, !dbg !28
Adrian Prantlabe04752017-07-28 20:21:02 +000050 call void @llvm.dbg.value(metadata i32 %add10, metadata !29, metadata !17), !dbg !30
Frederic Riss0f7abef2014-11-13 03:20:23 +000051 %conv11 = trunc i32 %add10 to i16, !dbg !31
52 %conv12 = sext i16 %conv11 to i32, !dbg !31
53 %add13 = add nsw i32 %conv12, 8, !dbg !31
Adrian Prantlabe04752017-07-28 20:21:02 +000054 call void @llvm.dbg.value(metadata i32 %add13, metadata !32, metadata !17), !dbg !33
Frederic Riss0f7abef2014-11-13 03:20:23 +000055 ret i32 %add13, !dbg !34
56}
57
58; Function Attrs: nounwind readnone
59declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
60
61; Function Attrs: nounwind readnone
Adrian Prantlabe04752017-07-28 20:21:02 +000062declare void @llvm.dbg.value(metadata, metadata, metadata) #1
Frederic Riss0f7abef2014-11-13 03:20:23 +000063
64attributes #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" }
65attributes #1 = { nounwind readnone }
66
67!llvm.dbg.cu = !{!0}
68!llvm.module.flags = !{!13, !14}
69!llvm.ident = !{!15}
70
Adrian Prantl75819ae2016-04-15 15:57:41 +000071!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)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000072!1 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000073!2 = !{}
74!3 = !{!4}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000075!4 = !DIDerivedType(tag: DW_TAG_typedef, name: "int16_t", line: 30, file: !5, baseType: !6)
76!5 = !DIFile(filename: "/usr/include/sys/_types/_int16_t.h", directory: "/tmp")
77!6 = !DIBasicType(tag: DW_TAG_base_type, name: "short", size: 16, align: 16, encoding: DW_ATE_signed)
Adrian Prantl75819ae2016-04-15 15:57:41 +000078!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, variables: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000079!9 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp")
80!10 = !DISubroutineType(types: !11)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000081!11 = !{!12, !12}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000082!12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000083!13 = !{i32 2, !"Dwarf Version", i32 2}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000084!14 = !{i32 2, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000085!15 = !{!"clang version 3.6.0 "}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000086!16 = !DILocalVariable(name: "a", line: 3, arg: 1, scope: !8, file: !9, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000087!17 = !DIExpression()
88!18 = !DILocation(line: 3, column: 13, scope: !8)
89!19 = !DILocation(line: 4, column: 5, scope: !8)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000090!20 = !DILocalVariable(name: "b", line: 4, scope: !8, file: !9, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000091!21 = !DILocation(line: 4, column: 9, scope: !8)
92!22 = !DILocation(line: 5, column: 5, scope: !8)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000093!23 = !DILocalVariable(name: "c", line: 5, scope: !8, file: !9, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000094!24 = !DILocation(line: 5, column: 9, scope: !8)
95!25 = !DILocation(line: 6, column: 5, scope: !8)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000096!26 = !DILocalVariable(name: "d", line: 6, scope: !8, file: !9, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000097!27 = !DILocation(line: 6, column: 9, scope: !8)
98!28 = !DILocation(line: 7, column: 5, scope: !8)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000099!29 = !DILocalVariable(name: "e", line: 7, scope: !8, file: !9, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000100!30 = !DILocation(line: 7, column: 9, scope: !8)
101!31 = !DILocation(line: 8, column: 5, scope: !8)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000102!32 = !DILocalVariable(name: "f", line: 8, scope: !8, file: !9, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000103!33 = !DILocation(line: 8, column: 9, scope: !8)
104!34 = !DILocation(line: 9, column: 5, scope: !8)