2017-09-12 06:59:45 +08:00
; RUN: llc < %s - -filetype=obj | llvm-dwarfdump -debug-loc - | FileCheck %s
2011-05-05 03:00:57 +08:00
; Radar 9376013
target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32"
target triple = "thumbv7-apple-macosx10.6.7"
2014-08-08 06:44:24 +08:00
; Just making sure the first part of the location isn't a repetition
; of the size of the location description.
DebugInfo: Fix a bunch of tests that, owing to their compile_unit metadata not including a 13th field, had some subtle behavior.
Without the 13th field, the "emission kind" field defaults to 0 (which
is not equal to either of the values of the emission kind enum (1 ==
full debug info, 2 == line tables only)).
In this particular instance, the comparison with "FullDebugInfo" was
done when adding elements to the ranges list - so for these test cases
no values were added to the ranges list.
This got weirder when emitting debug_loc entries as the addresses should
be relative to the range of the CU if the CU has only one range (the
reasonable assumption is that if we're emitting debug_loc lists for a CU
that CU has at least one range - but due to the above situation, it has
zero) so the ranges were emitted relative to the start of the section
rather than relative to the start of the CU's singular range.
Fix these tests by accounting for the difference in the description of
debug_loc entries (in some cases making the test ignorant to these
differences, in others adding the extra label difference expression,
etc) or the presence/absence of high/low_pc on the CU, and add the 13th
field to their CUs to enable proper "full debug info" emission here.
In a future commit I'll fix up a bunch of other test cases that are not
so rigorously depending on this behavior, but still doing similarly
weird things due to the missing 13th field.
llvm-svn: 214937
2014-08-06 07:57:31 +08:00
[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: 0x00000000:
2018-01-16 19:17:57 +08:00
; CHECK-NEXT: [0x{{[0-9]*[a-f]*}}, 0x{{[0-9]*[a-f]*}}): DW_OP_regx D8
2011-05-05 03:00:57 +08:00
2015-11-06 06:03:56 +08:00
define void @_Z3foov ( ) optsize ssp !dbg !1 {
2011-05-05 03:00:57 +08:00
entry:
%call = tail call float @_Z3barv ( ) optsize , !dbg !11
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata float %call , metadata !5 , metadata !DIExpression ( ) ) , !dbg !11
2011-05-05 03:00:57 +08:00
%call16 = tail call float @_Z2f2v ( ) optsize , !dbg !12
%cmp7 = fcmp olt float %call , %call16 , !dbg !12
br i1 %cmp7 , label %for.body , label %for.end , !dbg !12
for.body: ; preds = %entry, %for.body
%k.08 = phi float [ %inc , %for.body ] , [ %call , %entry ]
%call4 = tail call float @_Z2f3f ( float %k.08 ) optsize , !dbg !13
%inc = fadd float %k.08 , 1.000000e+00 , !dbg !14
%call1 = tail call float @_Z2f2v ( ) optsize , !dbg !12
%cmp = fcmp olt float %inc , %call1 , !dbg !12
br i1 %cmp , label %for.body , label %for.end , !dbg !12
for.end: ; preds = %for.body, %entry
ret void , !dbg !15
}
declare float @_Z3barv ( ) optsize
declare float @_Z2f2v ( ) optsize
declare float @_Z2f3f ( float ) optsize
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) nounwind readnone
2011-05-05 03:00:57 +08:00
!llvm.dbg.cu = ! { !0 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !20 }
2011-05-05 03:00:57 +08:00
2016-04-15 23:57:41 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , producer: "clang version 3.0 (trunk 130845)" , isOptimized: true , emissionKind: F u l l D e b u g , file: !18 , enums: !19 , retainedTypes: !19 , imports: null )
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!1 = distinct !DISubprogram ( name: "foo" , linkageName: "_Z3foov" , line: 5 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , scopeLine: 5 , file: !18 , scope: !2 , type: !3 , retainedNodes: !17 )
2015-04-30 00:38:44 +08:00
!2 = !DIFile ( filename: "k.cc" , directory: "/private/tmp" )
!3 = !DISubroutineType ( types: !4 )
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.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!4 = ! { null }
2015-08-01 02:58:39 +08:00
!5 = !DILocalVariable ( name: "k" , line: 6 , scope: !6 , file: !2 , type: !7 )
2015-04-30 00:38:44 +08:00
!6 = distinct !DILexicalBlock ( line: 5 , column: 12 , file: !18 , scope: !1 )
!7 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "float" , size: 32 , align: 32 , encoding: D W _ A T E _ float )
2015-08-01 02:58:39 +08:00
!8 = !DILocalVariable ( name: "y" , line: 8 , scope: !9 , file: !2 , type: !7 )
2015-04-30 00:38:44 +08:00
!9 = distinct !DILexicalBlock ( line: 7 , column: 25 , file: !18 , scope: !10 )
!10 = distinct !DILexicalBlock ( line: 7 , column: 3 , file: !18 , scope: !6 )
!11 = !DILocation ( line: 6 , column: 18 , scope: !6 )
!12 = !DILocation ( line: 7 , column: 3 , scope: !6 )
!13 = !DILocation ( line: 8 , column: 20 , scope: !9 )
!14 = !DILocation ( line: 7 , column: 20 , scope: !10 )
!15 = !DILocation ( line: 10 , column: 1 , scope: !6 )
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.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!17 = ! { !5 , !8 }
2015-04-30 00:38:44 +08:00
!18 = !DIFile ( filename: "k.cc" , directory: "/private/tmp" )
2015-03-28 04:46:33 +08:00
!19 = ! { }
2015-03-04 01:24:31 +08:00
!20 = ! { i32 1 , !"Debug Info Version" , i32 3 }