2013-05-11 05:52:07 +08:00
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
2021-10-29 08:09:03 +08:00
; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | 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:
2021-09-20 12:03:20 +08:00
; template<typename T> T var;
; enum e : unsigned char { E = (e)-1 };
; template<int x, int*, template<typename> class y, decltype(nullptr) n, e, int ...z> int func() {
2018-10-04 02:44:53 +08:00
; var<int> = 5;
; return var<int>;
; }
2013-08-02 04:30:22 +08:00
; template<typename> struct y_impl { struct nested { }; };
2021-09-20 12:03:20 +08:00
; int glbl = func<3, &glbl, y_impl, nullptr, E, 1, 2>();
2013-08-02 04:30:22 +08:00
; y_impl<int>::nested n;
2013-05-11 05:52:07 +08:00
2021-10-29 08:09:03 +08:00
; VERIFY-NOT: error:
2019-08-14 01:00:54 +08:00
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
2021-09-20 12:03:20 +08:00
; CHECK: DW_AT_name{{.*}}"func<3, &glbl, y_impl, nullptr, E, 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)
2021-09-20 12:03:20 +08:00
; CHECK: DW_TAG_template_value_parameter
; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "e")
; CHECK: DW_AT_const_value [DW_FORM_udata] (255)
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)"
2021-09-20 12:03:20 +08:00
source_filename = "test.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
2013-08-02 04:30:22 +08:00
%"struct.y_impl<int>::nested" = type { i8 }
2013-06-23 02:59:11 +08:00
2021-09-20 12:03:20 +08:00
$ _ Z 4 f u n c I L i3 E X a d L _ Z 4 g l b l E E 6 y _ i m p l L D n 0 E L 1e255 E J L i1 E L i2 E E E i v = comdat any
$ _ Z 3 v a r I i E = comdat any
2018-10-04 02:44:53 +08:00
@glbl = d s o _ l o c a l global i32 0 , align 4 , !dbg !0
2021-09-20 12:03:20 +08:00
@n = d s o _ l o c a l global %"struct.y_impl<int>::nested" zeroinitializer , align 1 , !dbg !10
@_Z3varIiE = linkonce_odr d s o _ l o c a l global i32 0 , comdat , align 4 , !dbg !18
@llvm.global_ctors = appending global [ 1 x { i32 , void ( ) * , i8 * } ] [ { i32 , void ( ) * , i8 * } { i32 65535 , void ( ) * @_GLOBAL__sub_I_test.cpp , i8 * null } ]
2013-05-11 05:52:07 +08:00
2018-10-04 02:44:53 +08:00
; Function Attrs: noinline uwtable
2021-09-20 12:03:20 +08:00
define internal void @__cxx_global_var_init ( ) #0 section ".text.startup" !dbg !28 {
2013-05-11 05:52:07 +08:00
entry:
2021-09-20 12:03:20 +08:00
%call = call i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EL1e255EJLi1ELi2EEEiv ( ) , !dbg !31
store i32 %call , i32 * @glbl , align 4 , !dbg !32
ret void , !dbg !31
2013-05-11 05:52:07 +08:00
}
2021-09-20 12:03:20 +08:00
; Function Attrs: mustprogress noinline nounwind optnone uwtable
define linkonce_odr d s o _ l o c a l i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EL1e255EJLi1ELi2EEEiv ( ) #1 comdat !dbg !33 {
2013-05-11 05:52:07 +08:00
entry:
2021-09-20 12:03:20 +08:00
store i32 5 , i32 * @_Z3varIiE , align 4 , !dbg !48
%0 = load i32 , i32 * @_Z3varIiE , align 4 , !dbg !49
ret i32 %0 , !dbg !50
2013-05-11 05:52:07 +08:00
}
2018-10-04 02:44:53 +08:00
; Function Attrs: noinline uwtable
2021-09-20 12:03:20 +08:00
define internal void @_GLOBAL__sub_I_test.cpp ( ) #0 section ".text.startup" !dbg !51 {
2013-05-11 05:52:07 +08:00
entry:
2021-09-20 12:03:20 +08:00
call void @__cxx_global_var_init ( ) , !dbg !53
2014-12-17 08:43:22 +08:00
ret void
2013-05-11 05:52:07 +08:00
}
2021-09-20 12:03:20 +08:00
attributes #0 = { noinline uwtable "frame-pointer" = "all" "min-legal-vector-width" = "0" "no-trapping-math" = "true" "stack-protector-buffer-size" = "8" "target-cpu" = "x86-64" "target-features" = "+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu" = "generic" }
attributes #1 = { m u s t p r o g r e s s noinline nounwind optnone uwtable "frame-pointer" = "all" "min-legal-vector-width" = "0" "no-trapping-math" = "true" "stack-protector-buffer-size" = "8" "target-cpu" = "x86-64" "target-features" = "+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu" = "generic" }
2013-05-11 05:52:07 +08:00
2018-10-04 02:44:53 +08:00
!llvm.dbg.cu = ! { !2 }
2021-09-20 12:03:20 +08:00
!llvm.module.flags = ! { !22 , !23 , !24 , !25 , !26 }
!llvm.ident = ! { !27 }
2016-12-22 08:45:21 +08:00
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2021-09-20 12:03:20 +08:00
!1 = distinct !DIGlobalVariable ( name: "glbl" , scope: !2 , file: !3 , line: 8 , type: !17 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s _ 14 , file: !3 , producer: "clang version 14.0.0 (git@github.com:llvm/llvm-project.git d0046d018934b284c995408a117371606472cd2a)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , globals: !9 , splitDebugInlining: false , nameTableKind: N one )
!3 = !DIFile ( filename: "test.cpp" , directory: "" )
!4 = ! { !5 }
!5 = !DICompositeType ( tag: D W _ T A G _ e n u m e r a t i o n _ type , name: "e" , file: !3 , line: 2 , baseType: !6 , size: 8 , elements: !7 , identifier: "_ZTS1e" )
!6 = !DIBasicType ( name: "unsigned char" , size: 8 , encoding: D W _ A T E _ u n s i g n e d _ c h a r )
!7 = ! { !8 }
!8 = !DIEnumerator ( name: "E" , value: 255 , isUnsigned: true )
!9 = ! { !0 , !10 , !18 }
!10 = !DIGlobalVariableExpression ( var: !11 , expr: !DIExpression ( ) )
!11 = distinct !DIGlobalVariable ( name: "n" , scope: !2 , file: !3 , line: 9 , type: !12 , isLocal: false , isDefinition: true )
!12 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "nested" , scope: !13 , file: !3 , line: 7 , 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: !14 , identifier: "_ZTSN6y_implIiE6nestedE" )
!13 = 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: 7 , 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: !14 , templateParams: !15 , identifier: "_ZTS6y_implIiE" )
!14 = ! { }
2018-10-04 02:44:53 +08:00
!15 = ! { !16 }
2021-09-20 12:03:20 +08:00
!16 = !DITemplateTypeParameter ( type: !17 )
!17 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!18 = !DIGlobalVariableExpression ( var: !19 , expr: !DIExpression ( ) )
!19 = distinct !DIGlobalVariable ( name: "var" , linkageName: "_Z3varIiE" , scope: !2 , file: !3 , line: 1 , type: !17 , isLocal: false , isDefinition: true , templateParams: !20 )
!20 = ! { !21 }
!21 = !DITemplateTypeParameter ( name: "T" , type: !17 )
!22 = ! { i32 7 , !"Dwarf Version" , i32 4 }
!23 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!24 = ! { i32 1 , !"wchar_size" , i32 4 }
!25 = ! { i32 7 , !"uwtable" , i32 1 }
!26 = ! { i32 7 , !"frame-pointer" , i32 2 }
!27 = ! { !"clang version 14.0.0 (git@github.com:llvm/llvm-project.git d0046d018934b284c995408a117371606472cd2a)" }
!28 = distinct !DISubprogram ( name: "__cxx_global_var_init" , scope: !3 , file: !3 , type: !29 , flags: D I F l a g A r t i f i c i a l , spFlags: D I S P F l a g L o c a l T o U n i t | D I S P F l a g D e f i n i t i o n , unit: !2 , retainedNodes: !14 )
!29 = !DISubroutineType ( types: !30 )
!30 = ! { null }
!31 = !DILocation ( line: 8 , column: 12 , scope: !28 )
!32 = !DILocation ( line: 0 , scope: !28 )
!33 = distinct !DISubprogram ( name: "func<3, &glbl, y_impl, nullptr, E, 1, 2>" , linkageName: "_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EL1e255EJLi1ELi2EEEiv" , scope: !3 , file: !3 , line: 3 , type: !34 , scopeLine: 3 , flags: D I F l a g P r o t o t y p e d , spFlags: D I S P F l a g D e f i n i t i o n , unit: !2 , templateParams: !36 , retainedNodes: !14 )
!34 = !DISubroutineType ( types: !35 )
!35 = ! { !17 }
!36 = ! { !37 , !38 , !40 , !41 , !43 , !44 }
!37 = !DITemplateValueParameter ( name: "x" , type: !17 , value: i32 3 )
!38 = !DITemplateValueParameter ( type: !39 , value: i32 * @glbl )
!39 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !17 , size: 64 )
!40 = !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" )
!41 = !DITemplateValueParameter ( name: "n" , type: !42 , value: i8 0 )
!42 = !DIBasicType ( tag: D W _ T A G _ u n s p e c i f i e d _ type , name: "decltype(nullptr)" )
!43 = !DITemplateValueParameter ( type: !5 , value: i8 -1 )
!44 = !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: !45 )
!45 = ! { !46 , !47 }
!46 = !DITemplateValueParameter ( type: !17 , value: i32 1 )
!47 = !DITemplateValueParameter ( type: !17 , value: i32 2 )
!48 = !DILocation ( line: 4 , column: 11 , scope: !33 )
!49 = !DILocation ( line: 5 , column: 9 , scope: !33 )
!50 = !DILocation ( line: 5 , column: 2 , scope: !33 )
!51 = distinct !DISubprogram ( linkageName: "_GLOBAL__sub_I_test.cpp" , scope: !3 , file: !3 , type: !52 , flags: D I F l a g A r t i f i c i a l , spFlags: D I S P F l a g L o c a l T o U n i t | D I S P F l a g D e f i n i t i o n , unit: !2 , retainedNodes: !14 )
!52 = !DISubroutineType ( types: !14 )
!53 = !DILocation ( line: 0 , scope: !51 )