1*9880d681SAndroid Build Coastguard Worker; REQUIRES: object-emission 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; RUN: llc -mtriple=x86_64-apple-macosx10.10.0 -o %t %s 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker; Testcase generated from: 6*9880d681SAndroid Build Coastguard Worker; #include <stdint.h> 7*9880d681SAndroid Build Coastguard Worker; int foo(int a) { 8*9880d681SAndroid Build Coastguard Worker; int b = (int16_t)a + 8; 9*9880d681SAndroid Build Coastguard Worker; int c = (int16_t)b + 8; 10*9880d681SAndroid Build Coastguard Worker; int d = (int16_t)c + 8; 11*9880d681SAndroid Build Coastguard Worker; int e = (int16_t)d + 8; 12*9880d681SAndroid Build Coastguard Worker; int f = (int16_t)e + 8; 13*9880d681SAndroid Build Coastguard Worker; return f; 14*9880d681SAndroid Build Coastguard Worker; } 15*9880d681SAndroid Build Coastguard Worker; by emitting the IR and then manually applying mem2reg to it. 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker; This testcase would trigger the assert commited along with it if the 18*9880d681SAndroid Build Coastguard Worker; fix of r221709 isn't applied. There is no other check except the successful 19*9880d681SAndroid Build Coastguard Worker; run of llc. 20*9880d681SAndroid Build Coastguard Worker; What happened before r221709, is that SDDbgInfo (the data structure helping 21*9880d681SAndroid Build Coastguard Worker; SelectionDAG to keep track of dbg.values) kept a map keyed by SDNode pointers. 22*9880d681SAndroid Build Coastguard Worker; This map was never purged when the SDNodes were deallocated and thus if a new 23*9880d681SAndroid Build Coastguard Worker; SDNode was allocated in the same memory, it would have an entry in the SDDbgInfo 24*9880d681SAndroid Build Coastguard Worker; map upon creation (Reallocation in the same memory can happen easily as 25*9880d681SAndroid Build Coastguard Worker; SelectionDAG uses a Recycling allocator). This behavior could turn into a 26*9880d681SAndroid Build Coastguard Worker; pathological memory consumption explosion if the DAG combiner hit the 'right' 27*9880d681SAndroid Build Coastguard Worker; allocation patterns as could be seen in PR20893. 28*9880d681SAndroid Build Coastguard Worker; By nature, this test could bitrot quite easily. If it doesn't trigger an assert 29*9880d681SAndroid Build Coastguard Worker; when run with r221709 reverted, then it really doesn't test anything anymore. 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind ssp uwtable 32*9880d681SAndroid Build Coastguard Workerdefine i32 @foo(i32 %a) #0 !dbg !8 { 33*9880d681SAndroid Build Coastguard Workerentry: 34*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !16, metadata !17), !dbg !18 35*9880d681SAndroid Build Coastguard Worker %conv = trunc i32 %a to i16, !dbg !19 36*9880d681SAndroid Build Coastguard Worker %conv1 = sext i16 %conv to i32, !dbg !19 37*9880d681SAndroid Build Coastguard Worker %add = add nsw i32 %conv1, 8, !dbg !19 38*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 %add, i64 0, metadata !20, metadata !17), !dbg !21 39*9880d681SAndroid Build Coastguard Worker %conv2 = trunc i32 %add to i16, !dbg !22 40*9880d681SAndroid Build Coastguard Worker %conv3 = sext i16 %conv2 to i32, !dbg !22 41*9880d681SAndroid Build Coastguard Worker %add4 = add nsw i32 %conv3, 8, !dbg !22 42*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 %add4, i64 0, metadata !23, metadata !17), !dbg !24 43*9880d681SAndroid Build Coastguard Worker %conv5 = trunc i32 %add4 to i16, !dbg !25 44*9880d681SAndroid Build Coastguard Worker %conv6 = sext i16 %conv5 to i32, !dbg !25 45*9880d681SAndroid Build Coastguard Worker %add7 = add nsw i32 %conv6, 8, !dbg !25 46*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 %add7, i64 0, metadata !26, metadata !17), !dbg !27 47*9880d681SAndroid Build Coastguard Worker %conv8 = trunc i32 %add7 to i16, !dbg !28 48*9880d681SAndroid Build Coastguard Worker %conv9 = sext i16 %conv8 to i32, !dbg !28 49*9880d681SAndroid Build Coastguard Worker %add10 = add nsw i32 %conv9, 8, !dbg !28 50*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 %add10, i64 0, metadata !29, metadata !17), !dbg !30 51*9880d681SAndroid Build Coastguard Worker %conv11 = trunc i32 %add10 to i16, !dbg !31 52*9880d681SAndroid Build Coastguard Worker %conv12 = sext i16 %conv11 to i32, !dbg !31 53*9880d681SAndroid Build Coastguard Worker %add13 = add nsw i32 %conv12, 8, !dbg !31 54*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.value(metadata i32 %add13, i64 0, metadata !32, metadata !17), !dbg !33 55*9880d681SAndroid Build Coastguard Worker ret i32 %add13, !dbg !34 56*9880d681SAndroid Build Coastguard Worker} 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone 59*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone 62*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Workerattributes #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" } 65*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone } 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0} 68*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!13, !14} 69*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!15} 70*9880d681SAndroid Build Coastguard Worker 71*9880d681SAndroid Build Coastguard Worker!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) 72*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp") 73*9880d681SAndroid Build Coastguard Worker!2 = !{} 74*9880d681SAndroid Build Coastguard Worker!3 = !{!4} 75*9880d681SAndroid Build Coastguard Worker!4 = !DIDerivedType(tag: DW_TAG_typedef, name: "int16_t", line: 30, file: !5, baseType: !6) 76*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "/usr/include/sys/_types/_int16_t.h", directory: "/tmp") 77*9880d681SAndroid Build Coastguard Worker!6 = !DIBasicType(tag: DW_TAG_base_type, name: "short", size: 16, align: 16, encoding: DW_ATE_signed) 78*9880d681SAndroid Build Coastguard Worker!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) 79*9880d681SAndroid Build Coastguard Worker!9 = !DIFile(filename: "ghost-sdnode-dbgvalues.c", directory: "/tmp") 80*9880d681SAndroid Build Coastguard Worker!10 = !DISubroutineType(types: !11) 81*9880d681SAndroid Build Coastguard Worker!11 = !{!12, !12} 82*9880d681SAndroid Build Coastguard Worker!12 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 83*9880d681SAndroid Build Coastguard Worker!13 = !{i32 2, !"Dwarf Version", i32 2} 84*9880d681SAndroid Build Coastguard Worker!14 = !{i32 2, !"Debug Info Version", i32 3} 85*9880d681SAndroid Build Coastguard Worker!15 = !{!"clang version 3.6.0 "} 86*9880d681SAndroid Build Coastguard Worker!16 = !DILocalVariable(name: "a", line: 3, arg: 1, scope: !8, file: !9, type: !12) 87*9880d681SAndroid Build Coastguard Worker!17 = !DIExpression() 88*9880d681SAndroid Build Coastguard Worker!18 = !DILocation(line: 3, column: 13, scope: !8) 89*9880d681SAndroid Build Coastguard Worker!19 = !DILocation(line: 4, column: 5, scope: !8) 90*9880d681SAndroid Build Coastguard Worker!20 = !DILocalVariable(name: "b", line: 4, scope: !8, file: !9, type: !12) 91*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 4, column: 9, scope: !8) 92*9880d681SAndroid Build Coastguard Worker!22 = !DILocation(line: 5, column: 5, scope: !8) 93*9880d681SAndroid Build Coastguard Worker!23 = !DILocalVariable(name: "c", line: 5, scope: !8, file: !9, type: !12) 94*9880d681SAndroid Build Coastguard Worker!24 = !DILocation(line: 5, column: 9, scope: !8) 95*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 6, column: 5, scope: !8) 96*9880d681SAndroid Build Coastguard Worker!26 = !DILocalVariable(name: "d", line: 6, scope: !8, file: !9, type: !12) 97*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 6, column: 9, scope: !8) 98*9880d681SAndroid Build Coastguard Worker!28 = !DILocation(line: 7, column: 5, scope: !8) 99*9880d681SAndroid Build Coastguard Worker!29 = !DILocalVariable(name: "e", line: 7, scope: !8, file: !9, type: !12) 100*9880d681SAndroid Build Coastguard Worker!30 = !DILocation(line: 7, column: 9, scope: !8) 101*9880d681SAndroid Build Coastguard Worker!31 = !DILocation(line: 8, column: 5, scope: !8) 102*9880d681SAndroid Build Coastguard Worker!32 = !DILocalVariable(name: "f", line: 8, scope: !8, file: !9, type: !12) 103*9880d681SAndroid Build Coastguard Worker!33 = !DILocation(line: 8, column: 9, scope: !8) 104*9880d681SAndroid Build Coastguard Worker!34 = !DILocation(line: 9, column: 5, scope: !8) 105