1 ;; Test for !DIStringType.!DIStringType is used to construct a Fortran
2 ;; CHARACTER intrinsic type, with a LEN type parameter where LEN is a
3 ;; dynamic parameter as in a deferred-length CHARACTER. LLVM after
4 ;; processing !DIStringType metadata in either of the following forms,
5 ;; generates DW_AT_string_length attribute
6 ;; !DIStringType(name: "character(*)", stringLength: !{{[0-9]+}})
7 ;; !DIStringType(name: "character(*)", stringLengthExpr: !DIExpression(...))
9 ; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
10 ; CHECK: DW_TAG_string_type
11 ; CHECK: DW_AT_name (".str.DEFERRED")
12 ; CHECK-NEXT: DW_AT_string_length (DW_OP_push_object_address, DW_OP_plus_uconst 0x8)
13 ; CHECK: DW_TAG_string_type
14 ; CHECK: DW_AT_name ("character(*)!2")
15 ; CHECK-NEXT: DW_AT_string_length
17 ;; sample fortran testcase involving deferred and assumed length string types.
18 ;; program assumedLength
19 ;; character(len=:), allocatable :: deferred
20 ;; allocate(character(10)::deferred)
22 ;; call sub('Goodbye')
24 ;; subroutine sub(string)
26 ;; character(len=*), intent(in) :: string
29 ;; end program assumedLength
31 ; ModuleID = 'distring.f90'
32 source_filename = "distring.f90"
33 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
34 target triple = "x86_64-unknown-linux-gnu"
36 %"QNCA_a0$i8*$rank0$" = type { i8*, i64, i64, i64, i64, i64 }
38 @0 = internal unnamed_addr constant [7 x i8] c"Goodbye"
39 @1 = internal unnamed_addr constant [5 x i8] c"Hello"
40 @"assumedlength_$DEFERRED" = internal global %"QNCA_a0$i8*$rank0$" zeroinitializer, !dbg !0
41 @2 = internal unnamed_addr constant i32 2
43 ; Function Attrs: noinline nounwind uwtable
44 define void @MAIN__() #0 !dbg !2 {
46 %"var$1" = alloca [8 x i64], align 8
47 %"var$2" = alloca i64, align 8
48 %strlit = load [7 x i8], [7 x i8]* @0, align 1
49 %strlit1 = load [5 x i8], [5 x i8]* @1, align 1
50 %func_result = call i32 @for_set_reentrancy(i32* @2), !dbg !12
51 %val_fetch = load i64, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 1), align 1, !dbg !13
52 %val_fetch4 = load i64, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 3), align 1, !dbg !13
53 %and = and i64 %val_fetch4, 256, !dbg !13
54 %lshr = lshr i64 %and, 8, !dbg !13
55 %shl = shl i64 %lshr, 8, !dbg !13
56 %or = or i64 133, %shl, !dbg !13
57 %and5 = and i64 %val_fetch4, 1030792151040, !dbg !13
58 %lshr6 = lshr i64 %and5, 36, !dbg !13
59 %and7 = and i64 %or, -1030792151041, !dbg !13
60 %shl8 = shl i64 %lshr6, 36, !dbg !13
61 %or9 = or i64 %and7, %shl8, !dbg !13
62 store i64 %or9, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 3), align 1, !dbg !13
63 store i64 10, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 1), align 1, !dbg !13
64 store i64 0, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 4), align 1, !dbg !13
65 store i64 0, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 2), align 1, !dbg !13
66 %val_fetch10 = load i64, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 3), align 1, !dbg !13
67 %val_fetch11 = load i64, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 3), align 1, !dbg !13
68 %and12 = and i64 %val_fetch11, -68451041281, !dbg !13
69 %or13 = or i64 %and12, 1073741824, !dbg !13
70 store i64 %or13, i64* getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 3), align 1, !dbg !13
71 %and14 = and i64 %val_fetch10, 1, !dbg !13
72 %shl15 = shl i64 %and14, 1, !dbg !13
73 %int_zext = trunc i64 %shl15 to i32, !dbg !13
74 %or16 = or i32 0, %int_zext, !dbg !13
75 %and17 = and i32 %or16, -17, !dbg !13
76 %and18 = and i64 %val_fetch10, 256, !dbg !13
77 %lshr19 = lshr i64 %and18, 8, !dbg !13
78 %and20 = and i32 %and17, -2097153, !dbg !13
79 %shl21 = shl i64 %lshr19, 21, !dbg !13
80 %int_zext22 = trunc i64 %shl21 to i32, !dbg !13
81 %or23 = or i32 %and20, %int_zext22, !dbg !13
82 %and24 = and i64 %val_fetch10, 1030792151040, !dbg !13
83 %lshr25 = lshr i64 %and24, 36, !dbg !13
84 %and26 = and i32 %or23, -31457281, !dbg !13
85 %shl27 = shl i64 %lshr25, 21, !dbg !13
86 %int_zext28 = trunc i64 %shl27 to i32, !dbg !13
87 %or29 = or i32 %and26, %int_zext28, !dbg !13
88 %and30 = and i64 %val_fetch10, 1099511627776, !dbg !13
89 %lshr31 = lshr i64 %and30, 40, !dbg !13
90 %and32 = and i32 %or29, -33554433, !dbg !13
91 %shl33 = shl i64 %lshr31, 25, !dbg !13
92 %int_zext34 = trunc i64 %shl33 to i32, !dbg !13
93 %or35 = or i32 %and32, %int_zext34, !dbg !13
94 %and36 = and i32 %or35, -2031617, !dbg !13
95 %or37 = or i32 %and36, 262144, !dbg !13
96 %func_result3 = call i32 @for_alloc_allocatable(i64 10, i8** getelementptr inbounds (%"QNCA_a0$i8*$rank0$", %"QNCA_a0$i8*$rank0$"* @"assumedlength_$DEFERRED", i32 0, i32 0), i32 %or37), !dbg !13
97 call void @assumedlength_IP_sub_(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i64 5), !dbg !14
98 call void @assumedlength_IP_sub_(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @0, i32 0, i32 0), i64 7), !dbg !15
102 ; Function Attrs: noinline nounwind uwtable
103 define void @assumedlength_IP_sub_(i8* noalias nocapture readonly %STRING, i64 %"STRING.len$val") #0 !dbg !17 {
105 %"var$3" = alloca [8 x i64], align 8
106 %STRING.len = alloca i64, align 8, !dbg !23
107 %"var$4" = alloca i32, align 4, !dbg !23
108 %"(&)val$" = alloca [4 x i8], align 1, !dbg !23
109 %argblock = alloca { i64, i8* }, align 8, !dbg !23
110 call void @llvm.dbg.declare(metadata i64* %STRING.len, metadata !19, metadata !DIExpression()), !dbg !23
111 call void @llvm.dbg.declare(metadata i8* %STRING, metadata !21, metadata !DIExpression()), !dbg !24
112 store i64 %"STRING.len$val", i64* %STRING.len, align 8
113 %strlit = load [7 x i8], [7 x i8]* @0, align 1, !dbg !25
114 %strlit1 = load [5 x i8], [5 x i8]* @1, align 1, !dbg !25
115 %STRING.len_fetch = load i64, i64* %STRING.len, align 1, !dbg !26
116 store [4 x i8] c"8\04\01\00", [4 x i8]* %"(&)val$", align 1, !dbg !26
117 %BLKFIELD_ = getelementptr inbounds { i64, i8* }, { i64, i8* }* %argblock, i32 0, i32 0, !dbg !26
118 store i64 %STRING.len_fetch, i64* %BLKFIELD_, align 1, !dbg !26
119 %BLKFIELD_3 = getelementptr inbounds { i64, i8* }, { i64, i8* }* %argblock, i32 0, i32 1, !dbg !26
120 store i8* %STRING, i8** %BLKFIELD_3, align 1, !dbg !26
121 %"(i8*)var$3$" = bitcast [8 x i64]* %"var$3" to i8*, !dbg !26
122 %"(i8*)(&)val$$" = bitcast [4 x i8]* %"(&)val$" to i8*, !dbg !26
123 %"(i8*)argblock$" = bitcast { i64, i8* }* %argblock to i8*, !dbg !26
124 %func_result = call i32 (i8*, i32, i64, i8*, i8*, ...) @for_write_seq_lis(i8* %"(i8*)var$3$", i32 -1, i64 1239157112576, i8* %"(i8*)(&)val$$", i8* %"(i8*)argblock$"), !dbg !26
128 declare i32 @for_set_reentrancy(i32*)
130 declare i32 @for_alloc_allocatable(i64, i8**, i32)
132 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
133 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
135 declare i32 @for_write_seq_lis(i8*, i32, i64, i8*, i8*, ...)
137 attributes #0 = { noinline nounwind uwtable "intel-lang"="fortran" "min-legal-vector-width"="0" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" }
138 attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
140 !llvm.module.flags = !{!10, !11}
142 !omp_offload.info = !{}
144 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
145 !1 = distinct !DIGlobalVariable(name: "deferred", linkageName: "assumedlength_$DEFERRED", scope: !2, file: !3, line: 2, type: !9, isLocal: true, isDefinition: true)
146 !2 = distinct !DISubprogram(name: "assumedlength", linkageName: "MAIN__", scope: !3, file: !3, line: 1, type: !4, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !7)
147 !3 = !DIFile(filename: "distring.f90", directory: "/iusers/cchen15/examples/tests")
148 !4 = !DISubroutineType(types: !5)
150 !6 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3, producer: "Intel(R) Fortran 21.0-2142", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !7, globals: !8, splitDebugInlining: false, nameTableKind: None)
153 !9 = !DIStringType(name: ".str.DEFERRED", stringLengthExpression: !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8))
154 !10 = !{i32 2, !"Debug Info Version", i32 3}
155 !11 = !{i32 2, !"Dwarf Version", i32 4}
156 !12 = !DILocation(line: 1, column: 9, scope: !2)
157 !13 = !DILocation(line: 3, column: 3, scope: !2)
158 !14 = !DILocation(line: 4, column: 8, scope: !2)
159 !15 = !DILocation(line: 5, column: 8, scope: !2)
160 !16 = !DILocation(line: 6, column: 3, scope: !2)
161 !17 = distinct !DISubprogram(name: "sub", linkageName: "assumedlength_IP_sub_", scope: !3, file: !3, line: 7, type: !4, scopeLine: 7, spFlags: DISPFlagDefinition, unit: !6, retainedNodes: !18)
163 !19 = !DILocalVariable(name: "STRING.len", scope: !17, type: !20, flags: DIFlagArtificial)
164 !20 = !DIBasicType(name: "INTEGER*8", size: 64, encoding: DW_ATE_signed)
165 !21 = !DILocalVariable(name: "string", arg: 1, scope: !17, file: !3, line: 7, type: !22)
166 !22 = !DIStringType(name: "character(*)!2", stringLength: !19)
167 !23 = !DILocation(line: 0, scope: !17)
168 !24 = !DILocation(line: 7, column: 18, scope: !17)
169 !25 = !DILocation(line: 7, column: 14, scope: !17)
170 !26 = !DILocation(line: 10, column: 11, scope: !17)
171 !27 = !DILocation(line: 11, column: 3, scope: !17)