; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -split-dwarf=Enable -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info.dwo - | FileCheck %s ;; This test checks the following: ;; 2. Function static variable, typedef, records (structure, class and union) ;; that are defined in lexical function scope are emitted as children to ;; the function scope, directly. ;; 3. "bar" function, which was inlined into "foo" function, is created as ;; abstract (with DW_AT_inline attribute). ;; All variables and types are defined in this abstract entry. ;; 4. "bar" function is created in "foo" function as inlined function ;; (with DW_TAG_inlined_subroutine attribute), and all its local variables ;; are created as concrete variables pointing to the abstract suitable entry ;; defined under abstract "bar" function. ;; ;; This test was generated by running following command: ;; clang -cc1 -O0 -g -emit-llvm foo.cpp -o - | opt -S -inline -sroa ;; Where foo.cpp ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;__inline int bar(int s) { ;; ;; ;; struct X { ;; int x; ;; }; ;; typedef int Y; ;; ;; X a = { s }; ;; Y b(s); ;; static int c = 0; ;; return a.x + b + c++; ;; ;; ;; ;;} ;; ;; ;;int foo(int i) { ;; return ;; bar(i); ;;} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; CHECK: [[Offset_bar:0x[0-9abcdef]+]]: DW_TAG_subprogram ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "bar" ; CHECK: DW_AT_inline ; CHECK-NOT: NULL ; CHECK: [[Offset_a:0x[0-9abcdef]+]]: DW_TAG_variable ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "a" ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: [[Offset_b:0x[0-9abcdef]+]]: DW_TAG_variable ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "b" ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: [[Offset_c:0x[0-9abcdef]+]]: DW_TAG_variable ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "c" ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_location ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: [[Offset_X:0x[0-9abcdef]+]]: DW_TAG_structure_type ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "X" ; CHECK: NULL ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: [[Offset_Y:0x[0-9abcdef]+]]: DW_TAG_typedef ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "Y" ; CHECK-NOT: {{DW_TAG}} ; CHECK: NULL ; CHECK: DW_TAG_subprogram ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_AT_name {{.*}} "foo" ; CHECK-NOT: {{NULL}} ; CHECK: DW_TAG_inlined_subroutine ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_bar]]} ; CHECK-NOT: {{NULL}} ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_location ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_a]]} ; CHECK-NOT: {{DW_TAG|NULL}} ; CHECK: DW_TAG_variable ; CHECK-NEXT: DW_AT_location ; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[Offset_b]]} ; CHECK-NOT: {{DW_TAG}} ; CHECK: NULL %struct.X = type { i32 } $_ZZ3bariE1c = comdat any @_ZZ3bariE1c = linkonce_odr global i32 0, comdat, align 4 ; Function Attrs: nounwind define i32 @_Z3fooi(i32 %i) #0 !dbg !13 { entry: call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !18, metadata !19), !dbg !20 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !21, metadata !19), !dbg !22 call void @llvm.dbg.declare(metadata %struct.X* undef, metadata !24, metadata !19), !dbg !25 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !24, metadata !19), !dbg !25 call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !26, metadata !19), !dbg !27 %add.i = add nsw i32 %i, %i, !dbg !28 %0 = load i32, i32* @_ZZ3bariE1c, align 4, !dbg !28 %inc.i = add nsw i32 %0, 1, !dbg !28 store i32 %inc.i, i32* @_ZZ3bariE1c, align 4, !dbg !28 %add2.i = add nsw i32 %add.i, %0, !dbg !28 ret i32 %add2.i, !dbg !29 } ; Function Attrs: nounwind readnone declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 ; Function Attrs: nounwind readnone declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } attributes #1 = { nounwind readnone } !llvm.dbg.cu = !{!0, !30} !llvm.module.flags = !{!16} !llvm.ident = !{!17} !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 256818)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !12, globals: !14) !1 = !DIFile(filename: "foo.cpp", directory: "/") !2 = !{} !3 = !{!4, !11} !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !9, identifier: "_ZTSZ3bariE1X") !5 = distinct !DISubprogram(name: "bar", linkageName: "_Z3bari", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, variables: !2) !6 = !DISubroutineType(types: !7) !7 = !{!8, !8} !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !9 = !{!10} !10 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !"_ZTSZ3bariE1X", file: !1, line: 5, baseType: !8, size: 32, align: 32) !11 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !8) !12 = !{!13, !5} !13 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 19, type: !6, isLocal: false, isDefinition: true, scopeLine: 19, flags: DIFlagPrototyped, isOptimized: false, variables: !2) !14 = !{!15} !15 = !DIGlobalVariable(name: "c", scope: !5, file: !1, line: 11, type: !8, isLocal: false, isDefinition: true, variable: i32* @_ZZ3bariE1c) !16 = !{i32 2, !"Debug Info Version", i32 3} !17 = !{!"clang version 3.8.0 (trunk 256818)"} !18 = !DILocalVariable(name: "i", arg: 1, scope: !13, file: !1, line: 19, type: !8) !19 = !DIExpression() !20 = !DILocation(line: 19, scope: !13) !21 = !DILocalVariable(name: "s", arg: 1, scope: !5, file: !1, line: 1, type: !8) !22 = !DILocation(line: 1, scope: !5, inlinedAt: !23) !23 = distinct !DILocation(line: 21, scope: !13) !24 = !DILocalVariable(name: "a", scope: !5, file: !1, line: 9, type: !"_ZTSZ3bariE1X") !25 = !DILocation(line: 9, scope: !5, inlinedAt: !23) !26 = !DILocalVariable(name: "b", scope: !5, file: !1, line: 10, type: !11) !27 = !DILocation(line: 10, scope: !5, inlinedAt: !23) !28 = !DILocation(line: 12, scope: !5, inlinedAt: !23) !29 = !DILocation(line: 20, scope: !13) ; This line is manually added to check that the test does not crash when having ; more than one compile unit! !30 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 242994) (llvm/trunk 242995)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2)