[Metadata] Extend 'count' field of DISubrange to take a metadata node
Summary:
This patch extends the DISubrange 'count' field to take either a
(signed) constant integer value or a reference to a DILocalVariable
or DIGlobalVariable.
This is patch [1/3] in a series to extend LLVM's DISubrange Metadata
node to support debugging of C99 variable length arrays and vectors with
runtime length like the Scalable Vector Extension for AArch64. It is
also a first step towards representing more complex cases like arrays
in Fortran.
Reviewers: echristo, pcc, aprantl, dexonsmith, clayborg, kristof.beyls, dblaikie
Reviewed By: aprantl
Subscribers: rnk, probinson, fhahn, aemerson, rengolin, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D41695
llvm-svn: 323313
2018-01-24 10:56:07 +01:00
; Check that the DISubrange 'count' reference is correctly uniqued and restored,
; since it can take the value of either a signed integer or a DIVariable.
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
define void @foo ( i32 %n ) {
entry:
%0 = zext i32 %n to i64
%vla = alloca i32 , i64 %0 , align 16
call void @llvm.dbg.declare ( metadata i32 * %vla , metadata !19 , metadata !12 ) , !dbg !18
ret void
}
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) #1
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 }
!llvm.ident = ! { !6 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 5.0.1" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "vla.c" , directory: "/path/to" )
!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 5.0.1" }
[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
!7 = distinct !DISubprogram ( name: "foo" , scope: !1 , file: !1 , line: 20 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 20 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !11 )
[Metadata] Extend 'count' field of DISubrange to take a metadata node
Summary:
This patch extends the DISubrange 'count' field to take either a
(signed) constant integer value or a reference to a DILocalVariable
or DIGlobalVariable.
This is patch [1/3] in a series to extend LLVM's DISubrange Metadata
node to support debugging of C99 variable length arrays and vectors with
runtime length like the Scalable Vector Extension for AArch64. It is
also a first step towards representing more complex cases like arrays
in Fortran.
Reviewers: echristo, pcc, aprantl, dexonsmith, clayborg, kristof.beyls, dblaikie
Reviewed By: aprantl
Subscribers: rnk, probinson, fhahn, aemerson, rengolin, JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D41695
llvm-svn: 323313
2018-01-24 10:56:07 +01:00
!8 = !DISubroutineType ( types: !9 )
!9 = ! { null , !10 }
!10 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!11 = ! { !16 , !19 }
!12 = !DIExpression ( )
!16 = !DILocalVariable ( name: "vla_expr" , scope: !7 , file: !1 , line: 21 , type: !17 )
!17 = !DIBasicType ( name: "long unsigned int" , size: 64 , encoding: D W _ A T E _ u n s i g n e d )
!18 = !DILocation ( line: 21 , column: 7 , scope: !7 )
!19 = !DILocalVariable ( name: "vla" , scope: !7 , file: !1 , line: 21 , type: !20 )
!20 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !10 , align: 32 , elements: !21 )
!21 = ! { !22 , !23 , !24 , !25 , !26 , !27 }
; CHECK-DAG: ![[NODE:[0-9]+]] = !DILocalVariable(name: "vla_expr"
; CHECK-DAG: ![[RANGE:[0-9]+]] = !DISubrange(count: ![[NODE]])
; CHECK-DAG: ![[CONST:[0-9]+]] = !DISubrange(count: 16)
; CHECK-DAG: ![[MULTI:[0-9]+]] = !{![[RANGE]], ![[RANGE]], ![[CONST]], ![[CONST]], ![[CONST]], ![[CONST]]}
; CHECK-DAG: elements: ![[MULTI]]
!22 = !DISubrange ( count: !16 )
!23 = !DISubrange ( count: !16 )
!24 = !DISubrange ( count: 16 )
!25 = !DISubrange ( count: i16 16 )
!26 = !DISubrange ( count: i32 16 )
!27 = !DISubrange ( count: i64 16 )