1; RUN: llc -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM 2; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump -v --debug-info - | FileCheck %s 3; 4; Generated at -O2 from: 5; struct B; 6; class A { 7; int a1 = 23; 8; int a2 = 42; 9; }; 10; struct B { 11; A a; 12; int b = 48; 13; }; 14; 15; B *getB() { return new B(); } 16; 17; The inlined A::this pointer has the same location as B::this, but it may not be 18; modified by the debugger. 19; 20; ASM: [DW_OP_stack_value] 21; CHECK: DW_AT_location {{.*}} (DW_OP_breg0 RAX+0, DW_OP_stack_value) 22 23source_filename = "ab.cpp" 24target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 25target triple = "x86_64-apple-macosx10.12.0" 26 27%struct.B = type { %class.A, i32 } 28%class.A = type { i32, i32 } 29 30; Function Attrs: ssp uwtable 31define noalias nonnull ptr @_Z4getBv() local_unnamed_addr #0 !dbg !7 { 32entry: 33 %call = tail call ptr @_Znwm(i64 12) #3, !dbg !20 34 tail call void @llvm.dbg.value(metadata ptr %call, metadata !21, metadata !28), !dbg !29 35 tail call void @llvm.dbg.value(metadata ptr %call, metadata !31, metadata !28), !dbg !34 36 tail call void @llvm.dbg.value(metadata ptr %call, metadata !36, metadata !44), !dbg !45 37 tail call void @llvm.dbg.value(metadata ptr %call, metadata !47, metadata !44), !dbg !50 38 store i32 23, ptr %call, align 4, !dbg !52, !tbaa !53 39 %a2.i.i.i.i = getelementptr inbounds i8, ptr %call, i64 4, !dbg !58 40 store i32 42, ptr %a2.i.i.i.i, align 4, !dbg !58, !tbaa !59 41 %b.i.i = getelementptr inbounds i8, ptr %call, i64 8, !dbg !60 42 store i32 48, ptr %b.i.i, align 4, !dbg !60, !tbaa !61 43 ret ptr %call, !dbg !63 44} 45 46declare noalias nonnull ptr @_Znwm(i64) local_unnamed_addr #1 47declare void @llvm.dbg.value(metadata, metadata, metadata) #2 48 49attributes #0 = { ssp uwtable } 50attributes #1 = { nobuiltin } 51attributes #2 = { nounwind readnone } 52attributes #3 = { builtin } 53 54!llvm.dbg.cu = !{!0} 55!llvm.module.flags = !{!3, !4, !5} 56 57!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 301093) (llvm/trunk 301093)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 58!1 = !DIFile(filename: "ab.cpp", directory: "/") 59!2 = !{} 60!3 = !{i32 2, !"Dwarf Version", i32 4} 61!4 = !{i32 2, !"Debug Info Version", i32 3} 62!5 = !{i32 1, !"PIC Level", i32 2} 63!7 = distinct !DISubprogram(name: "getB", linkageName: "_Z4getBv", scope: !1, file: !1, line: 11, type: !8, isLocal: false, isDefinition: true, scopeLine: 11, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2) 64!8 = !DISubroutineType(types: !9) 65!9 = !{!10} 66!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) 67!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "B", file: !1, line: 6, size: 96, elements: !12, identifier: "_ZTS1B") 68!12 = !{!13, !19} 69!13 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !11, file: !1, line: 7, baseType: !14, size: 64) 70!14 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !1, line: 2, size: 64, elements: !15, identifier: "_ZTS1A") 71!15 = !{!16, !18} 72!16 = !DIDerivedType(tag: DW_TAG_member, name: "a1", scope: !14, file: !1, line: 3, baseType: !17, size: 32) 73!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 74!18 = !DIDerivedType(tag: DW_TAG_member, name: "a2", scope: !14, file: !1, line: 4, baseType: !17, size: 32, offset: 32) 75!19 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !11, file: !1, line: 8, baseType: !17, size: 32, offset: 64) 76!20 = !DILocation(line: 11, column: 20, scope: !7) 77!21 = !DILocalVariable(name: "this", arg: 1, scope: !22, type: !10, flags: DIFlagArtificial | DIFlagObjectPointer) 78!22 = distinct !DISubprogram(name: "B", linkageName: "_ZN1BC1Ev", scope: !11, file: !1, line: 6, type: !23, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !26, retainedNodes: !27) 79!23 = !DISubroutineType(types: !24) 80!24 = !{null, !25} 81!25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 82!26 = !DISubprogram(name: "B", scope: !11, type: !23, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: true) 83!27 = !{!21} 84!28 = !DIExpression() 85!29 = !DILocation(line: 0, scope: !22, inlinedAt: !30) 86!30 = distinct !DILocation(line: 11, column: 24, scope: !7) 87!31 = !DILocalVariable(name: "this", arg: 1, scope: !32, type: !10, flags: DIFlagArtificial | DIFlagObjectPointer) 88!32 = distinct !DISubprogram(name: "B", linkageName: "_ZN1BC2Ev", scope: !11, file: !1, line: 6, type: !23, isLocal: false, isDefinition: true, scopeLine: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !26, retainedNodes: !33) 89!33 = !{!31} 90!34 = !DILocation(line: 0, scope: !32, inlinedAt: !35) 91!35 = distinct !DILocation(line: 6, column: 8, scope: !22, inlinedAt: !30) 92!36 = !DILocalVariable(name: "this", arg: 1, scope: !37, type: !43, flags: DIFlagArtificial | DIFlagObjectPointer) 93!37 = distinct !DISubprogram(name: "A", linkageName: "_ZN1AC1Ev", scope: !14, file: !1, line: 2, type: !38, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !41, retainedNodes: !42) 94!38 = !DISubroutineType(types: !39) 95!39 = !{null, !40} 96!40 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer) 97!41 = !DISubprogram(name: "A", scope: !14, type: !38, isLocal: false, isDefinition: false, flags: DIFlagPublic | DIFlagArtificial | DIFlagPrototyped, isOptimized: true) 98!42 = !{!36} 99!43 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) 100!44 = !DIExpression(DW_OP_stack_value) 101!45 = !DILocation(line: 0, scope: !37, inlinedAt: !46) 102!46 = distinct !DILocation(line: 6, column: 8, scope: !32, inlinedAt: !35) 103!47 = !DILocalVariable(name: "this", arg: 1, scope: !48, type: !43, flags: DIFlagArtificial | DIFlagObjectPointer) 104!48 = distinct !DISubprogram(name: "A", linkageName: "_ZN1AC2Ev", scope: !14, file: !1, line: 2, type: !38, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: true, unit: !0, declaration: !41, retainedNodes: !49) 105!49 = !{!47} 106!50 = !DILocation(line: 0, scope: !48, inlinedAt: !51) 107!51 = distinct !DILocation(line: 2, column: 7, scope: !37, inlinedAt: !46) 108!52 = !DILocation(line: 3, column: 7, scope: !48, inlinedAt: !51) 109!53 = !{!54, !55, i64 0} 110!54 = !{!"_ZTS1A", !55, i64 0, !55, i64 4} 111!55 = !{!"int", !56, i64 0} 112!56 = !{!"omnipotent char", !57, i64 0} 113!57 = !{!"Simple C++ TBAA"} 114!58 = !DILocation(line: 4, column: 7, scope: !48, inlinedAt: !51) 115!59 = !{!54, !55, i64 4} 116!60 = !DILocation(line: 8, column: 7, scope: !32, inlinedAt: !35) 117!61 = !{!62, !55, i64 8} 118!62 = !{!"_ZTS1B", !54, i64 0, !55, i64 8} 119!63 = !DILocation(line: 11, column: 13, scope: !7) 120