1 ; RUN: llc -mtriple=x86_64-unknown-unknown -stop-before livedebugvalues %s -o - \ 2 ; RUN: | FileCheck %s 3 ; 4 ; Generated at -O1 from: 5 ; typedef struct { 6 ; unsigned long long c; 7 ; } S1; 8 ; struct S3 { 9 ; unsigned long long packed; 10 ; }; 11 ; struct S6 { 12 ; struct S0 *b; 13 ; }; 14 ; void f(struct S3 *a3) 15 ; { 16 ; struct S4 *s4 = (struct S4 *)(a3->packed + 0x1000UL); 17 ; struct S6 *myVar = (struct S6 *)s4; 18 ; struct S0 *b = myVar->b; 19 ; use(b); 20 ; } 21 ; 22 ; The debug info is attached to the ADD 4096 operation, which doesn't survive 23 ; instruction selection as it is folded into the load. 24 ; 25 ; CHECK: ![[S4:.*]] = !DILocalVariable(name: "s4", 26 ; CHECK: ![[MYVAR:.*]] = !DILocalVariable(name: "myVar", 27 ; CHECK: DBG_VALUE debug-use $rax, debug-use $noreg, ![[MYVAR]], 28 ; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, 4096, DW_OP_stack_value) 29 ; CHECK-NEXT: DBG_VALUE debug-use $rax, debug-use $noreg, ![[S4]], 30 ; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, 4096, DW_OP_stack_value) 31 ; CHECK-NEXT: $rdi = MOV64rm killed renamable $rax, 1, $noreg, 4096, $noreg, 32 33 source_filename = "test.c" 34 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 35 target triple = "x86_64-apple-macosx10.13.0" 36 37 %struct.S3 = type { i64 } 38 %struct.S4 = type opaque 39 %struct.S0 = type opaque 40 41 ; Function Attrs: noinline nounwind ssp uwtable 42 define void @f(%struct.S3* nocapture readonly %a3) local_unnamed_addr #0 !dbg !6 { 43 entry: 44 tail call void @llvm.dbg.value(metadata %struct.S3* %a3, metadata !15, metadata !DIExpression()), !dbg !30 45 %packed = getelementptr inbounds %struct.S3, %struct.S3* %a3, i64 0, i32 0, !dbg !31 46 %0 = load i64, i64* %packed, align 8, !dbg !31 47 %add = add i64 %0, 4096, !dbg !37 48 %1 = inttoptr i64 %add to %struct.S4*, !dbg !38 49 tail call void @llvm.dbg.value(metadata %struct.S4* %1, metadata !16, metadata !DIExpression()), !dbg !39 50 tail call void @llvm.dbg.value(metadata %struct.S4* %1, metadata !17, metadata !DIExpression()), !dbg !40 51 %b1 = bitcast %struct.S4* %1 to %struct.S0**, !dbg !41 52 %2 = load %struct.S0*, %struct.S0** %b1, align 8, !dbg !41 53 tail call void @llvm.dbg.value(metadata %struct.S0* %2, metadata !24, metadata !DIExpression()), !dbg !45 54 %call = tail call i32 (%struct.S0*, ...) bitcast (i32 (...)* @use to i32 (%struct.S0*, ...)*)(%struct.S0* %2) #3, !dbg !46 55 ret void, !dbg !47 56 } 57 58 declare i32 @use(...) local_unnamed_addr 59 60 ; Function Attrs: nounwind readnone speculatable 61 declare void @llvm.dbg.value(metadata, metadata, metadata) #2 62 63 attributes #0 = { noinline nounwind ssp uwtable } 64 attributes #2 = { nounwind readnone speculatable } 65 attributes #3 = { nounwind } 66 67 !llvm.dbg.cu = !{!0} 68 !llvm.module.flags = !{!25, !26, !27, !28} 69 !llvm.ident = !{!29} 70 71 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 (trunk 316467) (llvm/trunk 316466)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3) 72 !1 = !DIFile(filename: "test.c", directory: "/") 73 !2 = !{} 74 !3 = !{!4, !18} 75 !4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64) 76 !5 = !DICompositeType(tag: DW_TAG_structure_type, name: "S4", scope: !6, file: !1, line: 20, flags: DIFlagFwdDecl) 77 !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 18, type: !7, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !14) 78 !7 = !DISubroutineType(types: !8) 79 !8 = !{null, !9} 80 !9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64) 81 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S3", file: !1, line: 5, size: 64, elements: !11) 82 !11 = !{!12} 83 !12 = !DIDerivedType(tag: DW_TAG_member, name: "packed", scope: !10, file: !1, line: 6, baseType: !13, size: 64) 84 !13 = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned) 85 !14 = !{!15, !16, !17, !24} 86 !15 = !DILocalVariable(name: "a3", arg: 1, scope: !6, file: !1, line: 18, type: !9) 87 !16 = !DILocalVariable(name: "s4", scope: !6, file: !1, line: 20, type: !4) 88 !17 = !DILocalVariable(name: "myVar", scope: !6, file: !1, line: 21, type: !18) 89 !18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !19, size: 64) 90 !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S6", file: !1, line: 8, size: 64, elements: !20) 91 !20 = !{!21} 92 !21 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !19, file: !1, line: 9, baseType: !22, size: 64) 93 !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !23, size: 64) 94 !23 = !DICompositeType(tag: DW_TAG_structure_type, name: "S0", file: !1, line: 4, flags: DIFlagFwdDecl) 95 !24 = !DILocalVariable(name: "b", scope: !6, file: !1, line: 22, type: !22) 96 !25 = !{i32 2, !"Dwarf Version", i32 4} 97 !26 = !{i32 2, !"Debug Info Version", i32 3} 98 !27 = !{i32 1, !"wchar_size", i32 4} 99 !28 = !{i32 7, !"PIC Level", i32 2} 100 !29 = !{!"clang version 6.0.0 (trunk 316467) (llvm/trunk 316466)"} 101 !30 = !DILocation(line: 18, column: 14, scope: !6) 102 !31 = !DILocation(line: 20, column: 37, scope: !6) 103 !37 = !DILocation(line: 20, column: 44, scope: !6) 104 !38 = !DILocation(line: 20, column: 19, scope: !6) 105 !39 = !DILocation(line: 20, column: 14, scope: !6) 106 !40 = !DILocation(line: 21, column: 14, scope: !6) 107 !41 = !DILocation(line: 22, column: 25, scope: !6) 108 !45 = !DILocation(line: 22, column: 14, scope: !6) 109 !46 = !DILocation(line: 23, column: 3, scope: !6) 110 !47 = !DILocation(line: 24, column: 1, scope: !6) 111