summaryrefslogtreecommitdiffstats
path: root/llvm/test/Bitcode
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2018-01-24 09:56:07 +0000
committerSander de Smalen <sander.desmalen@arm.com>2018-01-24 09:56:07 +0000
commitfdf40917d946e3b36fd67afb2aac4063af9fc85d (patch)
tree9f0bac9e282261c26720ea14594ddb76e35f5d2f /llvm/test/Bitcode
parente8404780c38e44ccbbc1cd89873929ed4c49dac0 (diff)
downloadbcm5719-llvm-fdf40917d946e3b36fd67afb2aac4063af9fc85d.tar.gz
bcm5719-llvm-fdf40917d946e3b36fd67afb2aac4063af9fc85d.zip
[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
Diffstat (limited to 'llvm/test/Bitcode')
-rw-r--r--llvm/test/Bitcode/disubrange-v0.ll41
-rw-r--r--llvm/test/Bitcode/disubrange-v0.ll.bcbin0 -> 1492 bytes
-rw-r--r--llvm/test/Bitcode/disubrange.ll49
3 files changed, 90 insertions, 0 deletions
diff --git a/llvm/test/Bitcode/disubrange-v0.ll b/llvm/test/Bitcode/disubrange-v0.ll
new file mode 100644
index 00000000000..2d4cd187144
--- /dev/null
+++ b/llvm/test/Bitcode/disubrange-v0.ll
@@ -0,0 +1,41 @@
+; Check that a DISubrange built with an older version of LLVM is correctly restored.
+; RUN: llvm-dis < %s.bc | FileCheck %s
+; RUN: llvm-dis < %s.bc | llvm-as | llvm-dis | FileCheck %s
+
+define void @foo(i32 %n) {
+entry:
+ %array = alloca i32, i64 42, align 16
+ call void @llvm.dbg.declare(metadata i32* %array, 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: DW_LANG_C99, file: !1, producer: "clang version 5.0.1", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, 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"}
+!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 20, type: !8, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !11)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null, !10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!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: DW_ATE_unsigned)
+!18 = !DILocation(line: 21, column: 7, scope: !7)
+!19 = !DILocalVariable(name: "array", scope: !7, file: !1, line: 21, type: !20)
+!20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, align: 32, elements: !21)
+!21 = !{!22}
+; CHECK-DAG: ![[NODE:[0-9]+]] = !DILocalVariable(name: "array"
+; CHECK-DAG: ![[CONST:[0-9]+]] = !DISubrange(count: 42, lowerBound: 1)
+; CHECK-DAG: ![[MULTI:[0-9]+]] = !{![[CONST]]}
+; CHECK-DAG: elements: ![[MULTI]]
+!22 = !DISubrange(count: 42, lowerBound: 1)
diff --git a/llvm/test/Bitcode/disubrange-v0.ll.bc b/llvm/test/Bitcode/disubrange-v0.ll.bc
new file mode 100644
index 00000000000..7b7d85e0d60
--- /dev/null
+++ b/llvm/test/Bitcode/disubrange-v0.ll.bc
Binary files differ
diff --git a/llvm/test/Bitcode/disubrange.ll b/llvm/test/Bitcode/disubrange.ll
new file mode 100644
index 00000000000..5c725099ae3
--- /dev/null
+++ b/llvm/test/Bitcode/disubrange.ll
@@ -0,0 +1,49 @@
+; 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: DW_LANG_C99, file: !1, producer: "clang version 5.0.1", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, 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"}
+!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 20, type: !8, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !11)
+!8 = !DISubroutineType(types: !9)
+!9 = !{null, !10}
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!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: DW_ATE_unsigned)
+!18 = !DILocation(line: 21, column: 7, scope: !7)
+!19 = !DILocalVariable(name: "vla", scope: !7, file: !1, line: 21, type: !20)
+!20 = !DICompositeType(tag: DW_TAG_array_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)
OpenPOWER on IntegriCloud