2014-04-02 07:19:23 +08:00
; RUN: llc -O1 -filetype=obj -mtriple=x86_64-apple-darwin < %s > %t
2020-09-15 12:30:46 +08:00
; RUN: llvm-dwarfdump -v %t | FileCheck %s --check-prefixes=CHECK,DWARFv4
2020-03-16 07:17:52 +08:00
; RUN: llvm-objdump -r %t | FileCheck --check-prefix=DARWIN %s
2020-09-15 12:30:46 +08:00
2014-04-02 07:19:23 +08:00
; RUN: llc -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t
2020-09-15 12:30:46 +08:00
; RUN: llvm-dwarfdump -v %t | FileCheck %s --check-prefixes=CHECK,DWARFv4
; RUN: llvm-objdump -r %t | FileCheck --check-prefix=LINUX %s
; RUN: llc -dwarf-version=3 -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t
; RUN: llvm-dwarfdump -debug-info -v %t | FileCheck %s --check-prefixes=CHECK,DWARF32v3
; RUN: llvm-objdump -r %t | FileCheck --check-prefix=LINUX %s
; RUN: llc -dwarf64 -dwarf-version=3 -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t
; RUN: llvm-dwarfdump -debug-info -v %t | FileCheck %s --check-prefixes=CHECK,DWARF64v3
2020-03-16 07:17:52 +08:00
; RUN: llvm-objdump -r %t | FileCheck --check-prefix=LINUX %s
2014-04-02 07:19:23 +08:00
2012-06-22 09:25:12 +08:00
; PR9493
; Adapted from the original test case in r127757.
; We use 'llc -O1' to induce variable 'x' to live in different locations.
; We don't actually care where 'x' lives, or what exact optimizations get
; used, as long as 'x' moves around we're fine.
; // The variable 'x' lives in different locations, so it needs an entry in
; // the .debug_loc table section, referenced by DW_AT_location.
; // This ref is not relocatable on Darwin, and is relocatable elsewhere.
; extern int g(int, int);
; extern int a;
2018-01-16 19:17:57 +08:00
;
2012-06-22 09:25:12 +08:00
; void f(void) {
; int x;
; a = g(0, 0);
; x = 1;
; while (x & 1) { x *= a; }
; a = g(x, 0);
; x = 2;
; while (x & 2) { x *= a; }
; a = g(0, x);
; }
; // The 'x' variable and its symbol reference location
2014-04-02 07:19:23 +08:00
; CHECK: .debug_info contents:
; CHECK: DW_TAG_variable
2020-09-15 12:30:46 +08:00
; DWARF32v3-NEXT: DW_AT_location [DW_FORM_data4] (0x00000000
; DWARF64v3-NEXT: DW_AT_location [DW_FORM_data8] (0x00000000
; DWARFv4-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000
[DebugInfo] Nerf placeDbgValues, with prejudice
CodeGenPrepare::placeDebugValues moves variable location intrinsics to be
immediately after the Value they refer to. This makes tracking of locations
very easy; but it changes the order in which assignments appear to the
debugger, from the source programs order to the order in which the
optimised program computes values. This then leads to PR43986 and PR38754,
where variable locations that were in a conditional block are made
unconditional, which is highly misleading.
This patch adjusts placeDbgValues to only re-order variable location
intrinsics if they use a Value before it is defined, significantly reducing
the damage that it does. This is still not 100% safe, but the rest of
CodeGenPrepare needs polishing to correctly update debug info when
optimisations are performed to fully fix this.
This will probably break downstream debuginfo tests -- if the
instruction-stream position of variable location changes isn't the focus of
the test, an easy fix should be to manually apply placeDbgValues' behaviour
to the failing tests, moving dbg.value intrinsics next to SSA variable
definitions thus:
%foo = inst1
%bar = ...
%baz = ...
void call @llvm.dbg.value(metadata i32 %foo, ...
to
%foo = inst1
void call @llvm.dbg.value(metadata i32 %foo, ...
%bar = ...
%baz = ...
This should return your test to exercising whatever it was testing before.
Differential Revision: https://reviews.llvm.org/D58453
2019-12-09 19:26:44 +08:00
; Check that the location contains only 4 ranges.
; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}})
; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}})
Re-commit "DWARF location lists: Add section index dumping"
This reapplies c0f6ad7d1f3ccb9d0b9ce9ef8dfa06409ccf1b3e with an
additional fix in test/DebugInfo/X86/constant-loclist.ll, which had a
slightly different output on windows targets. The test now accounts for
this difference.
The original commit message follows.
Summary:
As discussed in D70081, this adds the ability to dump section
names/indices to the location list dumper. It does this by moving the
range specific logic from DWARFDie.cpp:dumpRanges into the
DWARFAddressRange class.
The trickiest part of this patch is the backflip in the meanings of the
two dump flags for the location list sections.
The dumping of "raw" location list data is now controlled by
"DisplayRawContents" flag. This frees up the "Verbose" flag to be used
to control whether we print the section index. Additionally, the
DisplayRawContents flag is set for section-based dumps whenever the
--verbose option is passed, but this is not done for the "inline" dumps.
Also note that the index dumping currently does not work for the DWARF
v5 location lists, as the parser does not fill out the appropriate
fields. This will be done in a separate patch.
Reviewers: dblaikie, probinson, JDevlieghere, SouraVX
Subscribers: sdardis, hiraditya, jrtc27, atanasyan, arphaman, aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70227
2019-11-14 18:22:00 +08:00
; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}})
; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}}){{.*}})
2014-04-02 07:19:23 +08:00
; CHECK-NEXT: DW_AT_name {{.*}} "x"
; CHECK-NEXT: DW_AT_decl_file
; CHECK-NEXT: DW_AT_decl_line
; CHECK-NEXT: DW_AT_type
; Check that we have no relocations in Darwin's output.
; DARWIN-NOT: X86_64_RELOC{{.*}} __debug_loc
2012-06-22 09:25:12 +08:00
2014-04-02 07:19:23 +08:00
; Check we have a relocation for the debug_loc entry in Linux output.
2019-05-07 21:14:18 +08:00
; LINUX: RELOCATION RECORDS FOR [.debug_info]
2014-04-02 07:19:23 +08:00
; LINUX-NOT: RELOCATION RECORDS
2018-06-01 13:31:58 +08:00
; LINUX: R_X86_64{{.*}} .debug_loc
2012-06-22 09:25:12 +08:00
; ModuleID = 'simple.c'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32"
@a = external global i32
2015-11-06 06:03:56 +08:00
define void @f ( ) nounwind !dbg !0 {
2012-06-22 09:25:12 +08:00
entry:
%call = tail call i32 @g ( i32 0 , i32 0 ) nounwind , !dbg !8
2013-05-01 01:52:57 +08:00
store i32 %call , i32 * @a , align 4 , !dbg !8
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 1 , metadata !5 , metadata !DIExpression ( ) ) , !dbg !13
2012-06-22 09:25:12 +08:00
br label %while.body
while.body: ; preds = %entry, %while.body
%x.017 = phi i32 [ 1 , %entry ] , [ %mul , %while.body ]
%mul = mul nsw i32 %call , %x.017 , !dbg !14
%and = and i32 %mul , 1 , !dbg !14
%tobool = icmp eq i32 %and , 0 , !dbg !14
br i1 %tobool , label %while.end , label %while.body , !dbg !14
while.end: ; preds = %while.body
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %mul , metadata !5 , metadata !DIExpression ( ) ) , !dbg !14
2012-06-22 09:25:12 +08:00
%call4 = tail call i32 @g ( i32 %mul , i32 0 ) nounwind , !dbg !15
2013-05-01 01:52:57 +08:00
store i32 %call4 , i32 * @a , align 4 , !dbg !15
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 2 , metadata !5 , metadata !DIExpression ( ) ) , !dbg !17
2012-06-22 09:25:12 +08:00
br label %while.body9
while.body9: ; preds = %while.end, %while.body9
%x.116 = phi i32 [ 2 , %while.end ] , [ %mul12 , %while.body9 ]
%mul12 = mul nsw i32 %call4 , %x.116 , !dbg !18
%and7 = and i32 %mul12 , 2 , !dbg !18
%tobool8 = icmp eq i32 %and7 , 0 , !dbg !18
br i1 %tobool8 , label %while.end13 , label %while.body9 , !dbg !18
while.end13: ; preds = %while.body9
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %mul12 , metadata !5 , metadata !DIExpression ( ) ) , !dbg !18
2012-06-22 09:25:12 +08:00
%call15 = tail call i32 @g ( i32 0 , i32 %mul12 ) nounwind , !dbg !19
2013-05-01 01:52:57 +08:00
store i32 %call15 , i32 * @a , align 4 , !dbg !19
2012-06-22 09:25:12 +08:00
ret void , !dbg !20
}
declare i32 @g ( i32 , i32 )
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) nounwind readnone
2012-06-22 09:25:12 +08:00
2013-03-08 08:23:31 +08:00
!llvm.dbg.cu = ! { !2 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !24 }
2012-06-22 09:25:12 +08:00
[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
!0 = distinct !DISubprogram ( name: "f" , line: 4 , 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: !2 , scopeLine: 4 , file: !23 , scope: !1 , type: !3 , retainedNodes: !22 )
2015-04-30 00:38:44 +08:00
!1 = !DIFile ( filename: "simple.c" , directory: "/home/rengol01/temp/tests/dwarf/relocation" )
2016-04-15 23:57:41 +08:00
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , producer: "clang version 3.0 (trunk)" , isOptimized: true , emissionKind: F u l l D e b u g , file: !23 , enums: ! { } , retainedTypes: ! { } , imports: null )
2015-04-30 00:38:44 +08:00
!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: "x" , line: 5 , scope: !6 , file: !1 , type: !7 )
2015-04-30 00:38:44 +08:00
!6 = distinct !DILexicalBlock ( line: 4 , column: 14 , file: !23 , scope: !0 )
!7 = !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 )
!8 = !DILocation ( line: 6 , column: 3 , 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
!12 = ! { i32 1 }
2015-04-30 00:38:44 +08:00
!13 = !DILocation ( line: 7 , column: 3 , scope: !6 )
!14 = !DILocation ( line: 8 , column: 3 , scope: !6 )
!15 = !DILocation ( line: 9 , column: 3 , 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
!16 = ! { i32 2 }
2015-04-30 00:38:44 +08:00
!17 = !DILocation ( line: 10 , column: 3 , scope: !6 )
!18 = !DILocation ( line: 11 , column: 3 , scope: !6 )
!19 = !DILocation ( line: 12 , column: 3 , scope: !6 )
!20 = !DILocation ( line: 13 , 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
!22 = ! { !5 }
2015-04-30 00:38:44 +08:00
!23 = !DIFile ( filename: "simple.c" , directory: "/home/rengol01/temp/tests/dwarf/relocation" )
2015-03-04 01:24:31 +08:00
!24 = ! { i32 1 , !"Debug Info Version" , i32 3 }