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