2017-09-21 02:19:08 +08:00
; RUN: llc < %s | FileCheck %s
; Make sure we insert DW_OP_deref when spilling indirect DBG_VALUE instructions.
; In this example, 'nt' is passed by address because it is not trivially
; copyable. When we spill the physical argument register at the barrier, we need
; to insert DW_OP_deref.
; #define FORCE_SPILL() \
; __asm volatile("" : : : \
; "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \
; "r9", "r10", "r11", "r12", "r13", "r14", "r15")
; struct NonTrivial {
; NonTrivial();
; ~NonTrivial();
; int i;
; };
; int foo(NonTrivial nt) {
; FORCE_SPILL();
; return nt.i;
; }
; CHECK-LABEL: _Z3foo10NonTrivial:
[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 18:46:24 +08:00
; CHECK: #DEBUG_VALUE: foo:nt <- [DW_OP_deref] $rdi
2017-09-21 02:19:08 +08:00
; CHECK: movq %rdi, -8(%rsp) # 8-byte Spill
2018-02-01 06:04:26 +08:00
; CHECK: #DEBUG_VALUE: foo:nt <- [DW_OP_constu 8, DW_OP_minus, DW_OP_deref] [$rsp+0]
2017-09-21 02:19:08 +08:00
; CHECK: #APP
; CHECK: #NO_APP
; CHECK: movq -8(%rsp), %rax # 8-byte Reload
; CHECK: movl (%rax), %eax
; ModuleID = 't.cpp'
source_filename = "t.cpp"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
%struct.NonTrivial = type { i32 }
; Function Attrs: nounwind uwtable
define i32 @_Z3foo10NonTrivial ( %struct.NonTrivial * nocapture readonly %nt ) local_unnamed_addr #0 !dbg !7 {
entry:
tail call void @llvm.dbg.declare ( metadata %struct.NonTrivial * %nt , metadata !20 , metadata !DIExpression ( ) ) , !dbg !21
tail call void asm sideeffect "" , "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}" ( ) #2 , !dbg !22 , !srcloc !23
%i = getelementptr inbounds %struct.NonTrivial , %struct.NonTrivial * %nt , i64 0 , i32 0 , !dbg !24
%0 = load i32 , i32 * %i , align 4 , !dbg !24 , !tbaa !25
ret i32 %0 , !dbg !30
}
; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind readnone s p e c u l a t a b l e }
attributes #2 = { nounwind }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 }
!llvm.ident = ! { !6 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , 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: "t.cpp" , 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 4 }
!6 = ! { !"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 10:40:45 +08:00
!7 = distinct !DISubprogram ( name: "foo" , linkageName: "_Z3foo10NonTrivial" , scope: !1 , file: !1 , line: 10 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 10 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !19 )
2017-09-21 02:19:08 +08:00
!8 = !DISubroutineType ( types: !9 )
!9 = ! { !10 , !11 }
!10 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!11 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "NonTrivial" , file: !1 , line: 5 , size: 32 , elements: !12 , identifier: "_ZTS10NonTrivial" )
!12 = ! { !13 , !14 , !18 }
!13 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "i" , scope: !11 , file: !1 , line: 8 , baseType: !10 , size: 32 )
!14 = !DISubprogram ( name: "NonTrivial" , scope: !11 , file: !1 , line: 6 , type: !15 , isLocal: false , isDefinition: false , scopeLine: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true )
!15 = !DISubroutineType ( types: !16 )
!16 = ! { null , !17 }
!17 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !11 , size: 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 )
!18 = !DISubprogram ( name: "~NonTrivial" , scope: !11 , file: !1 , line: 7 , type: !15 , isLocal: false , isDefinition: false , scopeLine: 7 , flags: D I F l a g P r o t o t y p e d , isOptimized: true )
!19 = ! { !20 }
!20 = !DILocalVariable ( name: "nt" , arg: 1 , scope: !7 , file: !1 , line: 10 , type: !11 )
!21 = !DILocation ( line: 10 , column: 20 , scope: !7 )
!22 = !DILocation ( line: 11 , column: 3 , scope: !7 )
!23 = ! { i32 -2147471481 }
!24 = !DILocation ( line: 12 , column: 13 , scope: !7 )
!25 = ! { !26 , !27 , i64 0 }
!26 = ! { !"_ZTS10NonTrivial" , !27 , i64 0 }
!27 = ! { !"int" , !28 , i64 0 }
!28 = ! { !"omnipotent char" , !29 , i64 0 }
!29 = ! { !"Simple C++ TBAA" }
!30 = !DILocation ( line: 12 , column: 3 , scope: !7 )