2017-09-21 21:52:03 +02:00
; RUN: llc %s -o %t.s
; RUN: llvm-mc %t.s -filetype=obj -triple=x86_64-windows-msvc -o %t.o
; RUN: FileCheck %s < %t.s --check-prefix=ASM
; RUN: llvm-dwarfdump %t.o | FileCheck %s --check-prefix=DWARF
[DebugInfo] Remove some users of DBG_VALUEs IsIndirect field
This patch kills off a significant user of the "IsIndirect" field of
DBG_VALUE machine insts. Brought up in in PR41675, IsIndirect is
techncally redundant as it can be expressed by the DIExpression of a
DBG_VALUE inst, and it isn't helpful to have two ways of expressing
things.
Rather than setting IsIndirect, have DBG_VALUE creators add an extra deref
to the insts DIExpression. There should now be no appearences of
IsIndirect=True from isel down to LiveDebugVariables / VirtRegRewriter,
which is ensured by an assertion in LDVImpl::handleDebugValue. This means
we also get to delete the IsIndirect handling in LiveDebugVariables. Tests
can be upgraded by for example swapping the following IsIndirect=True
DBG_VALUE:
DBG_VALUE $somereg, 0, !123, !DIExpression(DW_OP_foo)
With one where the indirection is in the DIExpression, by _appending_
a deref:
DBG_VALUE $somereg, $noreg, !123, !DIExpression(DW_OP_foo, DW_OP_deref)
Which both mean the same thing.
Most of the test changes in this patch are updates of that form; also some
changes in how the textual assembly printer handles these insts.
Differential Revision: https://reviews.llvm.org/D68945
llvm-svn: 374877
2019-10-15 12:46:24 +02:00
; XFAIL: *
; See PR41992, the third and final dbg.value disappears after
; LiveDebugVariables.
2017-09-21 21:52:03 +02:00
; In this example, the variable lives mostly in memory, but at the point of the
; assignment to global, it lives nowhere, and is described as the constant
; value 1.
; C source:
;
; void escape(int *);
; extern int global;
; void f(int x) {
; escape(&x);
; x = 1; // DSE should delete and insert dbg.value(i32 1)
; global = x;
; x = 2; // DSE should insert dbg.addr
; escape(&x);
; }
; ModuleID = 'dse.c'
source_filename = "dse.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24215"
declare void @llvm.dbg.addr ( metadata , metadata , metadata ) #2
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #2
declare void @escape ( i32 * )
@global = external global i32 , align 4
; Function Attrs: nounwind uwtable
define void @f ( i32 %x ) #0 !dbg !8 {
entry:
%x.addr = alloca i32 , align 4
store i32 %x , i32 * %x.addr , align 4
call void @llvm.dbg.addr ( metadata i32 * %x.addr , metadata !13 , metadata !DIExpression ( ) ) , !dbg !18
call void @escape ( i32 * %x.addr ) , !dbg !19
call void @llvm.dbg.value ( metadata i32 1 , metadata !13 , metadata !DIExpression ( ) ) , !dbg !20
store i32 1 , i32 * @global , align 4 , !dbg !22
call void @llvm.dbg.addr ( metadata i32 * %x.addr , metadata !13 , metadata !DIExpression ( ) ) , !dbg !23
store i32 2 , i32 * %x.addr , align 4 , !dbg !23
call void @escape ( i32 * %x.addr ) , !dbg !24
ret void , !dbg !25
}
; ASM-LABEL: f: # @f
[DebugInfo] Remove some users of DBG_VALUEs IsIndirect field
This patch kills off a significant user of the "IsIndirect" field of
DBG_VALUE machine insts. Brought up in in PR41675, IsIndirect is
techncally redundant as it can be expressed by the DIExpression of a
DBG_VALUE inst, and it isn't helpful to have two ways of expressing
things.
Rather than setting IsIndirect, have DBG_VALUE creators add an extra deref
to the insts DIExpression. There should now be no appearences of
IsIndirect=True from isel down to LiveDebugVariables / VirtRegRewriter,
which is ensured by an assertion in LDVImpl::handleDebugValue. This means
we also get to delete the IsIndirect handling in LiveDebugVariables. Tests
can be upgraded by for example swapping the following IsIndirect=True
DBG_VALUE:
DBG_VALUE $somereg, 0, !123, !DIExpression(DW_OP_foo)
With one where the indirection is in the DIExpression, by _appending_
a deref:
DBG_VALUE $somereg, $noreg, !123, !DIExpression(DW_OP_foo, DW_OP_deref)
Which both mean the same thing.
Most of the test changes in this patch are updates of that form; also some
changes in how the textual assembly printer handles these insts.
Differential Revision: https://reviews.llvm.org/D68945
llvm-svn: 374877
2019-10-15 12:46:24 +02:00
; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X:[0-9]+]], DW_OP_deref] $rsp
2019-06-06 23:19:39 +02:00
; ASM: movl %ecx, [[OFF_X]](%rsp)
2017-09-21 21:52:03 +02:00
; ASM: callq escape
; ASM: #DEBUG_VALUE: f:x <- 1
; ASM: movl $1, global(%rip)
[DebugInfo] Remove some users of DBG_VALUEs IsIndirect field
This patch kills off a significant user of the "IsIndirect" field of
DBG_VALUE machine insts. Brought up in in PR41675, IsIndirect is
techncally redundant as it can be expressed by the DIExpression of a
DBG_VALUE inst, and it isn't helpful to have two ways of expressing
things.
Rather than setting IsIndirect, have DBG_VALUE creators add an extra deref
to the insts DIExpression. There should now be no appearences of
IsIndirect=True from isel down to LiveDebugVariables / VirtRegRewriter,
which is ensured by an assertion in LDVImpl::handleDebugValue. This means
we also get to delete the IsIndirect handling in LiveDebugVariables. Tests
can be upgraded by for example swapping the following IsIndirect=True
DBG_VALUE:
DBG_VALUE $somereg, 0, !123, !DIExpression(DW_OP_foo)
With one where the indirection is in the DIExpression, by _appending_
a deref:
DBG_VALUE $somereg, $noreg, !123, !DIExpression(DW_OP_foo, DW_OP_deref)
Which both mean the same thing.
Most of the test changes in this patch are updates of that form; also some
changes in how the textual assembly printer handles these insts.
Differential Revision: https://reviews.llvm.org/D68945
llvm-svn: 374877
2019-10-15 12:46:24 +02:00
; ASM: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[OFF_X]], DW_OP_deref] $rsp
2017-09-21 21:52:03 +02:00
; ASM: movl $2, [[OFF_X]](%rsp)
; ASM: callq escape
; ASM: retq
; DWARF: DW_TAG_formal_parameter
; DWARF-NEXT: DW_AT_location (0x00000000
; DWARF-NEXT: {{[^:]*}}: DW_OP_breg7 RSP+{{[0-9]+}}
; DWARF-NEXT: {{[^:]*}}: DW_OP_consts +1, DW_OP_stack_value
2017-10-03 19:59:02 +02:00
; DWARF-NEXT: {{[^:]*}}: DW_OP_breg7 RSP+{{[0-9]+}})
2017-09-21 21:52:03 +02:00
; DWARF-NEXT: DW_AT_name ("x")
attributes #0 = { nounwind uwtable }
attributes #2 = { nounwind readnone s p e c u l a t a b l e }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 , !6 }
!llvm.ident = ! { !7 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 6.0.0 " , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "dse.c" , directory: "C:\5Csrc\5Cllvm-project\5Cbuild" )
!2 = ! { }
!3 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { i32 1 , !"wchar_size" , i32 2 }
!6 = ! { i32 7 , !"PIC Level" , i32 2 }
!7 = ! { !"clang version 6.0.0 " }
[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 04:40:45 +02:00
!8 = distinct !DISubprogram ( name: "f" , scope: !1 , file: !1 , line: 3 , type: !9 , isLocal: false , isDefinition: true , scopeLine: 3 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !12 )
2017-09-21 21:52:03 +02:00
!9 = !DISubroutineType ( types: !10 )
!10 = ! { null , !11 }
!11 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!12 = ! { !13 }
!13 = !DILocalVariable ( name: "x" , arg: 1 , scope: !8 , file: !1 , line: 3 , type: !11 )
!14 = ! { !15 , !15 , i64 0 }
!15 = ! { !"int" , !16 , i64 0 }
!16 = ! { !"omnipotent char" , !17 , i64 0 }
!17 = ! { !"Simple C/C++ TBAA" }
!18 = !DILocation ( line: 3 , column: 12 , scope: !8 )
!19 = !DILocation ( line: 4 , column: 3 , scope: !8 )
!20 = !DILocation ( line: 5 , column: 5 , scope: !8 )
!21 = !DILocation ( line: 6 , column: 12 , scope: !8 )
!22 = !DILocation ( line: 6 , column: 10 , scope: !8 )
!23 = !DILocation ( line: 7 , column: 5 , scope: !8 )
!24 = !DILocation ( line: 8 , column: 3 , scope: !8 )
!25 = !DILocation ( line: 9 , column: 1 , scope: !8 )