1 ;; Check whether fortran assumed size array is accepted
2 ;; which has upperBound absent in DISubrange
4 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu %s -filetype=obj -o %t.o
5 ; RUN: llvm-dwarfdump %t.o | FileCheck %s
8 ; RUN: sed -e "s/Fortran90/Fortran18/" %s > %t/test.ll
9 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu %t/test.ll -filetype=obj -o %t/test.o
10 ; RUN: llvm-dwarfdump %t/test.o | FileCheck %s
12 ; CHECK-LABEL: DW_TAG_formal_parameter
13 ; CHECK: DW_AT_name ("array1")
14 ; CHECK: DW_AT_type ([[type1:0x[0-9a-f]+]]
15 ; CHECK-LABEL: DW_TAG_formal_parameter
16 ; CHECK: DW_AT_name ("array2")
17 ; CHECK: DW_AT_type ([[type2:0x[0-9a-f]+]]
18 ; CHECK: [[type1]]: DW_TAG_array_type
19 ; CHECK: DW_TAG_subrange_type
20 ; CHECK: [[type2]]: DW_TAG_array_type
21 ; CHECK: DW_TAG_subrange_type
22 ; CHECK: DW_AT_lower_bound (4)
23 ; CHECK: DW_AT_upper_bound (9)
24 ; CHECK: DW_TAG_subrange_type
25 ; CHECK: DW_AT_lower_bound (10)
28 ;; original fortran program
29 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
30 ;;subroutine sub (array1, array2)
31 ;; integer :: array1 (*)
32 ;; integer :: array2 (4:9, 10:*)
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
39 ; ModuleID = 'assumed_size_array.ll'
40 source_filename = "assumed_size_array.ll"
41 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
42 target triple = "x86_64-unknown-linux-gnu"
44 @.C344_sub_ = internal constant i32 10
45 @.C345_sub_ = internal constant i64 10
46 @.C351_sub_ = internal constant i64 5
47 @.C341_sub_ = internal constant i32 9
48 @.C322_sub_ = internal constant i64 1
49 @.C350_sub_ = internal constant i64 8
50 @.C349_sub_ = internal constant i64 7
52 define void @sub_(ptr noalias %array1, ptr noalias %array2) #0 !dbg !5 {
54 %.dY0001_361 = alloca i64, align 8
55 %"i$a_357" = alloca i64, align 8
56 call void @llvm.dbg.declare(metadata ptr %array1, metadata !16, metadata !DIExpression()), !dbg !17
57 call void @llvm.dbg.declare(metadata ptr %array2, metadata !18, metadata !DIExpression()), !dbg !17
60 L.LB1_364: ; preds = %L.entry
61 store i64 2, ptr %.dY0001_361, align 8, !dbg !19
62 call void @llvm.dbg.declare(metadata ptr %"i$a_357", metadata !20, metadata !DIExpression()), !dbg !17
63 store i64 7, ptr %"i$a_357", align 8, !dbg !19
66 L.LB1_359: ; preds = %L.LB1_359, %L.LB1_364
67 %0 = load i64, ptr %"i$a_357", align 8, !dbg !19
68 call void @llvm.dbg.value(metadata i64 %0, metadata !22, metadata !DIExpression()), !dbg !17
69 %1 = getelementptr i8, ptr %array1, i64 -4, !dbg !19
70 %2 = getelementptr i32, ptr %1, i64 %0, !dbg !19
71 store i32 9, ptr %2, align 4, !dbg !19
72 %3 = load i64, ptr %"i$a_357", align 8, !dbg !19
73 call void @llvm.dbg.value(metadata i64 %3, metadata !23, metadata !DIExpression()), !dbg !17
74 %4 = add nsw i64 %3, 1, !dbg !19
75 store i64 %4, ptr %"i$a_357", align 8, !dbg !19
76 %5 = load i64, ptr %.dY0001_361, align 8, !dbg !19
77 %6 = sub nsw i64 %5, 1, !dbg !19
78 store i64 %6, ptr %.dY0001_361, align 8, !dbg !19
79 %7 = load i64, ptr %.dY0001_361, align 8, !dbg !19
80 %8 = icmp sgt i64 %7, 0, !dbg !19
81 br i1 %8, label %L.LB1_359, label %L.LB1_383, !dbg !19
83 L.LB1_383: ; preds = %L.LB1_359
84 %9 = getelementptr i8, ptr %array2, i64 4, !dbg !24
85 store i32 10, ptr %9, align 4, !dbg !24
89 ; Function Attrs: nounwind readnone speculatable willreturn
90 declare void @llvm.dbg.declare(metadata, metadata, metadata)
92 ; Function Attrs: nounwind readnone speculatable willreturn
93 declare void @llvm.dbg.value(metadata, metadata, metadata)
95 !llvm.module.flags = !{!0, !1}
98 !0 = !{i32 2, !"Dwarf Version", i32 4}
99 !1 = !{i32 2, !"Debug Info Version", i32 3}
100 !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)
101 !3 = !DIFile(filename: "assumed_size_array.f90", directory: "/tmp")
103 !5 = distinct !DISubprogram(name: "sub", scope: !2, file: !3, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2)
104 !6 = !DISubroutineType(types: !7)
105 !7 = !{null, !8, !12}
106 !8 = !DICompositeType(tag: DW_TAG_array_type, baseType: !9, align: 32, elements: !10)
107 !9 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
109 !11 = !DISubrange(lowerBound: 1)
110 !12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !9, align: 32, elements: !13)
112 !14 = !DISubrange(lowerBound: 4, upperBound: 9)
113 !15 = !DISubrange(lowerBound: 10)
114 !16 = !DILocalVariable(name: "array1", arg: 1, scope: !5, file: !3, line: 1, type: !8)
115 !17 = !DILocation(line: 0, scope: !5)
116 !18 = !DILocalVariable(name: "array2", arg: 2, scope: !5, file: !3, line: 1, type: !12)
117 !19 = !DILocation(line: 5, column: 1, scope: !5)
118 !20 = distinct !DILocalVariable(scope: !5, file: !3, type: !21, flags: DIFlagArtificial)
119 !21 = !DIBasicType(name: "integer*8", size: 64, align: 64, encoding: DW_ATE_signed)
120 !22 = distinct !DILocalVariable(scope: !5, file: !3, type: !21, flags: DIFlagArtificial)
121 !23 = distinct !DILocalVariable(scope: !5, file: !3, type: !21, flags: DIFlagArtificial)
122 !24 = !DILocation(line: 6, column: 1, scope: !5)
123 !25 = !DILocation(line: 7, column: 1, scope: !5)