1; RUN: llc %s -O2 -filetype=obj -o %t.o
2; RUN: llvm-dwarfdump  %t.o | FileCheck %s
3
4; Test whether DW_AT_data_location is generated.
5; CHECK-LABEL:  DW_TAG_array_type
6; CHECK:        DW_AT_allocated (DW_OP_push_object_address, DW_OP_deref)
7; CHECK-NOT: DW_TAG
8; CHECK:       DW_TAG_subrange_type
9
10; Test case is hand written with the help of below testcase
11;------------------------------
12;program main
13;integer, allocatable :: arr(:)
14;allocate(arr(2:20))
15;arr(2)=99
16;print *, arr
17;end program main
18;------------------------------
19
20; ModuleID = 'allocated.ll'
21source_filename = "allocated.ll"
22target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-unknown-linux-gnu"
24
25define void @MAIN_() !dbg !5 {
26L.entry:
27  %.Z0640_333 = alloca i32*, align 8
28  %"arr$sd1_349" = alloca [16 x i64], align 8
29  call void @llvm.dbg.declare(metadata [16 x i64]* %"arr$sd1_349", metadata !8, metadata !DIExpression()), !dbg !13
30  call void @llvm.dbg.declare(metadata i32** %.Z0640_333, metadata !14, metadata !DIExpression()), !dbg !13
31  ret void, !dbg !16
32}
33
34; Function Attrs: nounwind readnone speculatable willreturn
35declare void @llvm.dbg.declare(metadata, metadata, metadata)
36
37!llvm.module.flags = !{!0, !1}
38!llvm.dbg.cu = !{!2}
39
40!0 = !{i32 2, !"Dwarf Version", i32 4}
41!1 = !{i32 2, !"Debug Info Version", i32 3}
42!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)
43!3 = !DIFile(filename: "allocated.f90", directory: "/dir")
44!4 = !{}
45!5 = distinct !DISubprogram(name: "main", scope: !2, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2)
46!6 = !DISubroutineType(cc: DW_CC_program, types: !7)
47!7 = !{null}
48!8 = !DILocalVariable(name: "arr", scope: !5, file: !3, type: !9)
49!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 32, align: 32, elements: !11, dataLocation: !DIExpression(DW_OP_push_object_address, DW_OP_deref), allocated: !DIExpression(DW_OP_push_object_address, DW_OP_deref))
50!10 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
51!11 = !{!12}
52!12 = !DISubrange(count: 19, lowerBound: 2)
53!13 = !DILocation(line: 0, scope: !5)
54!14 = distinct !DILocalVariable(scope: !5, file: !3, type: !15, flags: DIFlagArtificial)
55!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 32, align: 32)
56!16 = !DILocation(line: 6, column: 1, scope: !5)
57