2013-05-11 05:52:07 +08:00
; REQUIRES: object-emission
2017-09-12 07:05:20 +08:00
; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
2019-08-14 01:00:54 +08:00
; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | not llvm-dwarfdump -verify - | FileCheck %s --check-prefix VERIFY
2013-05-11 05:52:07 +08:00
; IR generated with `clang++ -g -emit-llvm -S` from the following code:
2018-10-04 02:44:53 +08:00
; template<int x, int*, template<typename> class y, decltype(nullptr) n, int ...z> int func() {
; var<int> = 5;
; return var<int>;
; }
2013-08-02 04:30:22 +08:00
; template<typename> struct y_impl { struct nested { }; };
2014-12-17 08:43:22 +08:00
; int glbl = func<3, &glbl, y_impl, nullptr, 1, 2>();
2013-08-02 04:30:22 +08:00
; y_impl<int>::nested n;
2013-05-11 05:52:07 +08:00
2019-08-14 01:00:54 +08:00
; VERIFY-NOT: error: DIE has DW_AT_type with incompatible tag DW_TAG_unspecified_type
; VERIFY: error: DIEs have overlapping address ranges
2013-05-11 05:52:07 +08:00
; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type
; CHECK-NEXT: DW_AT_name{{.*}} = "int"
2013-08-02 04:30:22 +08:00
; CHECK: DW_TAG_structure_type
2018-10-04 02:44:53 +08:00
; CHECK: DW_AT_name{{.*}}"y_impl<int>"
; CHECK-NOT: {{TAG|NULL}}
; CHECK: DW_TAG_template_type_parameter
; CHECK: DW_TAG_variable
; CHECK-NEXT: DW_AT_name{{.*}}"var"
2013-08-02 04:30:22 +08:00
; CHECK-NOT: NULL
; CHECK: DW_TAG_template_type_parameter
2018-10-04 02:44:53 +08:00
; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
; CHECK-NEXT: DW_AT_name{{.*}}= "T"
2013-08-02 04:30:22 +08:00
2014-12-17 08:43:22 +08:00
; CHECK: DW_AT_name{{.*}}"func<3, &glbl, y_impl, nullptr, 1, 2>"
2013-05-11 05:52:07 +08:00
; CHECK-NOT: NULL
; CHECK: DW_TAG_template_value_parameter
; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
; CHECK-NEXT: DW_AT_name{{.*}}= "x"
2013-08-28 07:49:04 +08:00
; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(3)
2013-05-11 05:52:07 +08:00
; CHECK: DW_TAG_template_value_parameter
2013-10-29 08:58:04 +08:00
; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]}
2013-05-11 05:52:07 +08:00
; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use
; the value immediately, rather than indirecting through the address.
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-30 05:41:21 +08:00
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]{{ *}}(DW_OP_addr 0x0, DW_OP_stack_value)
2013-06-23 02:59:11 +08:00
; CHECK-NOT: NULL
; CHECK: DW_TAG_GNU_template_template_param
; CHECK-NEXT: DW_AT_name{{.*}}= "y"
; CHECK-NEXT: DW_AT_GNU_template_name{{.*}}= "y_impl"
; CHECK-NOT: NULL
2014-12-17 08:43:22 +08:00
; CHECK: DW_TAG_template_value_parameter
; CHECK-NEXT: DW_AT_type{{.*}}=> {[[NULLPTR:0x[0-9a-f]*]]}
; CHECK-NEXT: DW_AT_name{{.*}}= "n"
; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata]{{.*}}(0)
2013-06-23 02:59:11 +08:00
; CHECK: DW_TAG_GNU_template_parameter_pack
; CHECK-NOT: NULL
; CHECK: DW_TAG_template_value_parameter
; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
2013-08-28 07:49:04 +08:00
; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(1)
2013-06-23 02:59:11 +08:00
; CHECK-NOT: NULL
; CHECK: DW_TAG_template_value_parameter
; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
2013-08-28 07:49:04 +08:00
; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(2)
2013-05-11 05:52:07 +08:00
2013-10-29 08:58:04 +08:00
; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type
; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]}
2014-12-17 08:43:22 +08:00
; CHECK: [[NULLPTR]]:{{ *}}DW_TAG_unspecified_type
; CHECK-NEXT: DW_AT_name{{.*}}= "decltype(nullptr)"
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/template.ll"
2013-08-02 04:30:22 +08:00
%"struct.y_impl<int>::nested" = type { i8 }
2013-06-23 02:59:11 +08:00
2018-10-04 02:44:53 +08:00
@glbl = d s o _ l o c a l global i32 0 , align 4 , !dbg !0
@_Z3varIiE = linkonce_odr d s o _ l o c a l global i32 0 , align 4 , !dbg !13
@n = d s o _ l o c a l global %"struct.y_impl<int>::nested" zeroinitializer , align 1 , !dbg !6
@llvm.global_ctors = appending global [ 1 x { i32 , void ( ) * , i8 * } ] [ { i32 , void ( ) * , i8 * } { i32 65535 , void ( ) * @_GLOBAL__sub_I_upstream_test.cpp , i8 * null } ]
2013-05-11 05:52:07 +08:00
2018-10-04 02:44:53 +08:00
; Function Attrs: noinline uwtable
define internal void @__cxx_global_var_init ( ) #0 section ".text.startup" !dbg !21 {
2013-05-11 05:52:07 +08:00
entry:
2018-10-04 02:44:53 +08:00
%call = call i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv ( ) , !dbg !24
store i32 %call , i32 * @glbl , align 4 , !dbg !24
ret void , !dbg !24
2013-05-11 05:52:07 +08:00
}
2018-10-04 02:44:53 +08:00
; Function Attrs: noinline nounwind optnone uwtable
define linkonce_odr d s o _ l o c a l i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv ( ) #1 !dbg !25 {
2013-05-11 05:52:07 +08:00
entry:
2018-10-04 02:44:53 +08:00
store i32 5 , i32 * @_Z3varIiE , align 4 , !dbg !39
%0 = load i32 , i32 * @_Z3varIiE , align 4 , !dbg !40
ret i32 %0 , !dbg !41
2013-05-11 05:52:07 +08:00
}
2018-10-04 02:44:53 +08:00
; Function Attrs: noinline uwtable
define internal void @_GLOBAL__sub_I_upstream_test.cpp ( ) #0 section ".text.startup" !dbg !42 {
2013-05-11 05:52:07 +08:00
entry:
2018-10-04 02:44:53 +08:00
call void @__cxx_global_var_init ( ) , !dbg !44
2014-12-17 08:43:22 +08:00
ret void
2013-05-11 05:52:07 +08:00
}
2018-10-04 02:44:53 +08:00
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind uwtable noinline optnone }
2013-05-11 05:52:07 +08:00
2018-10-04 02:44:53 +08:00
!llvm.dbg.cu = ! { !2 }
!llvm.module.flags = ! { !17 , !18 , !19 }
!llvm.ident = ! { !20 }
2016-12-22 08:45:21 +08:00
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2018-10-04 02:44:53 +08:00
!1 = distinct !DIGlobalVariable ( name: "glbl" , scope: !2 , file: !3 , line: 7 , type: !12 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !3 , producer: "clang version 7.0.0 " , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , globals: !5 )
!3 = !DIFile ( filename: "upstream_test.cpp" , directory: "/home/mvoss/src/92562" )
!4 = ! { }
!5 = ! { !0 , !6 , !13 }
!6 = !DIGlobalVariableExpression ( var: !7 , expr: !DIExpression ( ) )
!7 = distinct !DIGlobalVariable ( name: "n" , scope: !2 , file: !3 , line: 8 , type: !8 , isLocal: false , isDefinition: true ) !8 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "nested" , scope: !9 , file: !3 , line: 6 , size: 8 , flags: D I F l a g T y p e P a s s B y V a l u e , elements: !4 , identifier: "_ZTSN6y_implIiE6nestedE" )
!9 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "y_impl<int>" , file: !3 , line: 6 , size: 8 , flags: D I F l a g T y p e P a s s B y V a l u e , elements: !4 , templateParams: !10 , identifier: "_ZTS6y_implIiE" )
!10 = ! { !11 }
!11 = !DITemplateTypeParameter ( type: !12 )
!12 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!13 = !DIGlobalVariableExpression ( var: !14 , expr: !DIExpression ( ) )
!14 = distinct !DIGlobalVariable ( name: "var" , linkageName: "_Z3varIiE" , scope: !2 , file: !3 , line: 1 , type: !12 , isLocal: false , isDefinition: true , templateParams: !15 )
!15 = ! { !16 }
!16 = !DITemplateTypeParameter ( name: "T" , type: !12 )
!17 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!18 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!19 = ! { i32 1 , !"wchar_size" , i32 4 }
!20 = ! { !"clang version 7.0.0 " }
!21 = distinct !DISubprogram ( name: "__cxx_global_var_init" , scope: !3 , file: !3 , line: 7 , type: !22 , isLocal: true , isDefinition: true , scopeLine: 7 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !2 , retainedNodes: !4 )
2016-12-22 08:45:21 +08:00
!22 = !DISubroutineType ( types: !23 )
2018-10-04 02:44:53 +08:00
!23 = ! { null }
!24 = !DILocation ( line: 7 , column: 12 , scope: !21 )
!25 = distinct !DISubprogram ( name: "func<3, &glbl, y_impl, nullptr, 1, 2>" , linkageName: "_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv" , scope: !3 , file: !3 , line: 2 , type: !26 , isLocal: false , isDefinition: true , scopeLine: 2 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !2 , templateParams: !28 , retainedNodes: !4 )
!26 = !DISubroutineType ( types: !27 )
!27 = ! { !12 }
!28 = ! { !29 , !30 , !32 , !33 , !35 }
!29 = !DITemplateValueParameter ( name: "x" , type: !12 , value: i32 3 )
!30 = !DITemplateValueParameter ( type: !31 , value: i32 * @glbl )
!31 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !12 , size: 64 )
!32 = !DITemplateValueParameter ( tag: D W _ T A G _ G N U _ t e m p l a t e _ t e m p l a t e _ p a r a m , name: "y" , value: !"y_impl" )
!33 = !DITemplateValueParameter ( name: "n" , type: !34 , value: i8 0 )
!34 = !DIBasicType ( tag: D W _ T A G _ u n s p e c i f i e d _ type , name: "decltype(nullptr)" )
!35 = !DITemplateValueParameter ( tag: D W _ T A G _ G N U _ t e m p l a t e _ p a r a m e t e r _ p a c k , name: "z" , value: !36 )
!36 = ! { !37 , !38 }
!37 = !DITemplateValueParameter ( type: !12 , value: i32 1 )
!38 = !DITemplateValueParameter ( type: !12 , value: i32 2 )
!39 = !DILocation ( line: 3 , column: 12 , scope: !25 )
!40 = !DILocation ( line: 4 , column: 10 , scope: !25 )
!41 = !DILocation ( line: 4 , column: 3 , scope: !25 )
!42 = distinct !DISubprogram ( linkageName: "_GLOBAL__sub_I_upstream_test.cpp" , scope: !3 , file: !3 , type: !43 , isLocal: true , isDefinition: true , flags: D I F l a g A r t i f i c i a l , isOptimized: false , unit: !2 , retainedNodes: !4 )
!43 = !DISubroutineType ( types: !4 )
!44 = !DILocation ( line: 0 , scope: !42 )