2014-05-14 01:08:28 +00:00
; REQUIRES: object-emission
; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
; bool f();
; inline __attribute__((always_inline)) int f1() {
; if (bool b = f())
; return 1;
; return 2;
; }
;
; inline __attribute__((always_inline)) int f2() {
; # 2 "y.cc"
; if (bool b = f())
; return 3;
; return 4;
; }
;
; int main() {
; f1();
; f2();
; }
; Ensure that lexical_blocks within inlined_subroutines are preserved/emitted.
; CHECK: DW_TAG_inlined_subroutine
; CHECK-NOT: DW_TAG
; CHECK-NOT: NULL
; CHECK: DW_TAG_lexical_block
; CHECK-NOT: DW_TAG
; CHECK-NOT: NULL
; CHECK: DW_TAG_variable
; Ensure that file changes don't interfere with creating inlined subroutines.
; (see the line directive inside 'f2' in thesource)
; CHECK: DW_TAG_inlined_subroutine
2014-05-25 18:11:35 +00:00
; CHECK: DW_TAG_variable
; CHECK-NOT: DW_TAG
; CHECK: DW_AT_abstract_origin
2014-05-14 01:08:28 +00:00
; Function Attrs: uwtable
define i32 @main ( ) #0 {
entry:
%retval.i2 = alloca i32 , align 4
%b.i3 = alloca i8 , align 1
%retval.i = alloca i32 , align 4
%b.i = alloca i8 , align 1
2015-03-03 17:24:31 +00:00
call void @llvm.dbg.declare ( metadata i8 * %b.i , metadata !16 , metadata !MDExpression ( ) ) , !dbg !19
2014-05-14 01:08:28 +00:00
%call.i = call zeroext i1 @_Z1fv ( ) , !dbg !19
%frombool.i = zext i1 %call.i to i8 , !dbg !19
store i8 %frombool.i , i8 * %b.i , align 1 , !dbg !19
2015-02-27 21:17:42 +00:00
%0 = load i8 , i8 * %b.i , align 1 , !dbg !19
2014-05-14 01:08:28 +00:00
%tobool.i = trunc i8 %0 to i1 , !dbg !19
br i1 %tobool.i , label %if.then.i , label %if.end.i , !dbg !19
if.then.i: ; preds = %entry
store i32 1 , i32 * %retval.i , !dbg !21
br label %_Z2f1v.exit , !dbg !21
if.end.i: ; preds = %entry
store i32 2 , i32 * %retval.i , !dbg !22
br label %_Z2f1v.exit , !dbg !22
_Z2f1v.exit: ; preds = %if.then.i, %if.end.i
2015-02-27 21:17:42 +00:00
%1 = load i32 , i32 * %retval.i , !dbg !23
2015-03-03 17:24:31 +00:00
call void @llvm.dbg.declare ( metadata i8 * %b.i3 , metadata !24 , metadata !MDExpression ( ) ) , !dbg !27
2014-05-14 01:08:28 +00:00
%call.i4 = call zeroext i1 @_Z1fv ( ) , !dbg !27
%frombool.i5 = zext i1 %call.i4 to i8 , !dbg !27
store i8 %frombool.i5 , i8 * %b.i3 , align 1 , !dbg !27
2015-02-27 21:17:42 +00:00
%2 = load i8 , i8 * %b.i3 , align 1 , !dbg !27
2014-05-14 01:08:28 +00:00
%tobool.i6 = trunc i8 %2 to i1 , !dbg !27
br i1 %tobool.i6 , label %if.then.i7 , label %if.end.i8 , !dbg !27
if.then.i7: ; preds = %_Z2f1v.exit
store i32 3 , i32 * %retval.i2 , !dbg !29
br label %_Z2f2v.exit , !dbg !29
if.end.i8: ; preds = %_Z2f1v.exit
store i32 4 , i32 * %retval.i2 , !dbg !30
br label %_Z2f2v.exit , !dbg !30
_Z2f2v.exit: ; preds = %if.then.i7, %if.end.i8
2015-02-27 21:17:42 +00:00
%3 = load i32 , i32 * %retval.i2 , !dbg !31
2014-05-14 01:08:28 +00:00
ret i32 0 , !dbg !32
}
; 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-05-14 01:08:28 +00:00
declare zeroext i1 @_Z1fv ( ) #2
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 }
attributes #2 = { "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" }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !13 , !14 }
!llvm.ident = ! { !15 }
2015-03-03 17:24:31 +00:00
!0 = !MDCompileUnit ( 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: 1 , file: !1 , enums: !2 , retainedTypes: !2 , subprograms: !3 , globals: !2 , imports: !2 )
!1 = !MDFile ( filename: "inline-scopes.cpp" , directory: "/tmp/dbginfo" )
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 , !10 , !12 }
2015-03-03 17:24:31 +00:00
!4 = !MDSubprogram ( name: "main" , line: 7 , 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 , scopeLine: 7 , file: !5 , scope: !6 , type: !7 , function: i32 ( ) * @main , variables: !2 )
!5 = !MDFile ( filename: "y.cc" , directory: "/tmp/dbginfo" )
!6 = !MDFile ( filename: "y.cc" , directory: "/tmp/dbginfo" )
!7 = !MDSubroutineType ( types: !8 )
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
!8 = ! { !9 }
2015-03-03 17:24:31 +00:00
!9 = !MDBasicType ( 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 )
!10 = !MDSubprogram ( name: "f2" , linkageName: "_Z2f2v" , line: 8 , 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 , scopeLine: 8 , file: !1 , scope: !11 , type: !7 , variables: !2 )
!11 = !MDFile ( filename: "inline-scopes.cpp" , directory: "/tmp/dbginfo" )
!12 = !MDSubprogram ( name: "f1" , linkageName: "_Z2f1v" , line: 2 , 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 , scopeLine: 2 , file: !1 , scope: !11 , type: !7 , 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
!13 = ! { i32 2 , !"Dwarf Version" , i32 4 }
2015-03-03 17:24:31 +00:00
!14 = ! { 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
!15 = ! { !"clang version 3.5.0 " }
2015-03-03 17:24:31 +00:00
!16 = !MDLocalVariable ( tag: D W _ T A G _ a u t o _ v a r i a b l e , name: "b" , line: 3 , scope: !17 , file: !11 , type: !18 )
!17 = distinct !MDLexicalBlock ( line: 3 , column: 0 , file: !1 , scope: !12 )
!18 = !MDBasicType ( tag: D W _ T A G _ b a s e _ type , name: "bool" , size: 8 , align: 8 , encoding: D W _ A T E _ b o o l e a n )
2015-01-14 22:27:36 +00:00
!19 = !MDLocation ( line: 3 , scope: !17 , inlinedAt: !20 )
!20 = !MDLocation ( line: 8 , scope: !4 )
!21 = !MDLocation ( line: 4 , scope: !17 , inlinedAt: !20 )
!22 = !MDLocation ( line: 5 , scope: !12 , inlinedAt: !20 )
!23 = !MDLocation ( line: 6 , scope: !12 , inlinedAt: !20 )
2015-03-03 17:24:31 +00:00
!24 = !MDLocalVariable ( tag: D W _ T A G _ a u t o _ v a r i a b l e , name: "b" , line: 2 , scope: !25 , file: !6 , type: !18 )
!25 = distinct !MDLexicalBlock ( line: 2 , column: 0 , file: !5 , scope: !26 )
!26 = !MDLexicalBlockFile ( discriminator: 0 , file: !5 , scope: !10 )
2015-01-14 22:27:36 +00:00
!27 = !MDLocation ( line: 2 , scope: !25 , inlinedAt: !28 )
!28 = !MDLocation ( line: 9 , scope: !4 )
!29 = !MDLocation ( line: 3 , scope: !25 , inlinedAt: !28 )
!30 = !MDLocation ( line: 4 , scope: !26 , inlinedAt: !28 )
!31 = !MDLocation ( line: 5 , scope: !26 , inlinedAt: !28 )
!32 = !MDLocation ( line: 10 , scope: !4 )