xref: /llvm-project/llvm/test/DebugInfo/X86/global-sra-struct-part-overlap-segment.ll (revision 20d8f8ca1a9de3506c7cad55abcea501a0c57afa)
1; RUN: opt -S -p globalopt < %s | FileCheck %s
2
3;; Generated at -g from:
4;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5;;MODULE mymod
6;;   IMPLICIT NONE
7;;   INTEGER, PARAMETER :: dp = SELECTED_REAL_KIND(14, 200)
8;;CONTAINS
9;;   FUNCTION foo(arg)
10;;      REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN)         :: arg
11;;      INTEGER, DIMENSION(3)                              :: foo
12;;      foo = bar(arg)
13;;   END FUNCTION foo
14;;   FUNCTION bar(arg)
15;;      REAL(KIND=dp), DIMENSION(3, 3), INTENT(IN)         :: arg
16;;      INTEGER, DIMENSION(3)                              :: bar
17;;      REAL(KIND=dp)                                      :: rvar(3)
18;;      rvar = arg(1,:)
19;;      IF(rvar(1) == 0._dp) print *,"IF"
20;;      bar = FLOOR(rvar)
21;;   END FUNCTION bar
22;;END MODULE mymod
23;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24
25%struct.BSS3 = type <{ [24 x i8] }>
26
27@.BSS3 = internal unnamed_addr global %struct.BSS3 zeroinitializer, align 32, !dbg !0, !dbg !7, !dbg !29
28;CHECK: @.BSS3.0 = internal unnamed_addr global double 0.000000e+00, align 32, !dbg ![[GVE1:.*]], !dbg ![[GVE2:.*]]
29;CHECK: @.BSS3.1 = internal unnamed_addr global double 0.000000e+00, align 8, !dbg ![[GVE3:.*]], !dbg ![[GVE4:.*]], !dbg ![[GVE6:.*]]
30;CHECK: @.BSS3.2 = internal unnamed_addr global double 0.000000e+00, align 16, !dbg ![[GVE5:.*]]
31
32@.C363_mymod_bar_ = internal constant [2 x i8] c"IF"
33@.C330_mymod_bar_ = internal constant i32 0
34@.C360_mymod_bar_ = internal constant i32 6
35@.C357_mymod_bar_ = internal constant [9 x i8] c"frag1.f90"
36@.C359_mymod_bar_ = internal constant i32 15
37
38define float @mymod_() local_unnamed_addr {
39.L.entry:
40  ret float undef
41}
42
43define void @mymod_foo_(ptr noalias nocapture writeonly %foo, ptr noalias nocapture readonly %arg) local_unnamed_addr !dbg !22 {
44L.entry:
45  tail call void @llvm.experimental.noalias.scope.decl(metadata !23)
46  tail call void @llvm.experimental.noalias.scope.decl(metadata !26)
47  %0 = bitcast ptr %arg to ptr
48  %1 = load double, ptr %0, align 8, !noalias !23
49  store double %1, ptr @.BSS3, align 32, !noalias !28
50  %2 = getelementptr i64, ptr %arg, i64 3
51  %3 = bitcast ptr %2 to ptr
52  %4 = load double, ptr %3, align 8, !alias.scope !26, !noalias !23
53  store double %4, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8, !noalias !28
54  %5 = getelementptr i64, ptr %arg, i64 6
55  %6 = bitcast ptr %5 to ptr
56  %7 = load double, ptr %6, align 8, !alias.scope !26, !noalias !23
57  store double %7, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16, !noalias !28
58  %8 = fcmp une double %1, 0.000000e+00
59  br i1 %8, label %L.LB3_377.i, label %L.LB3_417.i
60
61L.LB3_417.i:                                      ; preds = %L.entry
62  tail call void (ptr, ptr, i64, ...) @f90io_src_info03a(ptr @.C359_mymod_bar_, ptr @.C357_mymod_bar_, i64 9), !noalias !28
63  %9 = tail call i32 (ptr, ptr, ptr, ptr, ...) @f90io_print_init(ptr @.C360_mymod_bar_, ptr null, ptr @.C330_mymod_bar_, ptr @.C330_mymod_bar_), !noalias !28
64  %10 = tail call i32 (ptr, i32, i64, ...) @f90io_sc_ch_ldw(ptr @.C363_mymod_bar_, i32 14, i64 2), !noalias !28
65  %11 = tail call i32 (...) @f90io_ldw_end(), !noalias !28
66  %.pre = load double, ptr @.BSS3, align 32, !noalias !28
67  %.pre1 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8, !noalias !28
68  %.pre2 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16, !noalias !28
69  br label %L.LB3_377.i
70
71L.LB3_377.i:                                      ; preds = %L.LB3_417.i, %L.entry
72  %12 = phi double [ %.pre2, %L.LB3_417.i ], [ %7, %L.entry ]
73  %13 = phi double [ %.pre1, %L.LB3_417.i ], [ %4, %L.entry ]
74  %14 = phi double [ %.pre, %L.LB3_417.i ], [ %1, %L.entry ]
75  %15 = bitcast ptr %foo to ptr
76  %16 = tail call double @llvm.floor.f64(double %14)
77  %17 = fptosi double %16 to i32
78  %18 = bitcast ptr %foo to ptr
79  store i32 %17, ptr %18, align 4, !alias.scope !23, !noalias !26
80  %19 = tail call double @llvm.floor.f64(double %13)
81  %20 = fptosi double %19 to i32
82  %21 = getelementptr i8, ptr %15, i64 4
83  %22 = bitcast ptr %21 to ptr
84  store i32 %20, ptr %22, align 4, !alias.scope !23, !noalias !26
85  %23 = tail call double @llvm.floor.f64(double %12)
86  %24 = fptosi double %23 to i32
87  %25 = getelementptr i64, ptr %foo, i64 1
88  %26 = bitcast ptr %25 to ptr
89  store i32 %24, ptr %26, align 4, !alias.scope !23, !noalias !26
90  ret void
91}
92
93define void @mymod_bar_(ptr noalias nocapture writeonly %bar, ptr noalias nocapture readonly %arg) local_unnamed_addr !dbg !9 {
94L.entry:
95  %0 = bitcast ptr %arg to ptr
96  %1 = load double, ptr %0, align 8
97  store double %1, ptr @.BSS3, align 32
98  %2 = getelementptr i64, ptr %arg, i64 3
99  %3 = bitcast ptr %2 to ptr
100  %4 = load double, ptr %3, align 8
101  store double %4, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8
102  %5 = getelementptr i64, ptr %arg, i64 6
103  %6 = bitcast ptr %5 to ptr
104  %7 = load double, ptr %6, align 8
105  store double %7, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16
106  %8 = fcmp une double %1, 0.000000e+00
107  br i1 %8, label %L.LB3_377, label %L.LB3_417
108
109L.LB3_417:                                        ; preds = %L.entry
110  tail call void (ptr, ptr, i64, ...) @f90io_src_info03a(ptr @.C359_mymod_bar_, ptr @.C357_mymod_bar_, i64 9)
111  %9 = tail call i32 (ptr, ptr, ptr, ptr, ...) @f90io_print_init(ptr @.C360_mymod_bar_, ptr null, ptr @.C330_mymod_bar_, ptr @.C330_mymod_bar_)
112  %10 = tail call i32 (ptr, i32, i64, ...) @f90io_sc_ch_ldw(ptr @.C363_mymod_bar_, i32 14, i64 2)
113  %11 = tail call i32 (...) @f90io_ldw_end()
114  %.pre = load double, ptr @.BSS3, align 32
115  %.pre1 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 8), align 8
116  %.pre2 = load double, ptr getelementptr inbounds (%struct.BSS3, ptr @.BSS3, i64 0, i32 0, i64 16), align 16
117  br label %L.LB3_377
118
119L.LB3_377:                                        ; preds = %L.LB3_417, %L.entry
120  %12 = phi double [ %.pre2, %L.LB3_417 ], [ %7, %L.entry ]
121  %13 = phi double [ %.pre1, %L.LB3_417 ], [ %4, %L.entry ]
122  %14 = phi double [ %.pre, %L.LB3_417 ], [ %1, %L.entry ]
123  %15 = bitcast ptr %bar to ptr
124  %16 = tail call double @llvm.floor.f64(double %14)
125  %17 = fptosi double %16 to i32
126  %18 = bitcast ptr %bar to ptr
127  store i32 %17, ptr %18, align 4
128  %19 = tail call double @llvm.floor.f64(double %13)
129  %20 = fptosi double %19 to i32
130  %21 = getelementptr i8, ptr %15, i64 4
131  %22 = bitcast ptr %21 to ptr
132  store i32 %20, ptr %22, align 4
133  %23 = tail call double @llvm.floor.f64(double %12)
134  %24 = fptosi double %23 to i32
135  %25 = getelementptr i64, ptr %bar, i64 1
136  %26 = bitcast ptr %25 to ptr
137  store i32 %24, ptr %26, align 4
138  ret void
139}
140
141declare signext i32 @f90io_ldw_end(...) local_unnamed_addr
142
143declare signext i32 @f90io_sc_ch_ldw(...) local_unnamed_addr
144
145declare signext i32 @f90io_print_init(...) local_unnamed_addr
146
147declare void @f90io_src_info03a(...) local_unnamed_addr
148
149; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
150declare double @llvm.floor.f64(double)
151
152; Function Attrs: inaccessiblememonly nocallback nofree nosync nounwind willreturn
153declare void @llvm.experimental.noalias.scope.decl(metadata)
154
155!llvm.module.flags = !{!20, !21}
156!llvm.dbg.cu = !{!3}
157
158; CHECK-DAG: ![[GVE1]] = !DIGlobalVariableExpression(var: ![[GV1:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 0, 64))
159; CHECK-DAG: ![[GV1]] = distinct !DIGlobalVariable(name: "bar1"
160; CHECK-DAG: ![[GVE2]] = !DIGlobalVariableExpression(var: ![[GV2:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 0, 64))
161; CHECK-DAG: ![[GV2]] = distinct !DIGlobalVariable(name: "rvar"
162; CHECK-DAG: ![[GVE3]] = !DIGlobalVariableExpression(var: ![[GV1]], expr: !DIExpression(DW_OP_LLVM_fragment, 64, 32))
163; CHECK-DAG: ![[GVE4]] = !DIGlobalVariableExpression(var: ![[GV2]], expr: !DIExpression(DW_OP_LLVM_fragment, 64, 64))
164; CHECK-DAG: ![[GVE5]] = !DIGlobalVariableExpression(var: ![[GV2]], expr: !DIExpression(DW_OP_LLVM_fragment, 128, 64))
165; CHECK-DAG: ![[GVE6]] = !DIGlobalVariableExpression(var: ![[GV3:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 32, 32))
166; CHECK-DAG: ![[GV3]] = distinct !DIGlobalVariable(name: "ivar"
167
168!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
169!1 = distinct !DIGlobalVariable(name: "bar1", scope: !2, file: !4, type: !12, isLocal: true, isDefinition: true)
170!2 = !DIModule(scope: !3, name: "mymod", isDecl: true)
171!3 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !4, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: true, flags: "'+flang -g -O3 -S -emit-llvm -o -O1'", runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5, nameTableKind: None)
172!4 = !DIFile(filename: "global-sra-struct-part-overlap-segment_0.f90", directory: "/tmp")
173!5 = !{}
174!6 = !{!0, !7, !29}
175!7 = !DIGlobalVariableExpression(var: !8, expr: !DIExpression())
176!8 = distinct !DIGlobalVariable(name: "rvar", scope: !9, file: !4, line: 13, type: !19, isLocal: true, isDefinition: true)
177!9 = distinct !DISubprogram(name: "bar", scope: !2, file: !4, line: 10, type: !10, scopeLine: 10, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3)
178!10 = !DISubroutineType(types: !11)
179!11 = !{null, !12, !16}
180!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 96, align: 32, elements: !14)
181!13 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed)
182!14 = !{!15}
183!15 = !DISubrange(lowerBound: 1, upperBound: 3)
184!16 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 576, align: 64, elements: !18)
185!17 = !DIBasicType(name: "double precision", size: 64, align: 64, encoding: DW_ATE_float)
186!18 = !{!15, !15}
187!19 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, size: 192, align: 64, elements: !14)
188!20 = !{i32 2, !"Dwarf Version", i32 4}
189!21 = !{i32 2, !"Debug Info Version", i32 3}
190!22 = distinct !DISubprogram(name: "foo", scope: !2, file: !4, line: 5, type: !10, scopeLine: 5, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !3)
191!23 = !{!24}
192!24 = distinct !{!24, !25, !"mymod_bar_: %bar"}
193!25 = distinct !{!25, !"mymod_bar_"}
194!26 = !{!27}
195!27 = distinct !{!27, !25, !"mymod_bar_: %arg"}
196!28 = !{!24, !27}
197!29 = !DIGlobalVariableExpression(var: !30, expr: !DIExpression(DW_OP_plus_uconst, 4))
198!30 = distinct !DIGlobalVariable(name: "ivar", scope: !9, file: !4, line: 13, type: !31, isLocal: true, isDefinition: true)
199!31 = !DIBasicType(name: "integer*8", size: 64, align: 32, encoding: DW_ATE_signed)
200