2014-04-29 04:27:02 +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
2014-04-29 04:27:02 +08:00
; From source:
; struct foo {
; int __attribute__((always_inline)) func(int x) { return x + 2; }
; };
; int i;
; int main() {
; return foo().func(i);
; }
2014-05-28 02:37:48 +08:00
; CHECK: DW_TAG_structure_type
; CHECK: DW_TAG_subprogram
; But make sure we emit DW_AT_object_pointer on the abstract definition.
; CHECK: [[ABSTRACT_ORIGIN:.*]]: DW_TAG_subprogram
2014-10-06 11:36:31 +08:00
; CHECK-NOT: {{NULL|TAG}}
; CHECK: DW_AT_specification {{.*}} "_ZN3foo4funcEi"
; CHECK-NOT: {{NULL|TAG}}
2014-05-28 02:37:48 +08:00
; CHECK: DW_AT_object_pointer
2014-04-29 04:27:02 +08:00
; Ensure we omit DW_AT_object_pointer on inlined subroutines.
; CHECK: DW_TAG_inlined_subroutine
2014-10-06 11:36:31 +08:00
; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[ABSTRACT_ORIGIN]]} "_ZN3foo4funcEi"
2014-04-29 04:27:02 +08:00
; CHECK-NOT: NULL
; CHECK-NOT: DW_AT_object_pointer
2014-05-01 06:41:33 +08:00
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_AT_artificial
2014-04-29 04:27:02 +08:00
; CHECK: DW_TAG
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/inline-member-function.ll"
2014-04-29 04:27:02 +08:00
%struct.foo = type { i8 }
2016-12-22 08:45:21 +08:00
@i = global i32 0 , align 4 , !dbg !0
2014-04-29 04:27:02 +08:00
; Function Attrs: uwtable
2016-12-22 08:45:21 +08:00
define i32 @main ( ) #0 !dbg !17 {
2014-04-29 04:27:02 +08:00
entry:
%this.addr.i = alloca %struct.foo * , align 8
%x.addr.i = alloca i32 , align 4
%retval = alloca i32 , align 4
%tmp = alloca %struct.foo , align 1
store i32 0 , i32 * %retval
2016-12-22 08:45:21 +08:00
%0 = load i32 , i32 * @i , align 4 , !dbg !20
2014-04-29 04:27:02 +08:00
store %struct.foo * %tmp , %struct.foo * * %this.addr.i , align 8
2016-12-22 08:45:21 +08:00
call void @llvm.dbg.declare ( metadata %struct.foo * * %this.addr.i , metadata !21 , metadata !24 ) , !dbg !25
2014-04-29 04:27:02 +08:00
store i32 %0 , i32 * %x.addr.i , align 4
2016-12-22 08:45:21 +08:00
call void @llvm.dbg.declare ( metadata i32 * %x.addr.i , metadata !26 , metadata !24 ) , !dbg !27
2015-02-28 05:17:42 +08:00
%this1.i = load %struct.foo * , %struct.foo * * %this.addr.i
2016-12-22 08:45:21 +08:00
%1 = load i32 , i32 * %x.addr.i , align 4 , !dbg !27
%add.i = add nsw i32 %1 , 2 , !dbg !27
ret i32 %add.i , !dbg !20
2014-04-29 04:27:02 +08:00
}
; Function Attrs: nounwind readnone
2016-12-22 08:45:21 +08:00
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
llvm-svn: 218787
2014-10-02 02:55:02 +08:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
2014-04-29 04:27:02 +08:00
attributes #0 = { uwtable "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "stack-protector-buffer-size" = "8" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #1 = { nounwind readnone }
2016-12-22 08:45:21 +08:00
!llvm.dbg.cu = ! { !4 }
!llvm.module.flags = ! { !14 , !15 }
!llvm.ident = ! { !16 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "i" , scope: null , file: !2 , line: 5 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "inline.cpp" , directory: "/tmp/dbginfo" )
!3 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!4 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !2 , producer: "clang version 3.5.0 " , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !5 , retainedTypes: !6 , globals: !13 , imports: !5 )
!5 = ! { }
!6 = ! { !7 }
!7 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "foo" , file: !2 , line: 1 , size: 8 , align: 8 , elements: !8 , identifier: "_ZTS3foo" )
!8 = ! { !9 }
!9 = !DISubprogram ( name: "func" , linkageName: "_ZN3foo4funcEi" , scope: !7 , file: !2 , line: 2 , type: !10 , isLocal: false , isDefinition: false , scopeLine: 2 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false )
!10 = !DISubroutineType ( types: !11 )
!11 = ! { !3 , !12 , !3 }
!12 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !7 , size: 64 , align: 64 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
!13 = ! { !0 }
!14 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!15 = ! { i32 1 , !"Debug Info Version" , i32 3 }
!16 = ! { !"clang version 3.5.0 " }
!17 = distinct !DISubprogram ( name: "main" , scope: !2 , file: !2 , line: 7 , type: !18 , isLocal: false , isDefinition: true , scopeLine: 7 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !4 , variables: !5 )
!18 = !DISubroutineType ( types: !19 )
!19 = ! { !3 }
!20 = !DILocation ( line: 8 , scope: !17 )
!21 = !DILocalVariable ( name: "this" , arg: 1 , scope: !22 , type: !23 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
!22 = distinct !DISubprogram ( name: "func" , linkageName: "_ZN3foo4funcEi" , scope: !7 , file: !2 , line: 2 , type: !10 , isLocal: false , isDefinition: true , scopeLine: 2 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !4 , declaration: !9 , variables: !5 )
!23 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !7 , size: 64 , align: 64 )
!24 = !DIExpression ( )
!25 = !DILocation ( line: 0 , scope: !22 , inlinedAt: !20 )
!26 = !DILocalVariable ( name: "x" , arg: 2 , scope: !22 , file: !2 , line: 2 , type: !3 )
!27 = !DILocation ( line: 2 , scope: !22 , inlinedAt: !20 )