1; RUN: opt -passes=instcombine %s -o - -S | FileCheck %s 2; RUN: opt -passes=instcombine %s -o - -S --try-experimental-debuginfo-iterators | FileCheck %s 3; typedef struct v *v_t; 4; struct v { 5; unsigned long long p; 6; }; 7; 8; void f(v_t object, unsigned long long *start) { 9; unsigned head_size; 10; unsigned long long orig_start; 11; unsigned long long offset; 12; orig_start = *start; 13; for (offset = orig_start - (unsigned long long)(1 << 12); head_size; 14; offset -= (unsigned long long)(1 << 12), head_size -= (1 << 12)) 15; use(offset, (object)); 16; } 17source_filename = "test.i" 18target datalayout = "e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32" 19target triple = "thumbv7s-apple-ios5.0.0" 20 21%struct.vm_object = type { i64 } 22 23; Function Attrs: nounwind ssp 24define void @f(ptr %object, ptr nocapture readonly %start, i1 %c1) local_unnamed_addr #0 !dbg !11 { 25entry: 26 tail call void @llvm.dbg.value(metadata ptr %object, metadata !21, metadata !DIExpression()), !dbg !27 27 tail call void @llvm.dbg.value(metadata ptr %start, metadata !22, metadata !DIExpression()), !dbg !28 28 %0 = load i64, ptr %start, align 4, !dbg !29 29 tail call void @llvm.dbg.value(metadata i64 %0, metadata !25, metadata !DIExpression()), !dbg !30 30 %offset.08 = add i64 %0, -4096 31 tail call void @llvm.dbg.value(metadata i64 %offset.08, metadata !26, metadata !DIExpression()), !dbg !31 32 tail call void @llvm.dbg.value(metadata i32 undef, metadata !23, metadata !DIExpression()), !dbg !32 33 br i1 %c1, label %for.end, label %for.body.lr.ph, !dbg !32 34 35for.body.lr.ph: ; preds = %entry 36 ; The 'load' and the 'add' are sunken to this basic block. So let's verify that the related dbg.values are sunken as well. 37 ; The add is later eliminated, so we verify that the dbg.value is salvaged by using DW_OP_minus. 38 ; CHECK-LABEL: for.body.lr.ph: 39 ; CHECK-NEXT: %0 = load 40 ; CHECK-NEXT: #dbg_value(i64 %0, !25, !DIExpression(), ! 41 ; CHECK-NEXT: #dbg_value(i64 %0, !26, !DIExpression(DW_OP_constu, 4096, DW_OP_minus, DW_OP_stack_value), ! 42 br label %for.body, !dbg !32 43 44for.body: ; preds = %for.body.lr.ph, %for.body 45 ; CHECK-LABEL: for.body: 46 %offset.010 = phi i64 [ %offset.08, %for.body.lr.ph ], [ %offset.0, %for.body ] 47 %head_size.09 = phi i32 [ poison, %for.body.lr.ph ], [ %sub2, %for.body ] 48 tail call void @llvm.dbg.value(metadata i32 %head_size.09, metadata !23, metadata !DIExpression()), !dbg !31 49 %call = tail call i32 @use(i64 %offset.010, ptr %object) #3, !dbg !34 50 %sub2 = add i32 %head_size.09, -4096, !dbg !37 51 %offset.0 = add i64 %offset.010, -4096 52 tail call void @llvm.dbg.value(metadata i64 %offset.0, metadata !26, metadata !DIExpression()), !dbg !30 53 ; CHECK: #dbg_value(i64 %offset.010, !26, !DIExpression(DW_OP_constu, 4096, DW_OP_minus, DW_OP_stack_value), ! 54 tail call void @llvm.dbg.value(metadata i32 %sub2, metadata !23, metadata !DIExpression()), !dbg !31 55 %tobool = icmp eq i32 %sub2, 0, !dbg !32 56 br i1 %tobool, label %for.end, label %for.body, !dbg !32, !llvm.loop !38 57 58for.end: ; preds = %for.body, %entry 59 ret void, !dbg !40 60} 61 62declare i32 @use(...) local_unnamed_addr 63 64; Function Attrs: nounwind readnone speculatable 65declare void @llvm.dbg.value(metadata, metadata, metadata) #2 66 67attributes #0 = { nounwind ssp } 68attributes #2 = { nounwind readnone speculatable } 69attributes #3 = { nobuiltin } 70 71!llvm.dbg.cu = !{!0} 72!llvm.module.flags = !{!5, !6, !7, !8, !9} 73!llvm.ident = !{!10} 74 75!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 317434) (llvm/trunk 317437)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3) 76!1 = !DIFile(filename: "test.i", directory: "/Data/radar/31209283") 77!2 = !{} 78!3 = !{!4} 79!4 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned) 80!5 = !{i32 2, !"Dwarf Version", i32 2} 81!6 = !{i32 2, !"Debug Info Version", i32 3} 82!7 = !{i32 1, !"wchar_size", i32 4} 83!8 = !{i32 1, !"min_enum_size", i32 4} 84!9 = !{i32 7, !"PIC Level", i32 2} 85!10 = !{!"clang version 6.0.0 (trunk 317434) (llvm/trunk 317437)"} 86!11 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 6, type: !12, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !20) 87!12 = !DISubroutineType(types: !13) 88!13 = !{null, !14, !19} 89!14 = !DIDerivedType(tag: DW_TAG_typedef, name: "v_t", file: !1, line: 1, baseType: !15) 90!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 32) 91!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "v", file: !1, line: 2, size: 64, elements: !17) 92!17 = !{!18} 93!18 = !DIDerivedType(tag: DW_TAG_member, name: "p", scope: !16, file: !1, line: 3, baseType: !4, size: 64) 94!19 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 32) 95!20 = !{!21, !22, !23, !25, !26} 96!21 = !DILocalVariable(name: "object", arg: 1, scope: !11, file: !1, line: 6, type: !14) 97!22 = !DILocalVariable(name: "start", arg: 2, scope: !11, file: !1, line: 6, type: !19) 98!23 = !DILocalVariable(name: "head_size", scope: !11, file: !1, line: 7, type: !24) 99!24 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) 100!25 = !DILocalVariable(name: "orig_start", scope: !11, file: !1, line: 8, type: !4) 101!26 = !DILocalVariable(name: "offset", scope: !11, file: !1, line: 9, type: !4) 102!27 = !DILocation(line: 6, column: 20, scope: !11) 103!28 = !DILocation(line: 6, column: 48, scope: !11) 104!29 = !DILocation(line: 8, column: 22, scope: !11) 105!30 = !DILocation(line: 7, column: 12, scope: !11) 106!31 = !DILocation(line: 10, column: 16, scope: !11) 107!32 = !DILocation(line: 11, column: 5, scope: !33) 108!33 = distinct !DILexicalBlock(scope: !11, file: !1, line: 11, column: 5) 109!34 = !DILocation(line: 13, column: 7, scope: !35) 110!35 = distinct !DILexicalBlock(scope: !36, file: !1, line: 12, column: 75) 111!36 = distinct !DILexicalBlock(scope: !33, file: !1, line: 11, column: 5) 112!37 = !DILocation(line: 12, column: 61, scope: !36) 113!38 = distinct !{!38, !32, !39} 114!39 = !DILocation(line: 14, column: 3, scope: !33) 115!40 = !DILocation(line: 15, column: 1, scope: !11) 116