2015-09-16 05:34:32 +00:00
; REQUIRES: default_triple, object-emission
2014-03-14 23:08:25 +00:00
;
2016-04-17 00:26:17 +00:00
; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - \
2016-04-18 22:41:41 +00:00
; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
2016-04-17 00:26:17 +00:00
; RUN: | llvm-dwarfdump -debug-dump=info - \
; RUN: | FileCheck %s
2016-04-17 02:30:20 +00:00
; RUN: llvm-link %p/type-unique-odr-b.ll %s -S -o - \
2016-04-18 22:41:41 +00:00
; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
2016-04-17 02:30:20 +00:00
; RUN: | llvm-dwarfdump -debug-dump=info - \
; RUN: | FileCheck %s
2014-03-14 23:08:25 +00:00
;
; Test ODR-based type uniquing for C++ class members.
; rdar://problem/15851313.
;
; $ cat -n type-unique-odr-a.cpp
; 1 class A {
; 2 int data;
; 3 protected:
; 4 void getFoo();
; 5 };
; 6
; 7 static void bar() {
; 8 A a;
; 9 }
; 10
; 11 void baz() { bar(); }
;; #include "ab.h"
; foo_t bar() {
; return A().getFoo();
; }
;
; CHECK: DW_TAG_class_type
; CHECK-NEXT: DW_AT_name {{.*}} "A"
2016-04-17 00:26:17 +00:00
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_member
; CHECK-NEXT: DW_AT_name {{.*}} "data"
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_subprogram
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_linkage_name {{.*}} "_ZN1A6getFooEv"
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_name {{.*}} "getFoo"
; Ensure that there aren't any other subprograms in class A.
; CHECK-NOT: DW_TAG
; CHECK: DW_TAG_formal_parameter
; CHECK-NOT: DW_TAG
; CHECK: NULL
; CHECK-NOT: DW_TAG
; CHECK: NULL
2014-03-14 23:08:29 +00:00
; CHECK-NOT: DW_TAG
2016-04-17 00:26:17 +00:00
; CHECK: DW_TAG_base_type
2014-03-14 23:08:25 +00:00
2016-04-17 00:26:17 +00:00
; Ensure that getFoo and A are only emitted once.
2014-10-06 03:36:31 +00:00
; CHECK-NOT: AT_name{{.*(getFoo)|("A")}}
2014-03-14 23:08:25 +00:00
; ModuleID = 'type-unique-odr-a.cpp'
%class.A = type { i32 }
; Function Attrs: nounwind
2015-11-05 22:03:56 +00:00
define void @_Z3bazv ( ) #0 !dbg !15 {
2014-03-14 23:08:25 +00:00
entry:
call void @_ZL3barv ( ) , !dbg !23
ret void , !dbg !23
}
; Function Attrs: nounwind
2015-11-05 22:03:56 +00:00
define internal void @_ZL3barv ( ) #0 !dbg !19 {
2014-03-14 23:08:25 +00:00
entry:
%a = alloca %class.A , align 4
2015-04-29 16:38:44 +00:00
call void @llvm.dbg.declare ( metadata %class.A * %a , metadata !24 , metadata !DIExpression ( ) ) , !dbg !25
2014-03-14 23:08:25 +00:00
ret void , !dbg !26
}
; Function Attrs: nounwind readnone
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
2014-03-14 23:08:25 +00:00
attributes #0 = { nounwind }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !20 , !21 }
!llvm.ident = ! { !22 }
2016-04-15 15:57:41 +00:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , producer: "clang version 3.5.0 " , isOptimized: false , emissionKind: F u l l D e b u g , file: !1 , enums: !2 , retainedTypes: !3 , globals: !2 , imports: !2 )
2015-04-29 16:38:44 +00:00
!1 = !DIFile ( filename: "<unknown>" , directory: "" )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!2 = ! { }
!3 = ! { !4 }
2015-04-29 16:38:44 +00:00
!4 = !DICompositeType ( tag: D W _ T A G _ c l a s s _ type , name: "A" , line: 1 , size: 32 , align: 32 , file: !5 , elements: !6 , identifier: "_ZTS1A" )
!5 = !DIFile ( filename: "type-unique-odr-a.cpp" , directory: "" )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!6 = ! { !7 , !9 }
2016-04-23 21:08:00 +00:00
!7 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "data" , line: 2 , size: 32 , align: 32 , flags: D I F l a g P r i v a t e , file: !5 , scope: !4 , baseType: !8 )
2015-04-29 16:38:44 +00:00
!8 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
2016-04-23 21:08:00 +00:00
!9 = !DISubprogram ( name: "getFoo" , linkageName: "_ZN1A6getFooEv" , line: 4 , isLocal: false , isDefinition: false , virtualIndex: 6 , flags: D I F l a g P r o t e c t e d | D I F l a g P r o t o t y p e d , isOptimized: false , scopeLine: 4 , file: !5 , scope: !4 , type: !10 )
2015-04-29 16:38:44 +00:00
!10 = !DISubroutineType ( types: !11 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!11 = ! { null , !12 }
2016-04-23 21:08:00 +00:00
!12 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , 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 , baseType: !4 )
2016-04-15 15:57:41 +00:00
!15 = distinct !DISubprogram ( name: "baz" , linkageName: "_Z3bazv" , line: 11 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 11 , file: !5 , scope: !16 , type: !17 , variables: !2 )
2015-04-29 16:38:44 +00:00
!16 = !DIFile ( filename: "type-unique-odr-a.cpp" , directory: "" )
!17 = !DISubroutineType ( types: !18 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!18 = ! { null }
2016-04-15 15:57:41 +00:00
!19 = distinct !DISubprogram ( name: "bar" , linkageName: "_ZL3barv" , line: 7 , isLocal: true , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , scopeLine: 7 , file: !5 , scope: !16 , type: !17 , variables: !2 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!20 = ! { i32 2 , !"Dwarf Version" , i32 4 }
2015-03-03 17:24:31 +00:00
!21 = ! { i32 1 , !"Debug Info Version" , i32 3 }
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224257 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 19:07:53 +00:00
!22 = ! { !"clang version 3.5.0 " }
2015-04-29 16:38:44 +00:00
!23 = !DILocation ( line: 11 , scope: !15 )
2016-04-23 21:08:00 +00:00
!24 = !DILocalVariable ( name: "a" , line: 8 , scope: !19 , file: !16 , type: !4 )
2015-04-29 16:38:44 +00:00
!25 = !DILocation ( line: 8 , scope: !19 )
!26 = !DILocation ( line: 9 , scope: !19 )