xref: /llvm-project/llvm/test/DebugInfo/dwarfdump-dataLocationExp.ll (revision 391f323690b9ef84d13a09ff07fb805008401fee)
1;; This test checks whether DW_AT_data_location attribute
2;; accepts DIExpression.
3; REQUIRES: x86_64-linux
4
5; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -filetype=obj -o %t.o
6; RUN: llvm-dwarfdump  %t.o | FileCheck %s
7
8;; Test whether DW_AT_data_location is generated.
9; CHECK-LABEL:  DW_TAG_array_type
10
11; CHECK:        DW_AT_data_location (DW_OP_constu 0x1a85)
12; CHECK:        DW_TAG_subrange_type
13
14;; Test case is hand written with the help of below testcase
15;;------------------------------
16;;program main
17;;integer, allocatable :: arr(:)
18;;allocate(arr(2:20))
19;;arr(2)=99
20;;print *, arr
21;;end program main
22;;------------------------------
23
24; ModuleID = 'fortsubrange.ll'
25source_filename = "fortsubrange.ll"
26target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
27target triple = "x86_64-unknown-linux-gnu"
28
29define void @MAIN_() !dbg !5 {
30L.entry:
31  %.Z0640_333 = alloca ptr, align 8
32  %"arr$sd1_349" = alloca [16 x i64], align 8
33  call void @llvm.dbg.declare(metadata ptr %"arr$sd1_349", metadata !8, metadata !DIExpression()), !dbg !14
34  call void @llvm.dbg.declare(metadata ptr %.Z0640_333, metadata !15, metadata !DIExpression()), !dbg !14
35  ret void, !dbg !17
36}
37
38; Function Attrs: nounwind readnone speculatable willreturn
39declare void @llvm.dbg.declare(metadata, metadata, metadata)
40
41; Function Attrs: nounwind readnone speculatable willreturn
42declare void @llvm.dbg.value(metadata, metadata, metadata)
43
44!llvm.module.flags = !{!0, !1}
45!llvm.dbg.cu = !{!2}
46
47!0 = !{i32 2, !"Dwarf Version", i32 4}
48!1 = !{i32 2, !"Debug Info Version", i32 3}
49!2 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !3, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !4, globals: !4, imports: !4)
50!3 = !DIFile(filename: "fortsubrange.f90", directory: "/dir")
51!4 = !{}
52!5 = distinct !DISubprogram(name: "main", scope: !2, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
53!6 = !DISubroutineType(cc: DW_CC_program, types: !7)
54!7 = !{null}
55!8 = !DILocalVariable(name: "arr", scope: !9, file: !3, type: !10)
56!9 = !DILexicalBlock(scope: !5, file: !3, line: 1, column: 1)
57;; We intend to use DW_OP_push_object_address, since that is not available yet,
58;; we are using meaning less expression
59;;!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 32, align: 32, elements: !12, dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref))
60!10 = !DICompositeType(tag: DW_TAG_array_type, baseType: !11, size: 32, align: 32, elements: !12, dataLocation: !DIExpression(DW_OP_constu, 6789))
61!11 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
62!12 = !{!13}
63!13 = !DISubrange(count: 19, lowerBound: 2)
64!14 = !DILocation(line: 0, scope: !9)
65!15 = distinct !DILocalVariable(scope: !9, file: !3, type: !16, flags: DIFlagArtificial)
66!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 32, align: 32)
67!17 = !DILocation(line: 6, column: 1, scope: !9)
68