104 lines · plain
1 2; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 -o %t %s3 4; Testcase generated from:5; #include <stdint.h>6; int foo(int a) {7; int b = (int16_t)a + 8;8; int c = (int16_t)b + 8;9; int d = (int16_t)c + 8;10; int e = (int16_t)d + 8;11; int f = (int16_t)e + 8;12; return f;13; }14; by emitting the IR and then manually applying mem2reg to it.15 16; This testcase would trigger the assert commited along with it if the17; fix of r221709 isn't applied. There is no other check except the successful18; run of llc.19; What happened before r221709, is that SDDbgInfo (the data structure helping20; SelectionDAG to keep track of dbg.values) kept a map keyed by SDNode pointers.21; This map was never purged when the SDNodes were deallocated and thus if a new22; SDNode was allocated in the same memory, it would have an entry in the SDDbgInfo23; map upon creation (Reallocation in the same memory can happen easily as24; SelectionDAG uses a Recycling allocator). This behavior could turn into a25; pathological memory consumption explosion if the DAG combiner hit the 'right'26; allocation patterns as could be seen in PR20893.27; By nature, this test could bitrot quite easily. If it doesn't trigger an assert28; when run with r221709 reverted, then it really doesn't test anything anymore.29 30; Function Attrs: nounwind ssp uwtable31define i32 @foo(i32 %a) #0 !dbg !8 {32entry:33 call void @llvm.dbg.value(metadata i32 %a, metadata !16, metadata !17), !dbg !1834 %conv = trunc i32 %a to i16, !dbg !1935 %conv1 = sext i16 %conv to i32, !dbg !1936 %add = add nsw i32 %conv1, 8, !dbg !1937 call void @llvm.dbg.value(metadata i32 %add, metadata !20, metadata !17), !dbg !2138 %conv2 = trunc i32 %add to i16, !dbg !2239 %conv3 = sext i16 %conv2 to i32, !dbg !2240 %add4 = add nsw i32 %conv3, 8, !dbg !2241 call void @llvm.dbg.value(metadata i32 %add4, metadata !23, metadata !17), !dbg !2442 %conv5 = trunc i32 %add4 to i16, !dbg !2543 %conv6 = sext i16 %conv5 to i32, !dbg !2544 %add7 = add nsw i32 %conv6, 8, !dbg !2545 call void @llvm.dbg.value(metadata i32 %add7, metadata !26, metadata !17), !dbg !2746 %conv8 = trunc i32 %add7 to i16, !dbg !2847 %conv9 = sext i16 %conv8 to i32, !dbg !2848 %add10 = add nsw i32 %conv9, 8, !dbg !2849 call void @llvm.dbg.value(metadata i32 %add10, metadata !29, metadata !17), !dbg !3050 %conv11 = trunc i32 %add10 to i16, !dbg !3151 %conv12 = sext i16 %conv11 to i32, !dbg !3152 %add13 = add nsw i32 %conv12, 8, !dbg !3153 call void @llvm.dbg.value(metadata i32 %add13, metadata !32, metadata !17), !dbg !3354 ret i32 %add13, !dbg !3455}56 57; Function Attrs: nounwind readnone58declare void @llvm.dbg.declare(metadata, metadata, metadata) #159 60; Function Attrs: nounwind readnone61declare void @llvm.dbg.value(metadata, metadata, metadata) #162 63attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }64attributes #1 = { nounwind readnone }65 66!llvm.dbg.cu = !{!0}67!llvm.module.flags = !{!13, !14}68!llvm.ident = !{!15}69 70!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)71!1 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp")72!2 = !{}73!3 = !{!4}74!4 = !DIDerivedType(tag: DW_TAG_typedef, name: "int16_t", line: 30, file: !5, baseType: !6)75!5 = !DIFile(filename: "/usr/include/sys/_types/_int16_t.h", directory: "/tmp")76!6 = !DIBasicType(tag: DW_TAG_base_type, name: "short", size: 16, align: 16, encoding: DW_ATE_signed)77!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)78!9 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp")79!10 = !DISubroutineType(types: !11)80!11 = !{!12, !12}81!12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)82!13 = !{i32 2, !"Dwarf Version", i32 2}83!14 = !{i32 2, !"Debug Info Version", i32 3}84!15 = !{!"clang version 3.6.0 "}85!16 = !DILocalVariable(name: "a", line: 3, arg: 1, scope: !8, file: !9, type: !12)86!17 = !DIExpression()87!18 = !DILocation(line: 3, column: 13, scope: !8)88!19 = !DILocation(line: 4, column: 5, scope: !8)89!20 = !DILocalVariable(name: "b", line: 4, scope: !8, file: !9, type: !12)90!21 = !DILocation(line: 4, column: 9, scope: !8)91!22 = !DILocation(line: 5, column: 5, scope: !8)92!23 = !DILocalVariable(name: "c", line: 5, scope: !8, file: !9, type: !12)93!24 = !DILocation(line: 5, column: 9, scope: !8)94!25 = !DILocation(line: 6, column: 5, scope: !8)95!26 = !DILocalVariable(name: "d", line: 6, scope: !8, file: !9, type: !12)96!27 = !DILocation(line: 6, column: 9, scope: !8)97!28 = !DILocation(line: 7, column: 5, scope: !8)98!29 = !DILocalVariable(name: "e", line: 7, scope: !8, file: !9, type: !12)99!30 = !DILocation(line: 7, column: 9, scope: !8)100!31 = !DILocation(line: 8, column: 5, scope: !8)101!32 = !DILocalVariable(name: "f", line: 8, scope: !8, file: !9, type: !12)102!33 = !DILocation(line: 8, column: 9, scope: !8)103!34 = !DILocation(line: 9, column: 5, scope: !8)104